mcpField
L
lightning-2025-features

lightning-2025-features

github.com/josiahsiegel開発59150 回インストール19 週間前に更新
リポジトリ

lightning-2025-features について

lightning-2025-featuresは、Salesforce Lightning Web Componentsの新機能と移行例をまとめた資料です。LWC開発者向けに、ローカル開発、Agentforceターゲット、テスト、セキュリティ、デザインシステムの変更を扱います。

主な機能

  1. 01lightning/graphqlへの移行
  2. 02LWCのローカル実行とホットリロード
  3. 03Agentforceコンポーネントターゲットの利用
  4. 04Lightning Out 2.0によるコンポーネント埋め込み
  5. 05SLDS 2.0のダークモードと統合テストAPI

活用シーン

  1. 01LWCのローカルプレビューとデバッグ
  2. 02Agentforce向け入力・出力コンポーネントの作成
  3. 03外部ページへのコンポーネント埋め込み
  4. 04GraphQLモジュールの更新とテストの統合

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/josiahsiegel/claude-plugin-marketplace --skill lightning-2025-features

インストール後、Claude Code で/lightning-2025-featuresを入力して読み込まれたか確認します。

詳細

🚨 重要なガイドライン

Windows のファイルパス要件

必須:Windows ではファイルパスに必ずバックスラッシュを使用してください

Windows で Edit または Write ツールを使用する場合、ファイルパスにはスラッシュ(/)ではなく、必ずバックスラッシュ(\)を使用してください。

例:

  • ❌ 誤り:D:/repos/project/file.tsx
  • ✅ 正しい:D:\repos\project\file.tsx

これは次に適用されます。

  • Edit ツールの file_path パラメーター
  • Write ツールの file_path パラメーター
  • Windows システムでのすべてのファイル操作
ドキュメント作成のガイドライン

ユーザーから明示的に依頼されない限り、新しいドキュメントファイルを作成しないでください。

  • 優先事項:新しいドキュメントを作成するのではなく、既存の README.md ファイルを更新してください
  • リポジトリの整理:ユーザーから別途依頼がない限り、リポジトリのルートは README.md のみとし、すっきり保ってください
  • スタイル:ドキュメントは簡潔、明快、かつプロフェッショナルにまとめ、AI 生成らしい文体は避けてください
  • ユーザーの希望:ユーザーがドキュメントを明示的に求めた場合に限り、追加の .md ファイルを作成してください

Lightning Web Components 2025 の機能

lightning/graphql モジュール(Winter '26)

非推奨の lightning/uiGraphQLApi に代わる新しいモジュールです。

移行
// ❌ Old (deprecated)
import { gql, graphql } from 'lightning/uiGraphQLApi';

// ✅ New (Winter '26)
import { gql, graphql } from 'lightning/graphql';

export default class MyComponent extends LightningElement {
  @wire(graphql, {
    query: gql`
      query getAccount($id: ID!) {
        uiapi {
          query {
            Account(where: { Id: { eq: $id } }) {
              edges {
                node {
                  Id
                  Name
                  Industry
                }
              }
            }
          }
        }
      }
    `,
    variables: '$variables'
  })
  results;

  get variables() {
    return { id: this.recordId };
  }
}
メリット
  • パフォーマンスの向上
  • エラー処理の改善
  • 型安全性の強化
  • 将来性のある API

ローカル開発(sf lightning dev component)

デプロイせずに LWC コンポーネントをローカルで実行できます。

# Start local dev server
sf lightning dev component

# Opens browser at http://localhost:3333
# Live reload on file changes
# No deployment needed
# Faster development cycle

# Specify component
sf lightning dev component -n myComponent

# Specify target org
sf lightning dev component -o [email protected]

メリット:

  • すぐに結果を確認できます(デプロイを待つ必要がありません)
  • 実際のブラウザーの DevTools でデバッグできます
  • ホットモジュール置換に対応しています
  • オフラインで作業できます

コンポーネントプレビューでのプラットフォームモジュールへのアクセス

単一コンポーネントのプレビューでプラットフォームモジュールにアクセスできます。

// Works in local preview now
import { getRecord } from 'lightning/uiRecordApi';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { NavigationMixin } from 'lightning/navigation';

// Previously required full org deployment
// Now works in sf lightning dev component

Agentforce ターゲット(Winter '26)

AI エージェント向けの新しい LWC ターゲットです。


<targets>
  
  <target>lightning__AgentforceInput</target>

  
  <target>lightning__AgentforceOutput</target>
</targets>
// agentInputComponent.js
import { LightningElement, api } from 'lwc';

export default class AgentInputComponent extends LightningElement {
  @api agentContext;  // Provided by Agentforce

  handleSubmit() {
    const userInput = this.template.querySelector('input').value;
    // Send to Agentforce
    this.dispatchEvent(new CustomEvent('agentinput', {
      detail: { input: userInput }
    }));
  }
}

Lightning Out 2.0(Winter '26 で GA)

Web コンポーネントを使った、刷新された埋め込み方式です。

従来の Lightning Out(レガシー)
<script src="https://MyDomain.lightning.force.com/lightning/lightning.out.js"></script>
<script>
  $Lightning.use("c:myApp", function() {
    $Lightning.createComponent("c:myComponent",
      { recordId: "001..." },
      "lightningContainer",
      function(cmp) { /* callback */ }
    );
  });
</script>
<div id="lightningContainer"></div>
Lightning Out 2.0(モダン)

<script src="https://MyDomain.lightning.force.com/c/myComponent.js" type="module"></script>


<c-my-component record-id="001..." ></c-my-component>




メリット:

  • バンドルサイズを 50~70%削減
  • 読み込み時間の短縮
  • 標準ベース(独自フレームワークは不要)
  • ブラウザー互換性の向上
  • 統合の簡素化

ダークモード対応の SLDS 2.0(Winter '26 で GA)

Salesforce Lightning Design System 2.0:

/* Dark mode support in custom themes */
:host([data-theme="dark"]) {
  --lwc-colorBackground: #16325c;
  --lwc-colorTextPrimary: #ffffff;
  --lwc-brandPrimary: #1589ee;
}

/* Light mode */
:host([data-theme="light"]) {
  --lwc-colorBackground: #ffffff;
  --lwc-colorTextPrimary: #181818;
  --lwc-brandPrimary: #0176d3;
}
// Toggle dark mode
export default class ThemeToggle extends LightningElement {
  handleThemeChange(event) {
    const theme = event.target.checked ? 'dark' : 'light';
    this.template.host.setAttribute('data-theme', theme);
  }
}
修正オプション付き SLDS リンター
# Install SLDS linter
npm install -D @salesforce-ux/slds-linter

# Lint with auto-fix
npx slds-linter --fix src/

# CI/CD integration
npx slds-linter src/ --format json > slds-report.json

統合テスト API(Winter '26)

テスト検出 API とテストランナー API により、Apex と Flow のテストが統合されます。

// Discover all tests
Test.DiscoveryResult discovery = Test.discoverTests();

// Get Apex tests
List<Test.ApexTestInfo> apexTests = discovery.getApexTests();

// Get Flow tests
List<Test.FlowTestInfo> flowTests = discovery.getFlowTests();

// Run all tests from single location
Test.RunResult result = Test.runTests(discovery);

// Check results
System.debug('Apex passed: ' + result.getApexTestsPassed());
System.debug('Flow passed: ' + result.getFlowTestsPassed());

メリット:

  • テスト実行の統合
  • 単一のテストレポート
  • CI/CD の簡素化
  • テストオーケストレーションの改善

Lightning Web Security の強化

API の歪曲による新しいセキュリティ保護機能です。

// Additional secure protections automatically applied
export default class SecureComponent extends LightningElement {
  connectedCallback() {
    // Web APIs now include security distortions
    // ESLint rules validate distortion compliance

    // Example: Secure window access
    const secureWindow = window;  // LWS-secured reference
  }
}
セキュリティ用 ESLint ルール
// .eslintrc.json
{
  "extends": ["@salesforce/eslint-config-lwc/recommended"],
  "rules": {
    "@lwc/lwc/no-inner-html": "error",
    "@lwc/lwc/no-document-query": "error",
    "@salesforce/lwc-security/no-unsafe-references": "error"
  }
}

実践的な移行例

GraphQL モジュールの更新
// Before (Winter '25)
import { gql, graphql } from 'lightning/uiGraphQLApi';

@wire(graphql, { query: gql`...` })
results;

// After (Winter '26)
import { gql, graphql } from 'lightning/graphql';

@wire(graphql, { query: gql`...` })
results;
ローカル開発のワークフロー
# Old workflow (deploy every change)
sf project deploy start
# Wait 30-60 seconds
# Test in org
# Repeat...

# New workflow (instant feedback)
sf lightning dev component
# Changes reflect immediately
# No deployment
# Test in local browser
# Deploy only when ready
Lightning Out 2.0 を使った埋め込み

<script src="/lightning/lightning.out.js"></script>
<script>
  $Lightning.use("c:app", function() {
    $Lightning.createComponent("c:comp", {}, "div", callback);
  });
</script>


<script src="/c/comp.js" type="module"></script>
<c-comp></c-comp>

リソース

コメント