@aws/nx-plugin 1.0.0-rc.64 → 1.0.0-rc.65

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/migrations.json +12 -2
  2. package/package.json +1 -1
  3. package/src/mcp-server/guide-pipeline.js.map +1 -1
  4. package/src/migrations/latest/rolldown-code-splitting/metadata.json +3 -0
  5. package/src/migrations/latest/rolldown-code-splitting/migration.d.ts +6 -0
  6. package/src/migrations/latest/rolldown-code-splitting/migration.js +57 -0
  7. package/src/migrations/latest/rolldown-code-splitting/migration.js.map +1 -0
  8. package/src/migrations/latest/vite-config-import-meta-dirname/metadata.json +3 -0
  9. package/src/migrations/latest/vite-config-import-meta-dirname/migration.d.ts +6 -0
  10. package/src/migrations/latest/vite-config-import-meta-dirname/migration.js +71 -0
  11. package/src/migrations/latest/vite-config-import-meta-dirname/migration.js.map +1 -0
  12. package/src/py/rdb/__snapshots__/generator.spec.ts.snap +1 -1
  13. package/src/py/rdb/files/migrations/env.py.template +1 -1
  14. package/src/ts/lib/__snapshots__/vitest.spec.ts.snap +1 -1
  15. package/src/ts/lib/vitest.js +12 -0
  16. package/src/ts/lib/vitest.js.map +1 -1
  17. package/src/ts/nx-generator/__snapshots__/generator.spec.ts.snap +1 -1
  18. package/src/ts/nx-generator/files/local/generator.spec.ts.template +1 -1
  19. package/src/ts/nx-migration/files/migration.spec.ts.template +1 -1
  20. package/src/ts/nx-migration/generator.js +7 -1
  21. package/src/ts/nx-migration/generator.js.map +1 -1
  22. package/src/ts/rdb/__snapshots__/generator.spec.ts.snap +2 -2
  23. package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +10 -10
  24. package/src/ts/react-website/app/generator.js +1 -1
  25. package/src/ts/react-website/app/generator.js.map +1 -1
  26. package/src/utils/bundle/bundle.js +1 -1
  27. package/src/utils/bundle/bundle.js.map +1 -1
package/migrations.json CHANGED
@@ -47,6 +47,16 @@
47
47
  "description": "Build Smithy projects with the Smithy CLI directly rather than in a container, removing the Docker prerequisite",
48
48
  "implementation": "./src/migrations/latest/smithy-build-without-docker/migration"
49
49
  },
50
+ "latest-vite-config-import-meta-dirname": {
51
+ "version": "1.0.0-rc.65",
52
+ "description": "Resolve vite and vitest config paths from import.meta.dirname rather than __dirname",
53
+ "implementation": "./src/migrations/latest/vite-config-import-meta-dirname/migration"
54
+ },
55
+ "latest-rolldown-code-splitting": {
56
+ "version": "1.0.0-rc.65",
57
+ "description": "Replace the deprecated inlineDynamicImports rolldown output option with codeSplitting",
58
+ "implementation": "./src/migrations/latest/rolldown-code-splitting/migration"
59
+ },
50
60
  "v1.0.0-rc.50-0001-modernize-function-props-cast": {
51
61
  "version": "1.0.0-rc.50",
52
62
  "description": "Replace the legacy angle-bracket FunctionProps type assertion with the modern as syntax in generated API constructs",
@@ -88,14 +98,14 @@
88
98
  "implementation": "./src/migrations/v1.0.0-rc.57/0001-ts-agent-session-management-support/migration"
89
99
  },
90
100
  "sync-vended-versions": {
91
- "version": "1.0.0-rc.64",
101
+ "version": "1.0.0-rc.65",
92
102
  "description": "Sync vended dependency versions and the tracked plugin version to those vended by this release",
93
103
  "implementation": "./src/utils/version-upgrade-migration/migration"
94
104
  }
95
105
  },
96
106
  "packageJsonUpdates": {
97
107
  "nx-23.1.1-nx-packages": {
98
- "version": "1.0.0-rc.64",
108
+ "version": "1.0.0-rc.65",
99
109
  "packages": {
100
110
  "nx": {
101
111
  "version": "23.1.1",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws/nx-plugin",
3
- "version": "1.0.0-rc.64",
3
+ "version": "1.0.0-rc.65",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/awslabs/nx-plugin-for-aws.git",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../packages/nx-plugin/src/mcp-server/guide-pipeline.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport fs from 'fs';\n/**\n * Unified + remark-mdx pipeline for the MCP `generator-guide` tool.\n *\n * Passes (in order, each over the already-transformed tree):\n * 1. Snippet inlining — `<Snippet name>` → recursive post-process.\n * 2. Filter transforms — `<OptionFilter>`, `<Infrastructure>` slot\n * selection, `<Tabs><TabItem _filter>` pruning.\n * 3. Component transforms — `<NxCommands>` / `<RunGenerator>` /\n * `<GeneratorParameters>` / `<CreateNxWorkspaceCommand>` /\n * `<InstallCommand>` / `<PackageManagerShortCommand>` /\n * `<PackageManagerExecCommand>` render down to markdown.\n */\nimport type { Root, RootContent } from 'mdast';\nimport type { MdxJsxFlowElement } from 'mdast-util-mdx-jsx';\nimport {\n buildCreateNxWorkspaceCommand,\n buildInstallCommand,\n buildNxInitCommand,\n buildPackageManagerExecCommand,\n buildPackageManagerShortCommand,\n} from '../utils/commands';\nimport type { NxGeneratorInfo } from '../utils/generators';\nimport {\n buildNxCommand,\n renderGeneratorCommand,\n renderSchema,\n} from './guide-render';\nimport {\n hasBareAttr,\n isJsxElement,\n type JsxElement,\n type JsxParent,\n readEstreeAttr,\n readExpressionAttr,\n readStringAttr,\n} from './mdx-ast';\nimport {\n describePredicate,\n evaluatePredicate,\n extractStringArrayExpression,\n type Predicate,\n parseWhenExpression,\n} from './option-filter';\n\nexport interface PipelineOptions {\n generators: NxGeneratorInfo[];\n packageManager?: string;\n snippetContentProvider?: (name: string) => Promise<string> | string;\n options?: Record<string, string>;\n}\n\n// unified v11 is ESM-only and this package is CJS; dynamic import + rolldown's\n// inlineDynamicImports bundles everything into the published MCP binary.\ninterface RemarkDeps {\n unified: typeof import('unified').unified;\n remarkParse: typeof import('remark-parse').default;\n remarkMdx: typeof import('remark-mdx').default;\n remarkStringify: typeof import('remark-stringify').default;\n remarkFrontmatter: typeof import('remark-frontmatter').default;\n}\n\nlet depsPromise: Promise<RemarkDeps> | undefined;\nconst loadRemarkDeps = (): Promise<RemarkDeps> => {\n if (!depsPromise) {\n depsPromise = (async () => ({\n unified: (await import('unified')).unified,\n remarkParse: (await import('remark-parse')).default,\n remarkMdx: (await import('remark-mdx')).default,\n remarkStringify: (await import('remark-stringify')).default,\n remarkFrontmatter: (await import('remark-frontmatter')).default,\n }))();\n }\n return depsPromise;\n};\n\nconst parseMdxWithDeps = (source: string, deps: RemarkDeps): Root =>\n deps\n .unified()\n .use(deps.remarkParse)\n .use(deps.remarkFrontmatter)\n .use(deps.remarkMdx)\n .parse(source) as Root;\n\n/** Parse MDX (with frontmatter) into mdast. Exposed so callers like\n * `fetchGuideFrontmatters` don't need to re-load remark themselves. */\nexport const parseMdx = async (source: string): Promise<Root> => {\n const deps = await loadRemarkDeps();\n return parseMdxWithDeps(source, deps);\n};\n\nconst stringifyMdx = (tree: Root, deps: RemarkDeps): string =>\n String(\n deps\n .unified()\n .use(deps.remarkFrontmatter)\n .use(deps.remarkMdx)\n .use(deps.remarkStringify, {\n bullet: '-',\n fences: true,\n listItemIndent: 'one',\n })\n .stringify(tree),\n );\n\n/**\n * Remove nodes that are meaningless once the MDX is rendered to plain markdown\n * for an agent: the YAML frontmatter block and the `import`/`export` (ESM)\n * statements at the top of every docs page. They add noise and tokens without\n * conveying guidance.\n */\nconst stripFrontmatterAndEsm = (tree: Root): void => {\n tree.children = tree.children.filter(\n (node) => node.type !== 'yaml' && node.type !== 'mdxjsEsm',\n );\n};\n\nexport const postProcessGuideWithRemark = async (\n guide: string,\n opts: PipelineOptions,\n): Promise<string> => {\n const deps = await loadRemarkDeps();\n const tree = parseMdxWithDeps(guide, deps);\n\n await inlineSnippets(tree, opts, deps);\n applyFilterTransforms(tree, opts.options);\n applyComponentTransforms(tree, opts, deps);\n stripFrontmatterAndEsm(tree);\n\n return stringifyMdx(tree, deps);\n};\n\nconst inlineSnippets = async (\n tree: Root,\n opts: PipelineOptions,\n deps: RemarkDeps,\n): Promise<void> => {\n const provider = opts.snippetContentProvider;\n if (!provider) return;\n\n interface PendingSnippet {\n parent: JsxParent;\n index: number;\n name: string;\n node: JsxElement;\n }\n\n const pending: PendingSnippet[] = [];\n const walk = (parent: JsxParent): void => {\n const children = parent.children as RootContent[];\n for (let i = 0; i < children.length; i++) {\n const child = children[i];\n if (!isJsxElement(child)) continue;\n if (child.name === 'Snippet') {\n const name = readStringAttr(child, 'name');\n if (name) pending.push({ parent, index: i, name, node: child });\n continue;\n }\n walk(child);\n }\n };\n walk(tree);\n if (pending.length === 0) return;\n\n const fetched = await Promise.all(\n pending.map(async (p) => {\n let raw = '';\n try {\n raw = await provider(p.name);\n } catch {\n raw = '';\n }\n if (!raw) return { ...p, replacement: undefined };\n const processed = await postProcessGuideWithRemark(raw.trim(), opts);\n return { ...p, replacement: processed };\n }),\n );\n\n // Splice in descending index order per parent so earlier indices stay valid.\n const byParent = new Map<JsxParent, (typeof fetched)[number][]>();\n for (const f of fetched) {\n const bucket = byParent.get(f.parent) ?? [];\n bucket.push(f);\n byParent.set(f.parent, bucket);\n }\n for (const [parent, items] of byParent) {\n items.sort((a, b) => b.index - a.index);\n for (const { index, name, replacement, node } of items) {\n if (replacement === undefined) continue;\n const snippetTree = parseMdxWithDeps(replacement, deps);\n const wrapper: MdxJsxFlowElement = {\n type: 'mdxJsxFlowElement',\n name: 'Snippet',\n attributes: [{ type: 'mdxJsxAttribute', name: 'name', value: name }],\n children: snippetTree.children as MdxJsxFlowElement['children'],\n };\n if ('position' in node && node.position) {\n (wrapper as { position?: unknown }).position = node.position;\n }\n (parent.children as RootContent[]).splice(\n index,\n 1,\n wrapper as RootContent,\n );\n }\n }\n};\n\nconst applyFilterTransforms = (\n tree: Root,\n options: Record<string, string> | undefined,\n): void => {\n const iac = options?.iac;\n\n const transform = (parent: JsxParent): void => {\n const children = parent.children as RootContent[];\n for (let i = 0; i < children.length; i++) {\n const child = children[i];\n if (!isJsxElement(child)) continue;\n\n if (child.name === 'OptionFilter') {\n const when = parseWhenAttr(child);\n if (!when) continue; // malformed — leave alone\n // Recurse first so nested filters collapse before we replace this wrapper.\n transform(child);\n const not = hasBareAttr(child, 'not');\n if (options) {\n const replacement = evaluatePredicate(when, not, options)\n ? (child.children as RootContent[])\n : [];\n children.splice(i, 1, ...replacement);\n i += replacement.length - 1;\n } else {\n children.splice(i, 1, buildNoteQuote(child, when, not));\n }\n continue;\n }\n\n if (child.name === 'Infrastructure') {\n if (iac === 'cdk' || iac === 'terraform') {\n const body = selectInfrastructureSlot(child, iac);\n const pseudo: MdxJsxFlowElement = {\n type: 'mdxJsxFlowElement',\n name: 'tmp',\n attributes: [],\n children: body as MdxJsxFlowElement['children'],\n };\n transform(pseudo);\n children.splice(i, 1, ...(pseudo.children as RootContent[]));\n i--;\n continue;\n }\n // No iac → keep both slots so readers / agents see both variants.\n transform(child);\n continue;\n }\n\n if (child.name === 'Tabs' && child.type === 'mdxJsxFlowElement') {\n transform(child);\n const dropped = applyTabsFilter(child, options);\n if (dropped === 'empty') {\n children.splice(i, 1);\n i--;\n continue;\n }\n if (dropped === 'inline') {\n const survivor = (child.children as RootContent[]).find(\n (c): c is MdxJsxFlowElement =>\n isJsxElement(c) && c.name === 'TabItem',\n )!;\n const body = survivor.children as RootContent[];\n children.splice(i, 1, ...body);\n i += body.length - 1;\n continue;\n }\n continue;\n }\n\n transform(child);\n }\n };\n transform(tree);\n};\n\nconst selectInfrastructureSlot = (\n node: JsxElement,\n iac: 'cdk' | 'terraform',\n): RootContent[] => {\n const slotName = iac.toLowerCase();\n const frag = (node.children as RootContent[]).find(\n (c): c is MdxJsxFlowElement =>\n isJsxElement(c) &&\n c.name === 'Fragment' &&\n readStringAttr(c, 'slot') === slotName,\n );\n return (frag?.children as RootContent[]) ?? [];\n};\n\n/**\n * Prune TabItems whose `_filter` doesn't match `options`. Returns:\n * - `'empty'` if the <Tabs> now has no <TabItem>s — caller drops it.\n * - `'inline'` if exactly one filtered <TabItem> survived — caller\n * inlines the body so agents see just the picked variant.\n * - `'keep'` otherwise.\n */\nconst applyTabsFilter = (\n tabs: MdxJsxFlowElement,\n options: Record<string, string> | undefined,\n): 'empty' | 'inline' | 'keep' => {\n const children = tabs.children as RootContent[];\n const surviving: RootContent[] = [];\n let anyFiltered = false;\n for (const child of children) {\n if (!isJsxElement(child) || child.name !== 'TabItem') {\n surviving.push(child);\n continue;\n }\n const filterEstree = readEstreeAttr(child, '_filter');\n if (!filterEstree) {\n surviving.push(child);\n continue;\n }\n anyFiltered = true;\n let predicate: Predicate;\n try {\n predicate = parseWhenExpression(filterEstree as never);\n } catch {\n stripFilterAttr(child);\n surviving.push(child);\n continue;\n }\n if (!options || evaluatePredicate(predicate, false, options)) {\n stripFilterAttr(child);\n surviving.push(child);\n }\n }\n if (anyFiltered) {\n tabs.children = surviving as MdxJsxFlowElement['children'];\n }\n const tabItems = surviving.filter(\n (c) => isJsxElement(c) && c.name === 'TabItem',\n );\n if (tabItems.length === 0 && surviving.length === 0) return 'empty';\n if (anyFiltered && tabItems.length === 1) return 'inline';\n return 'keep';\n};\n\nconst stripFilterAttr = (el: JsxElement): void => {\n el.attributes = el.attributes.filter(\n (a) => !(a.type === 'mdxJsxAttribute' && a.name === '_filter'),\n );\n};\n\n/**\n * `> [!NOTE] Only when …` blockquote. The alert header goes through as an\n * `html` node so remark-stringify doesn't escape the `[`/`]` brackets —\n * downstream agents match on the literal GitHub alert syntax.\n */\nconst buildNoteQuote = (\n source: JsxElement,\n predicate: Predicate,\n not: boolean,\n): RootContent => {\n const marker = describePredicate(predicate, not);\n const description = readStringAttr(source, 'description');\n const headerLines = description\n ? [`[!NOTE] ${marker}`, description]\n : [`[!NOTE] ${marker}`];\n const headerNodes: RootContent[] = headerLines.map(\n (line) => ({ type: 'html', value: line }) as RootContent,\n );\n return {\n type: 'blockquote',\n children: [...headerNodes, ...(source.children as RootContent[])] as never,\n } as RootContent;\n};\n\nconst parseWhenAttr = (node: JsxElement): Predicate | undefined => {\n const estree = readEstreeAttr(node, 'when');\n if (!estree) return undefined;\n try {\n return parseWhenExpression(estree as never);\n } catch {\n return undefined;\n }\n};\n\nconst applyComponentTransforms = (\n tree: Root,\n opts: PipelineOptions,\n deps: RemarkDeps,\n): void => {\n const pm = opts.packageManager ?? 'pnpm';\n const transform = (parent: JsxParent): void => {\n const children = parent.children as RootContent[];\n for (let i = 0; i < children.length; i++) {\n const child = children[i];\n if (!isJsxElement(child)) continue;\n const replacement = renderComponent(child, opts, pm, deps);\n if (replacement !== undefined) {\n children.splice(i, 1, ...replacement);\n i += replacement.length - 1;\n continue;\n }\n transform(child);\n }\n };\n transform(tree);\n};\n\nconst renderComponent = (\n node: JsxElement,\n opts: PipelineOptions,\n pm: string,\n deps: RemarkDeps,\n): RootContent[] | undefined => {\n switch (node.name) {\n case 'NxCommands': {\n const commands = readCommandsAttr(node);\n if (!commands) return undefined;\n return [\n codeBlock(\n commands\n .map((c) => buildNxCommand(c, opts.packageManager))\n .join('\\n'),\n ),\n ];\n }\n case 'RunGenerator': {\n const generatorId = readStringAttr(node, 'generator');\n if (!generatorId) return undefined;\n const schema = findSchema(opts.generators, generatorId);\n if (!schema) return undefined;\n return parseMarkdownFragment(\n renderGeneratorCommand(generatorId, schema, opts.packageManager),\n deps,\n );\n }\n case 'GeneratorParameters': {\n const generatorId = readStringAttr(node, 'generator');\n if (!generatorId) return undefined;\n const schema = findSchema(opts.generators, generatorId);\n if (!schema) return undefined;\n return parseMarkdownFragment(renderSchema(schema), deps);\n }\n case 'CreateNxWorkspaceCommand': {\n const workspace = readStringAttr(node, 'workspace');\n if (!workspace) return undefined;\n const iac = readStringAttr(node, 'iac') as\n | 'cdk'\n | 'terraform'\n | undefined;\n return [codeBlock(buildCreateNxWorkspaceCommand(pm, workspace, iac))];\n }\n case 'NxInitCommand': {\n return [codeBlock(buildNxInitCommand(pm))];\n }\n case 'InstallCommand': {\n // Without `pkg`, installs the workspace's existing dependencies\n const pkg =\n readStringAttr(node, 'pkg') ?? readExpressionAttr(node, 'pkg');\n return [\n codeBlock(buildInstallCommand(pm, pkg, hasBareAttr(node, 'dev'))),\n ];\n }\n case 'PackageManagerShortCommand': {\n const commands = readCommandsAttr(node);\n if (!commands) return undefined;\n return [\n codeBlock(\n commands\n .map((c) => buildPackageManagerShortCommand(pm, c))\n .join('\\n'),\n ),\n ];\n }\n case 'PackageManagerExecCommand': {\n const commands = readCommandsAttr(node);\n if (!commands) return undefined;\n return [\n codeBlock(\n commands.map((c) => buildPackageManagerExecCommand(pm, c)).join('\\n'),\n ),\n ];\n }\n default:\n return undefined;\n }\n};\n\nconst codeBlock = (body: string): RootContent => ({\n type: 'code',\n lang: 'bash',\n value: body,\n});\n\nconst parseMarkdownFragment = (\n markdown: string,\n deps: RemarkDeps,\n): RootContent[] => {\n const fragTree = deps.unified().use(deps.remarkParse).parse(markdown) as Root;\n return fragTree.children as RootContent[];\n};\n\nconst findSchema = (\n generators: NxGeneratorInfo[],\n generatorId: string,\n):\n | { properties?: Record<string, unknown>; required?: string[] }\n | undefined => {\n const info = generators.find((g) => g.id === generatorId);\n if (!info) return undefined;\n try {\n return JSON.parse(fs.readFileSync(info.resolvedSchemaPath, 'utf-8'));\n } catch {\n return undefined;\n }\n};\n\n/** Parse the `commands={[…]}` attribute from the estree that remark-mdx\n * attaches to the JSX attribute value. */\nconst readCommandsAttr = (node: JsxElement): string[] | undefined => {\n const estree = readEstreeAttr(node, 'commands');\n if (!estree) return undefined;\n try {\n return extractStringArrayExpression(estree as never);\n } catch {\n return undefined;\n }\n};\n"],"names":["fs","buildCreateNxWorkspaceCommand","buildInstallCommand","buildNxInitCommand","buildPackageManagerExecCommand","buildPackageManagerShortCommand","buildNxCommand","renderGeneratorCommand","renderSchema","hasBareAttr","isJsxElement","readEstreeAttr","readExpressionAttr","readStringAttr","describePredicate","evaluatePredicate","extractStringArrayExpression","parseWhenExpression","depsPromise","loadRemarkDeps","unified","remarkParse","default","remarkMdx","remarkStringify","remarkFrontmatter","parseMdxWithDeps","source","deps","use","parse","parseMdx","stringifyMdx","tree","String","bullet","fences","listItemIndent","stringify","stripFrontmatterAndEsm","children","filter","node","type","postProcessGuideWithRemark","guide","opts","inlineSnippets","applyFilterTransforms","options","applyComponentTransforms","provider","snippetContentProvider","pending","walk","parent","i","length","child","name","push","index","fetched","Promise","all","map","p","raw","replacement","undefined","processed","trim","byParent","Map","f","bucket","get","set","items","sort","a","b","snippetTree","wrapper","attributes","value","position","splice","iac","transform","when","parseWhenAttr","not","buildNoteQuote","body","selectInfrastructureSlot","pseudo","dropped","applyTabsFilter","survivor","find","c","slotName","toLowerCase","frag","tabs","surviving","anyFiltered","filterEstree","predicate","stripFilterAttr","tabItems","el","marker","description","headerLines","headerNodes","line","estree","pm","packageManager","renderComponent","commands","readCommandsAttr","codeBlock","join","generatorId","schema","findSchema","generators","parseMarkdownFragment","workspace","pkg","lang","markdown","fragTree","info","g","id","JSON","readFileSync","resolvedSchemaPath"],"mappings":"AAAA;;;CAGC,GAED,OAAOA,QAAQ,KAAK;AAepB,SACEC,6BAA6B,EAC7BC,mBAAmB,EACnBC,kBAAkB,EAClBC,8BAA8B,EAC9BC,+BAA+B,QAC1B,uBAAoB;AAE3B,SACEC,cAAc,EACdC,sBAAsB,EACtBC,YAAY,QACP,oBAAiB;AACxB,SACEC,WAAW,EACXC,YAAY,EAGZC,cAAc,EACdC,kBAAkB,EAClBC,cAAc,QACT,eAAY;AACnB,SACEC,iBAAiB,EACjBC,iBAAiB,EACjBC,4BAA4B,EAE5BC,mBAAmB,QACd,qBAAkB;AAmBzB,IAAIC;AACJ,MAAMC,iBAAiB;IACrB,IAAI,CAACD,aAAa;QAChBA,cAAc,AAAC,CAAA,UAAa,CAAA;gBAC1BE,SAAS,AAAC,CAAA,MAAM,MAAM,CAAC,UAAS,EAAGA,OAAO;gBAC1CC,aAAa,AAAC,CAAA,MAAM,MAAM,CAAC,eAAc,EAAGC,OAAO;gBACnDC,WAAW,AAAC,CAAA,MAAM,MAAM,CAAC,aAAY,EAAGD,OAAO;gBAC/CE,iBAAiB,AAAC,CAAA,MAAM,MAAM,CAAC,mBAAkB,EAAGF,OAAO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AAU,OAAOrD;gBACtB,OAAO;oBACLuD,UACEF,SAASzD,GAAG,CAAC,CAACoC,IAAMjG,+BAA+BmH,IAAIlB,IAAIwB,IAAI,CAAC;iBAEnE;YACH;QACA;YACE,OAAOxD;IACX;AACF;AAEA,MAAMuD,YAAY,CAAC9B,OAA+B,CAAA;QAChDnD,MAAM;QACN0F,MAAM;QACNhD,OAAOS;IACT,CAAA;AAEA,MAAMoC,wBAAwB,CAC5BI,UACA1G;IAEA,MAAM2G,WAAW3G,KAAKR,OAAO,GAAGS,GAAG,CAACD,KAAKP,WAAW,EAAES,KAAK,CAACwG;IAC5D,OAAOC,SAAS/F,QAAQ;AAC1B;AAEA,MAAMwF,aAAa,CACjBC,YACAH;IAIA,MAAMU,OAAOP,WAAW7B,IAAI,CAAC,CAACqC,IAAMA,EAAEC,EAAE,KAAKZ;IAC7C,IAAI,CAACU,MAAM,OAAOnE;IAClB,IAAI;QACF,OAAOsE,KAAK7G,KAAK,CAAC9B,GAAG4I,YAAY,CAACJ,KAAKK,kBAAkB,EAAE;IAC7D,EAAE,OAAM;QACN,OAAOxE;IACT;AACF;AAEA;yCACyC,GACzC,MAAMsD,mBAAmB,CAACjF;IACxB,MAAM4E,SAAS3G,eAAe+B,MAAM;IACpC,IAAI,CAAC4E,QAAQ,OAAOjD;IACpB,IAAI;QACF,OAAOrD,6BAA6BsG;IACtC,EAAE,OAAM;QACN,OAAOjD;IACT;AACF"}
1
+ {"version":3,"sources":["../../../../../packages/nx-plugin/src/mcp-server/guide-pipeline.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport fs from 'fs';\n/**\n * Unified + remark-mdx pipeline for the MCP `generator-guide` tool.\n *\n * Passes (in order, each over the already-transformed tree):\n * 1. Snippet inlining — `<Snippet name>` → recursive post-process.\n * 2. Filter transforms — `<OptionFilter>`, `<Infrastructure>` slot\n * selection, `<Tabs><TabItem _filter>` pruning.\n * 3. Component transforms — `<NxCommands>` / `<RunGenerator>` /\n * `<GeneratorParameters>` / `<CreateNxWorkspaceCommand>` /\n * `<InstallCommand>` / `<PackageManagerShortCommand>` /\n * `<PackageManagerExecCommand>` render down to markdown.\n */\nimport type { Root, RootContent } from 'mdast';\nimport type { MdxJsxFlowElement } from 'mdast-util-mdx-jsx';\nimport {\n buildCreateNxWorkspaceCommand,\n buildInstallCommand,\n buildNxInitCommand,\n buildPackageManagerExecCommand,\n buildPackageManagerShortCommand,\n} from '../utils/commands';\nimport type { NxGeneratorInfo } from '../utils/generators';\nimport {\n buildNxCommand,\n renderGeneratorCommand,\n renderSchema,\n} from './guide-render';\nimport {\n hasBareAttr,\n isJsxElement,\n type JsxElement,\n type JsxParent,\n readEstreeAttr,\n readExpressionAttr,\n readStringAttr,\n} from './mdx-ast';\nimport {\n describePredicate,\n evaluatePredicate,\n extractStringArrayExpression,\n type Predicate,\n parseWhenExpression,\n} from './option-filter';\n\nexport interface PipelineOptions {\n generators: NxGeneratorInfo[];\n packageManager?: string;\n snippetContentProvider?: (name: string) => Promise<string> | string;\n options?: Record<string, string>;\n}\n\n// unified v11 is ESM-only and this package is CJS; dynamic import + rolldown's\n// `codeSplitting: false` bundles everything into the published MCP binary.\ninterface RemarkDeps {\n unified: typeof import('unified').unified;\n remarkParse: typeof import('remark-parse').default;\n remarkMdx: typeof import('remark-mdx').default;\n remarkStringify: typeof import('remark-stringify').default;\n remarkFrontmatter: typeof import('remark-frontmatter').default;\n}\n\nlet depsPromise: Promise<RemarkDeps> | undefined;\nconst loadRemarkDeps = (): Promise<RemarkDeps> => {\n if (!depsPromise) {\n depsPromise = (async () => ({\n unified: (await import('unified')).unified,\n remarkParse: (await import('remark-parse')).default,\n remarkMdx: (await import('remark-mdx')).default,\n remarkStringify: (await import('remark-stringify')).default,\n remarkFrontmatter: (await import('remark-frontmatter')).default,\n }))();\n }\n return depsPromise;\n};\n\nconst parseMdxWithDeps = (source: string, deps: RemarkDeps): Root =>\n deps\n .unified()\n .use(deps.remarkParse)\n .use(deps.remarkFrontmatter)\n .use(deps.remarkMdx)\n .parse(source) as Root;\n\n/** Parse MDX (with frontmatter) into mdast. Exposed so callers like\n * `fetchGuideFrontmatters` don't need to re-load remark themselves. */\nexport const parseMdx = async (source: string): Promise<Root> => {\n const deps = await loadRemarkDeps();\n return parseMdxWithDeps(source, deps);\n};\n\nconst stringifyMdx = (tree: Root, deps: RemarkDeps): string =>\n String(\n deps\n .unified()\n .use(deps.remarkFrontmatter)\n .use(deps.remarkMdx)\n .use(deps.remarkStringify, {\n bullet: '-',\n fences: true,\n listItemIndent: 'one',\n })\n .stringify(tree),\n );\n\n/**\n * Remove nodes that are meaningless once the MDX is rendered to plain markdown\n * for an agent: the YAML frontmatter block and the `import`/`export` (ESM)\n * statements at the top of every docs page. They add noise and tokens without\n * conveying guidance.\n */\nconst stripFrontmatterAndEsm = (tree: Root): void => {\n tree.children = tree.children.filter(\n (node) => node.type !== 'yaml' && node.type !== 'mdxjsEsm',\n );\n};\n\nexport const postProcessGuideWithRemark = async (\n guide: string,\n opts: PipelineOptions,\n): Promise<string> => {\n const deps = await loadRemarkDeps();\n const tree = parseMdxWithDeps(guide, deps);\n\n await inlineSnippets(tree, opts, deps);\n applyFilterTransforms(tree, opts.options);\n applyComponentTransforms(tree, opts, deps);\n stripFrontmatterAndEsm(tree);\n\n return stringifyMdx(tree, deps);\n};\n\nconst inlineSnippets = async (\n tree: Root,\n opts: PipelineOptions,\n deps: RemarkDeps,\n): Promise<void> => {\n const provider = opts.snippetContentProvider;\n if (!provider) return;\n\n interface PendingSnippet {\n parent: JsxParent;\n index: number;\n name: string;\n node: JsxElement;\n }\n\n const pending: PendingSnippet[] = [];\n const walk = (parent: JsxParent): void => {\n const children = parent.children as RootContent[];\n for (let i = 0; i < children.length; i++) {\n const child = children[i];\n if (!isJsxElement(child)) continue;\n if (child.name === 'Snippet') {\n const name = readStringAttr(child, 'name');\n if (name) pending.push({ parent, index: i, name, node: child });\n continue;\n }\n walk(child);\n }\n };\n walk(tree);\n if (pending.length === 0) return;\n\n const fetched = await Promise.all(\n pending.map(async (p) => {\n let raw = '';\n try {\n raw = await provider(p.name);\n } catch {\n raw = '';\n }\n if (!raw) return { ...p, replacement: undefined };\n const processed = await postProcessGuideWithRemark(raw.trim(), opts);\n return { ...p, replacement: processed };\n }),\n );\n\n // Splice in descending index order per parent so earlier indices stay valid.\n const byParent = new Map<JsxParent, (typeof fetched)[number][]>();\n for (const f of fetched) {\n const bucket = byParent.get(f.parent) ?? [];\n bucket.push(f);\n byParent.set(f.parent, bucket);\n }\n for (const [parent, items] of byParent) {\n items.sort((a, b) => b.index - a.index);\n for (const { index, name, replacement, node } of items) {\n if (replacement === undefined) continue;\n const snippetTree = parseMdxWithDeps(replacement, deps);\n const wrapper: MdxJsxFlowElement = {\n type: 'mdxJsxFlowElement',\n name: 'Snippet',\n attributes: [{ type: 'mdxJsxAttribute', name: 'name', value: name }],\n children: snippetTree.children as MdxJsxFlowElement['children'],\n };\n if ('position' in node && node.position) {\n (wrapper as { position?: unknown }).position = node.position;\n }\n (parent.children as RootContent[]).splice(\n index,\n 1,\n wrapper as RootContent,\n );\n }\n }\n};\n\nconst applyFilterTransforms = (\n tree: Root,\n options: Record<string, string> | undefined,\n): void => {\n const iac = options?.iac;\n\n const transform = (parent: JsxParent): void => {\n const children = parent.children as RootContent[];\n for (let i = 0; i < children.length; i++) {\n const child = children[i];\n if (!isJsxElement(child)) continue;\n\n if (child.name === 'OptionFilter') {\n const when = parseWhenAttr(child);\n if (!when) continue; // malformed — leave alone\n // Recurse first so nested filters collapse before we replace this wrapper.\n transform(child);\n const not = hasBareAttr(child, 'not');\n if (options) {\n const replacement = evaluatePredicate(when, not, options)\n ? (child.children as RootContent[])\n : [];\n children.splice(i, 1, ...replacement);\n i += replacement.length - 1;\n } else {\n children.splice(i, 1, buildNoteQuote(child, when, not));\n }\n continue;\n }\n\n if (child.name === 'Infrastructure') {\n if (iac === 'cdk' || iac === 'terraform') {\n const body = selectInfrastructureSlot(child, iac);\n const pseudo: MdxJsxFlowElement = {\n type: 'mdxJsxFlowElement',\n name: 'tmp',\n attributes: [],\n children: body as MdxJsxFlowElement['children'],\n };\n transform(pseudo);\n children.splice(i, 1, ...(pseudo.children as RootContent[]));\n i--;\n continue;\n }\n // No iac → keep both slots so readers / agents see both variants.\n transform(child);\n continue;\n }\n\n if (child.name === 'Tabs' && child.type === 'mdxJsxFlowElement') {\n transform(child);\n const dropped = applyTabsFilter(child, options);\n if (dropped === 'empty') {\n children.splice(i, 1);\n i--;\n continue;\n }\n if (dropped === 'inline') {\n const survivor = (child.children as RootContent[]).find(\n (c): c is MdxJsxFlowElement =>\n isJsxElement(c) && c.name === 'TabItem',\n )!;\n const body = survivor.children as RootContent[];\n children.splice(i, 1, ...body);\n i += body.length - 1;\n continue;\n }\n continue;\n }\n\n transform(child);\n }\n };\n transform(tree);\n};\n\nconst selectInfrastructureSlot = (\n node: JsxElement,\n iac: 'cdk' | 'terraform',\n): RootContent[] => {\n const slotName = iac.toLowerCase();\n const frag = (node.children as RootContent[]).find(\n (c): c is MdxJsxFlowElement =>\n isJsxElement(c) &&\n c.name === 'Fragment' &&\n readStringAttr(c, 'slot') === slotName,\n );\n return (frag?.children as RootContent[]) ?? [];\n};\n\n/**\n * Prune TabItems whose `_filter` doesn't match `options`. Returns:\n * - `'empty'` if the <Tabs> now has no <TabItem>s — caller drops it.\n * - `'inline'` if exactly one filtered <TabItem> survived — caller\n * inlines the body so agents see just the picked variant.\n * - `'keep'` otherwise.\n */\nconst applyTabsFilter = (\n tabs: MdxJsxFlowElement,\n options: Record<string, string> | undefined,\n): 'empty' | 'inline' | 'keep' => {\n const children = tabs.children as RootContent[];\n const surviving: RootContent[] = [];\n let anyFiltered = false;\n for (const child of children) {\n if (!isJsxElement(child) || child.name !== 'TabItem') {\n surviving.push(child);\n continue;\n }\n const filterEstree = readEstreeAttr(child, '_filter');\n if (!filterEstree) {\n surviving.push(child);\n continue;\n }\n anyFiltered = true;\n let predicate: Predicate;\n try {\n predicate = parseWhenExpression(filterEstree as never);\n } catch {\n stripFilterAttr(child);\n surviving.push(child);\n continue;\n }\n if (!options || evaluatePredicate(predicate, false, options)) {\n stripFilterAttr(child);\n surviving.push(child);\n }\n }\n if (anyFiltered) {\n tabs.children = surviving as MdxJsxFlowElement['children'];\n }\n const tabItems = surviving.filter(\n (c) => isJsxElement(c) && c.name === 'TabItem',\n );\n if (tabItems.length === 0 && surviving.length === 0) return 'empty';\n if (anyFiltered && tabItems.length === 1) return 'inline';\n return 'keep';\n};\n\nconst stripFilterAttr = (el: JsxElement): void => {\n el.attributes = el.attributes.filter(\n (a) => !(a.type === 'mdxJsxAttribute' && a.name === '_filter'),\n );\n};\n\n/**\n * `> [!NOTE] Only when …` blockquote. The alert header goes through as an\n * `html` node so remark-stringify doesn't escape the `[`/`]` brackets —\n * downstream agents match on the literal GitHub alert syntax.\n */\nconst buildNoteQuote = (\n source: JsxElement,\n predicate: Predicate,\n not: boolean,\n): RootContent => {\n const marker = describePredicate(predicate, not);\n const description = readStringAttr(source, 'description');\n const headerLines = description\n ? [`[!NOTE] ${marker}`, description]\n : [`[!NOTE] ${marker}`];\n const headerNodes: RootContent[] = headerLines.map(\n (line) => ({ type: 'html', value: line }) as RootContent,\n );\n return {\n type: 'blockquote',\n children: [...headerNodes, ...(source.children as RootContent[])] as never,\n } as RootContent;\n};\n\nconst parseWhenAttr = (node: JsxElement): Predicate | undefined => {\n const estree = readEstreeAttr(node, 'when');\n if (!estree) return undefined;\n try {\n return parseWhenExpression(estree as never);\n } catch {\n return undefined;\n }\n};\n\nconst applyComponentTransforms = (\n tree: Root,\n opts: PipelineOptions,\n deps: RemarkDeps,\n): void => {\n const pm = opts.packageManager ?? 'pnpm';\n const transform = (parent: JsxParent): void => {\n const children = parent.children as RootContent[];\n for (let i = 0; i < children.length; i++) {\n const child = children[i];\n if (!isJsxElement(child)) continue;\n const replacement = renderComponent(child, opts, pm, deps);\n if (replacement !== undefined) {\n children.splice(i, 1, ...replacement);\n i += replacement.length - 1;\n continue;\n }\n transform(child);\n }\n };\n transform(tree);\n};\n\nconst renderComponent = (\n node: JsxElement,\n opts: PipelineOptions,\n pm: string,\n deps: RemarkDeps,\n): RootContent[] | undefined => {\n switch (node.name) {\n case 'NxCommands': {\n const commands = readCommandsAttr(node);\n if (!commands) return undefined;\n return [\n codeBlock(\n commands\n .map((c) => buildNxCommand(c, opts.packageManager))\n .join('\\n'),\n ),\n ];\n }\n case 'RunGenerator': {\n const generatorId = readStringAttr(node, 'generator');\n if (!generatorId) return undefined;\n const schema = findSchema(opts.generators, generatorId);\n if (!schema) return undefined;\n return parseMarkdownFragment(\n renderGeneratorCommand(generatorId, schema, opts.packageManager),\n deps,\n );\n }\n case 'GeneratorParameters': {\n const generatorId = readStringAttr(node, 'generator');\n if (!generatorId) return undefined;\n const schema = findSchema(opts.generators, generatorId);\n if (!schema) return undefined;\n return parseMarkdownFragment(renderSchema(schema), deps);\n }\n case 'CreateNxWorkspaceCommand': {\n const workspace = readStringAttr(node, 'workspace');\n if (!workspace) return undefined;\n const iac = readStringAttr(node, 'iac') as\n | 'cdk'\n | 'terraform'\n | undefined;\n return [codeBlock(buildCreateNxWorkspaceCommand(pm, workspace, iac))];\n }\n case 'NxInitCommand': {\n return [codeBlock(buildNxInitCommand(pm))];\n }\n case 'InstallCommand': {\n // Without `pkg`, installs the workspace's existing dependencies\n const pkg =\n readStringAttr(node, 'pkg') ?? readExpressionAttr(node, 'pkg');\n return [\n codeBlock(buildInstallCommand(pm, pkg, hasBareAttr(node, 'dev'))),\n ];\n }\n case 'PackageManagerShortCommand': {\n const commands = readCommandsAttr(node);\n if (!commands) return undefined;\n return [\n codeBlock(\n commands\n .map((c) => buildPackageManagerShortCommand(pm, c))\n .join('\\n'),\n ),\n ];\n }\n case 'PackageManagerExecCommand': {\n const commands = readCommandsAttr(node);\n if (!commands) return undefined;\n return [\n codeBlock(\n commands.map((c) => buildPackageManagerExecCommand(pm, c)).join('\\n'),\n ),\n ];\n }\n default:\n return undefined;\n }\n};\n\nconst codeBlock = (body: string): RootContent => ({\n type: 'code',\n lang: 'bash',\n value: body,\n});\n\nconst parseMarkdownFragment = (\n markdown: string,\n deps: RemarkDeps,\n): RootContent[] => {\n const fragTree = deps.unified().use(deps.remarkParse).parse(markdown) as Root;\n return fragTree.children as RootContent[];\n};\n\nconst findSchema = (\n generators: NxGeneratorInfo[],\n generatorId: string,\n):\n | { properties?: Record<string, unknown>; required?: string[] }\n | undefined => {\n const info = generators.find((g) => g.id === generatorId);\n if (!info) return undefined;\n try {\n return JSON.parse(fs.readFileSync(info.resolvedSchemaPath, 'utf-8'));\n } catch {\n return undefined;\n }\n};\n\n/** Parse the `commands={[…]}` attribute from the estree that remark-mdx\n * attaches to the JSX attribute value. */\nconst readCommandsAttr = (node: JsxElement): string[] | undefined => {\n const estree = readEstreeAttr(node, 'commands');\n if (!estree) return undefined;\n try {\n return extractStringArrayExpression(estree as never);\n } catch {\n return undefined;\n }\n};\n"],"names":["fs","buildCreateNxWorkspaceCommand","buildInstallCommand","buildNxInitCommand","buildPackageManagerExecCommand","buildPackageManagerShortCommand","buildNxCommand","renderGeneratorCommand","renderSchema","hasBareAttr","isJsxElement","readEstreeAttr","readExpressionAttr","readStringAttr","describePredicate","evaluatePredicate","extractStringArrayExpression","parseWhenExpression","depsPromise","loadRemarkDeps","unified","remarkParse","default","remarkMdx","remarkStringify","remarkFrontmatter","parseMdxWithDeps","source","deps","use","parse","parseMdx","stringifyMdx","tree","String","bullet","fences","listItemIndent","stringify","stripFrontmatterAndEsm","children","filter","node","type","postProcessGuideWithRemark","guide","opts","inlineSnippets","applyFilterTransforms","options","applyComponentTransforms","provider","snippetContentProvider","pending","walk","parent","i","length","child","name","push","index","fetched","Promise","all","map","p","raw","replacement","undefined","processed","trim","byParent","Map","f","bucket","get","set","items","sort","a","b","snippetTree","wrapper","attributes","value","position","splice","iac","transform","when","parseWhenAttr","not","buildNoteQuote","body","selectInfrastructureSlot","pseudo","dropped","applyTabsFilter","survivor","find","c","slotName","toLowerCase","frag","tabs","surviving","anyFiltered","filterEstree","predicate","stripFilterAttr","tabItems","el","marker","description","headerLines","headerNodes","line","estree","pm","packageManager","renderComponent","commands","readCommandsAttr","codeBlock","join","generatorId","schema","findSchema","generators","parseMarkdownFragment","workspace","pkg","lang","markdown","fragTree","info","g","id","JSON","readFileSync","resolvedSchemaPath"],"mappings":"AAAA;;;CAGC,GAED,OAAOA,QAAQ,KAAK;AAepB,SACEC,6BAA6B,EAC7BC,mBAAmB,EACnBC,kBAAkB,EAClBC,8BAA8B,EAC9BC,+BAA+B,QAC1B,uBAAoB;AAE3B,SACEC,cAAc,EACdC,sBAAsB,EACtBC,YAAY,QACP,oBAAiB;AACxB,SACEC,WAAW,EACXC,YAAY,EAGZC,cAAc,EACdC,kBAAkB,EAClBC,cAAc,QACT,eAAY;AACnB,SACEC,iBAAiB,EACjBC,iBAAiB,EACjBC,4BAA4B,EAE5BC,mBAAmB,QACd,qBAAkB;AAmBzB,IAAIC;AACJ,MAAMC,iBAAiB;IACrB,IAAI,CAACD,aAAa;QAChBA,cAAc,AAAC,CAAA,UAAa,CAAA;gBAC1BE,SAAS,AAAC,CAAA,MAAM,MAAM,CAAC,UAAS,EAAGA,OAAO;gBAC1CC,aAAa,AAAC,CAAA,MAAM,MAAM,CAAC,eAAc,EAAGC,OAAO;gBACnDC,WAAW,AAAC,CAAA,MAAM,MAAM,CAAC,aAAY,EAAGD,OAAO;gBAC/CE,iBAAiB,AAAC,CAAA,MAAM,MAAM,CAAC,mBAAkB,EAAGF,OAAO;gBAC3DG,mBAAmB,AAAC,CAAA,MAAM,MAAM,CAAC,qBAAoB,EAAGH,OAAO;YACjE,CAAA,CAAC;IACH;IACA,OAAOJ;AACT;AAEA,MAAMQ,mBAAmB,CAACC,QAAgBC,OACxCA,KACGR,OAAO,GACPS,GAAG,CAACD,KAAKP,WAAW,EACpBQ,GAAG,CAACD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,MAAM;QACNhD,OAAOS;IACT,CAAA;AAEA,MAAMoC,wBAAwB,CAC5BI,UACA1G;IAEA,MAAM2G,WAAW3G,KAAKR,OAAO,GAAGS,GAAG,CAACD,KAAKP,WAAW,EAAES,KAAK,CAACwG;IAC5D,OAAOC,SAAS/F,QAAQ;AAC1B;AAEA,MAAMwF,aAAa,CACjBC,YACAH;IAIA,MAAMU,OAAOP,WAAW7B,IAAI,CAAC,CAACqC,IAAMA,EAAEC,EAAE,KAAKZ;IAC7C,IAAI,CAACU,MAAM,OAAOnE;IAClB,IAAI;QACF,OAAOsE,KAAK7G,KAAK,CAAC9B,GAAG4I,YAAY,CAACJ,KAAKK,kBAAkB,EAAE;IAC7D,EAAE,OAAM;QACN,OAAOxE;IACT;AACF;AAEA;yCACyC,GACzC,MAAMsD,mBAAmB,CAACjF;IACxB,MAAM4E,SAAS3G,eAAe+B,MAAM;IACpC,IAAI,CAAC4E,QAAQ,OAAOjD;IACpB,IAAI;QACF,OAAOrD,6BAA6BsG;IACtC,EAAE,OAAM;QACN,OAAOjD;IACT;AACF"}
@@ -0,0 +1,3 @@
1
+ {
2
+ "description": "Replace the deprecated inlineDynamicImports rolldown output option with codeSplitting"
3
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ import { type MigrationReturnObject, type Tree } from '@nx/devkit';
6
+ export default function migration(tree: Tree): Promise<MigrationReturnObject>;
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */ import { getProjects, joinPathFragments } from "@nx/devkit";
5
+ import { applyGritQL } from "../../../utils/ast.js";
6
+ import { formatFilesInSubtree } from "../../../utils/format.js";
7
+ /**
8
+ * Move generated rolldown configs onto `codeSplitting: false`.
9
+ *
10
+ * rolldown deprecated the `inlineDynamicImports` output option in favour of
11
+ * `codeSplitting`, and warns once per bundle entry — so a workspace with several
12
+ * bundled projects printed the warning many times over on every build. Both
13
+ * spellings ask for the same thing: the whole bundle in a single file, which is
14
+ * what the vended Lambda and container bundles need.
15
+ *
16
+ * Guardrails:
17
+ * - Both patterns are anchored to a rolldown `output` object and scoped with
18
+ * `some` to its direct properties, so an object of the user's own that happens
19
+ * to carry the same key is left alone. `inlineDynamicImports: false` is also
20
+ * left alone: it means the opposite, so a user who set it deliberately keeps it.
21
+ * - Where an output already carries `codeSplitting`, the deprecated option is
22
+ * dropped rather than renamed, so the rewrite can't produce a duplicate key.
23
+ * - Idempotent: neither pattern matches once the option is gone.
24
+ */ /**
25
+ * Rename the deprecated option, where the output does not already set
26
+ * `codeSplitting`.
27
+ */ const RENAME_PATTERN = `\`output: { $props }\` where {
28
+ $props <: some \`inlineDynamicImports: true\` as $deprecated,
29
+ $props <: not some \`codeSplitting: $_\`,
30
+ $deprecated => \`codeSplitting: false\`
31
+ }`;
32
+ /**
33
+ * Drop the deprecated option where `codeSplitting` is already set — renaming it
34
+ * would leave the output with the key twice.
35
+ */ const DROP_PATTERN = `\`output: { $props }\` where {
36
+ $props <: some \`codeSplitting: $_\`,
37
+ $props <: some \`inlineDynamicImports: true\` as $deprecated,
38
+ $deprecated => .
39
+ }`;
40
+ export default async function migration(tree) {
41
+ for (const project of getProjects(tree).values()){
42
+ const configPath = joinPathFragments(project.root, 'rolldown.config.ts');
43
+ if (!tree.exists(configPath)) {
44
+ continue;
45
+ }
46
+ for (const pattern of [
47
+ RENAME_PATTERN,
48
+ DROP_PATTERN
49
+ ]){
50
+ await applyGritQL(tree, configPath, pattern);
51
+ }
52
+ }
53
+ await formatFilesInSubtree(tree);
54
+ return {};
55
+ }
56
+
57
+ //# sourceMappingURL=migration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../packages/nx-plugin/src/migrations/latest/rolldown-code-splitting/migration.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n getProjects,\n joinPathFragments,\n type MigrationReturnObject,\n type Tree,\n} from '@nx/devkit';\nimport { applyGritQL } from '../../../utils/ast';\nimport { formatFilesInSubtree } from '../../../utils/format';\n\n/**\n * Move generated rolldown configs onto `codeSplitting: false`.\n *\n * rolldown deprecated the `inlineDynamicImports` output option in favour of\n * `codeSplitting`, and warns once per bundle entry — so a workspace with several\n * bundled projects printed the warning many times over on every build. Both\n * spellings ask for the same thing: the whole bundle in a single file, which is\n * what the vended Lambda and container bundles need.\n *\n * Guardrails:\n * - Both patterns are anchored to a rolldown `output` object and scoped with\n * `some` to its direct properties, so an object of the user's own that happens\n * to carry the same key is left alone. `inlineDynamicImports: false` is also\n * left alone: it means the opposite, so a user who set it deliberately keeps it.\n * - Where an output already carries `codeSplitting`, the deprecated option is\n * dropped rather than renamed, so the rewrite can't produce a duplicate key.\n * - Idempotent: neither pattern matches once the option is gone.\n */\n\n/**\n * Rename the deprecated option, where the output does not already set\n * `codeSplitting`.\n */\nconst RENAME_PATTERN = `\\`output: { $props }\\` where {\n $props <: some \\`inlineDynamicImports: true\\` as $deprecated,\n $props <: not some \\`codeSplitting: $_\\`,\n $deprecated => \\`codeSplitting: false\\`\n}`;\n\n/**\n * Drop the deprecated option where `codeSplitting` is already set — renaming it\n * would leave the output with the key twice.\n */\nconst DROP_PATTERN = `\\`output: { $props }\\` where {\n $props <: some \\`codeSplitting: $_\\`,\n $props <: some \\`inlineDynamicImports: true\\` as $deprecated,\n $deprecated => .\n}`;\n\nexport default async function migration(\n tree: Tree,\n): Promise<MigrationReturnObject> {\n for (const project of getProjects(tree).values()) {\n const configPath = joinPathFragments(project.root, 'rolldown.config.ts');\n if (!tree.exists(configPath)) {\n continue;\n }\n for (const pattern of [RENAME_PATTERN, DROP_PATTERN]) {\n await applyGritQL(tree, configPath, pattern);\n }\n }\n\n await formatFilesInSubtree(tree);\n\n return {};\n}\n"],"names":["getProjects","joinPathFragments","applyGritQL","formatFilesInSubtree","RENAME_PATTERN","DROP_PATTERN","migration","tree","project","values","configPath","root","exists","pattern"],"mappings":"AAAA;;;CAGC,GACD,SACEA,WAAW,EACXC,iBAAiB,QAGZ,aAAa;AACpB,SAASC,WAAW,QAAQ,wBAAqB;AACjD,SAASC,oBAAoB,QAAQ,2BAAwB;AAE7D;;;;;;;;;;;;;;;;;CAiBC,GAED;;;CAGC,GACD,MAAMC,iBAAiB,CAAC;;;;CAIvB,CAAC;AAEF;;;CAGC,GACD,MAAMC,eAAe,CAAC;;;;CAIrB,CAAC;AAEF,eAAe,eAAeC,UAC5BC,IAAU;IAEV,KAAK,MAAMC,WAAWR,YAAYO,MAAME,MAAM,GAAI;QAChD,MAAMC,aAAaT,kBAAkBO,QAAQG,IAAI,EAAE;QACnD,IAAI,CAACJ,KAAKK,MAAM,CAACF,aAAa;YAC5B;QACF;QACA,KAAK,MAAMG,WAAW;YAACT;YAAgBC;SAAa,CAAE;YACpD,MAAMH,YAAYK,MAAMG,YAAYG;QACtC;IACF;IAEA,MAAMV,qBAAqBI;IAE3B,OAAO,CAAC;AACV"}
@@ -0,0 +1,3 @@
1
+ {
2
+ "description": "Resolve vite and vitest config paths from import.meta.dirname rather than __dirname"
3
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ import { type MigrationReturnObject, type Tree } from '@nx/devkit';
6
+ export default function migration(tree: Tree): Promise<MigrationReturnObject>;
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */ import { getProjects, joinPathFragments } from "@nx/devkit";
5
+ import { applyGritQL } from "../../../utils/ast.js";
6
+ import { formatFilesInSubtree } from "../../../utils/format.js";
7
+ /**
8
+ * Resolve the vended vite and vitest config paths from `import.meta.dirname`
9
+ * rather than `__dirname`.
10
+ *
11
+ * `__dirname` is unavailable to Vite's native config loader, so every generated
12
+ * TypeScript project's config warned that it "uses features that are unsupported
13
+ * by `configLoader: 'native'`". That loader is slated to become the default, at
14
+ * which point the config breaks rather than warns.
15
+ *
16
+ * Two shapes are rewritten: the `root` that `@nx/js` writes into every project's
17
+ * config, and the two paths `ts#react-website` passes to the TanStack Router
18
+ * plugin.
19
+ *
20
+ * Guardrails:
21
+ * - Every pattern is anchored to the exact shape the generators produce, and
22
+ * scoped with `some` so it only matches a direct property of the object it
23
+ * names. A `root` nested inside another option, or a `resolve(__dirname, ...)`
24
+ * the user wrote anywhere else in the config, is left alone.
25
+ * - The router paths are matched by option name *and* path literal, so a user who
26
+ * pointed one somewhere else keeps their value.
27
+ * - Idempotent: no pattern matches once rewritten.
28
+ */ /**
29
+ * The `root` of the object the config factory returns. `some` matches a direct
30
+ * property only, so a nested `root` (a `test.alias` entry, say) is not touched.
31
+ */ const ROOT_PATTERN = `\`defineConfig(() => ({ $props }))\` where {
32
+ $props <: some \`root: __dirname\` as $root,
33
+ $root => \`root: import.meta.dirname\`
34
+ }`;
35
+ /**
36
+ * One of the TanStack Router plugin's path options, matched by name and by the
37
+ * path the generator passes — so a user who repointed it keeps their value.
38
+ * Scoped to the plugin's own option object rather than the file, so a
39
+ * `resolve(__dirname, ...)` elsewhere in the config is left alone.
40
+ */ const routerPathPattern = (option, path)=>`\`tanstackRouter({ $opts })\` where {
41
+ $opts <: some \`${option}: resolve(__dirname, '${path}')\` as $path,
42
+ $path => \`${option}: resolve(import.meta.dirname, '${path}')\`
43
+ }`;
44
+ /** The paths `ts#react-website` gives the TanStack Router plugin. */ const ROUTER_PATTERNS = [
45
+ routerPathPattern('routesDirectory', 'src/routes'),
46
+ routerPathPattern('generatedRouteTree', 'src/routeTree.gen.ts')
47
+ ];
48
+ /** The config filenames a generated project may carry. */ const CONFIG_FILES = [
49
+ 'vitest.config.mts',
50
+ 'vite.config.mts'
51
+ ];
52
+ export default async function migration(tree) {
53
+ for (const project of getProjects(tree).values()){
54
+ for (const configFile of CONFIG_FILES){
55
+ const configPath = joinPathFragments(project.root, configFile);
56
+ if (!tree.exists(configPath)) {
57
+ continue;
58
+ }
59
+ for (const pattern of [
60
+ ROOT_PATTERN,
61
+ ...ROUTER_PATTERNS
62
+ ]){
63
+ await applyGritQL(tree, configPath, pattern);
64
+ }
65
+ }
66
+ }
67
+ await formatFilesInSubtree(tree);
68
+ return {};
69
+ }
70
+
71
+ //# sourceMappingURL=migration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../packages/nx-plugin/src/migrations/latest/vite-config-import-meta-dirname/migration.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n getProjects,\n joinPathFragments,\n type MigrationReturnObject,\n type Tree,\n} from '@nx/devkit';\nimport { applyGritQL } from '../../../utils/ast';\nimport { formatFilesInSubtree } from '../../../utils/format';\n\n/**\n * Resolve the vended vite and vitest config paths from `import.meta.dirname`\n * rather than `__dirname`.\n *\n * `__dirname` is unavailable to Vite's native config loader, so every generated\n * TypeScript project's config warned that it \"uses features that are unsupported\n * by `configLoader: 'native'`\". That loader is slated to become the default, at\n * which point the config breaks rather than warns.\n *\n * Two shapes are rewritten: the `root` that `@nx/js` writes into every project's\n * config, and the two paths `ts#react-website` passes to the TanStack Router\n * plugin.\n *\n * Guardrails:\n * - Every pattern is anchored to the exact shape the generators produce, and\n * scoped with `some` so it only matches a direct property of the object it\n * names. A `root` nested inside another option, or a `resolve(__dirname, ...)`\n * the user wrote anywhere else in the config, is left alone.\n * - The router paths are matched by option name *and* path literal, so a user who\n * pointed one somewhere else keeps their value.\n * - Idempotent: no pattern matches once rewritten.\n */\n\n/**\n * The `root` of the object the config factory returns. `some` matches a direct\n * property only, so a nested `root` (a `test.alias` entry, say) is not touched.\n */\nconst ROOT_PATTERN = `\\`defineConfig(() => ({ $props }))\\` where {\n $props <: some \\`root: __dirname\\` as $root,\n $root => \\`root: import.meta.dirname\\`\n}`;\n\n/**\n * One of the TanStack Router plugin's path options, matched by name and by the\n * path the generator passes — so a user who repointed it keeps their value.\n * Scoped to the plugin's own option object rather than the file, so a\n * `resolve(__dirname, ...)` elsewhere in the config is left alone.\n */\nconst routerPathPattern = (option: string, path: string): string =>\n `\\`tanstackRouter({ $opts })\\` where {\n $opts <: some \\`${option}: resolve(__dirname, '${path}')\\` as $path,\n $path => \\`${option}: resolve(import.meta.dirname, '${path}')\\`\n }`;\n\n/** The paths `ts#react-website` gives the TanStack Router plugin. */\nconst ROUTER_PATTERNS = [\n routerPathPattern('routesDirectory', 'src/routes'),\n routerPathPattern('generatedRouteTree', 'src/routeTree.gen.ts'),\n];\n\n/** The config filenames a generated project may carry. */\nconst CONFIG_FILES = ['vitest.config.mts', 'vite.config.mts'];\n\nexport default async function migration(\n tree: Tree,\n): Promise<MigrationReturnObject> {\n for (const project of getProjects(tree).values()) {\n for (const configFile of CONFIG_FILES) {\n const configPath = joinPathFragments(project.root, configFile);\n if (!tree.exists(configPath)) {\n continue;\n }\n for (const pattern of [ROOT_PATTERN, ...ROUTER_PATTERNS]) {\n await applyGritQL(tree, configPath, pattern);\n }\n }\n }\n\n await formatFilesInSubtree(tree);\n\n return {};\n}\n"],"names":["getProjects","joinPathFragments","applyGritQL","formatFilesInSubtree","ROOT_PATTERN","routerPathPattern","option","path","ROUTER_PATTERNS","CONFIG_FILES","migration","tree","project","values","configFile","configPath","root","exists","pattern"],"mappings":"AAAA;;;CAGC,GACD,SACEA,WAAW,EACXC,iBAAiB,QAGZ,aAAa;AACpB,SAASC,WAAW,QAAQ,wBAAqB;AACjD,SAASC,oBAAoB,QAAQ,2BAAwB;AAE7D;;;;;;;;;;;;;;;;;;;;;CAqBC,GAED;;;CAGC,GACD,MAAMC,eAAe,CAAC;;;CAGrB,CAAC;AAEF;;;;;CAKC,GACD,MAAMC,oBAAoB,CAACC,QAAgBC,OACzC,CAAC;qBACkB,EAAED,OAAO,sBAAsB,EAAEC,KAAK;gBAC3C,EAAED,OAAO,gCAAgC,EAAEC,KAAK;IAC5D,CAAC;AAEL,mEAAmE,GACnE,MAAMC,kBAAkB;IACtBH,kBAAkB,mBAAmB;IACrCA,kBAAkB,sBAAsB;CACzC;AAED,wDAAwD,GACxD,MAAMI,eAAe;IAAC;IAAqB;CAAkB;AAE7D,eAAe,eAAeC,UAC5BC,IAAU;IAEV,KAAK,MAAMC,WAAWZ,YAAYW,MAAME,MAAM,GAAI;QAChD,KAAK,MAAMC,cAAcL,aAAc;YACrC,MAAMM,aAAad,kBAAkBW,QAAQI,IAAI,EAAEF;YACnD,IAAI,CAACH,KAAKM,MAAM,CAACF,aAAa;gBAC5B;YACF;YACA,KAAK,MAAMG,WAAW;gBAACd;mBAAiBI;aAAgB,CAAE;gBACxD,MAAMN,YAAYS,MAAMI,YAAYG;YACtC;QACF;IACF;IAEA,MAAMf,qBAAqBQ;IAE3B,OAAO,CAAC;AACV"}
@@ -947,7 +947,7 @@ from sqlalchemy.ext.asyncio import create_async_engine
947
947
  from sqlmodel import SQLModel
948
948
 
949
949
  # Import all models to register them in SQLModel.metadata
950
- from proj_db.models import * # noqa: F401, F403
950
+ from proj_db.models import * # noqa: F403
951
951
 
952
952
  config = context.config
953
953
 
@@ -9,7 +9,7 @@ from sqlalchemy.ext.asyncio import create_async_engine
9
9
  from sqlmodel import SQLModel
10
10
 
11
11
  # Import all models to register them in SQLModel.metadata
12
- from <%= name %>.models import * # noqa: F401, F403
12
+ from <%= name %>.models import * # noqa: F403
13
13
 
14
14
  config = context.config
15
15
 
@@ -4,7 +4,7 @@ exports[`vitest utils > should generate a valid vitest.config.mts without a doub
4
4
  "import { defineConfig } from 'vitest/config';
5
5
 
6
6
  export default defineConfig(() => ({
7
- root: __dirname,
7
+ root: import.meta.dirname,
8
8
  cacheDir: '../node_modules/.vite/test',
9
9
  test: {
10
10
  passWithNoTests: true,
@@ -9,6 +9,17 @@ import { forDependencies } from "../../utils/declared-dependencies.js";
9
9
  import { addDependenciesToPackageJson } from "../../utils/dependencies.js";
10
10
  import { withVersions } from "../../utils/versions.js";
11
11
  const readGritPattern = (name)=>readFileSync(join(import.meta.dirname, 'grit', `${name}.grit`), 'utf-8').trim();
12
+ /**
13
+ * Resolve the config's `root` from `import.meta.dirname`.
14
+ *
15
+ * `@nx/js` writes `root: __dirname`, which Vite's native config loader does not
16
+ * provide — it warns today and will reject once `configLoader: 'native'` becomes
17
+ * the default. Scoped with `some` to a direct property of the object the config
18
+ * factory returns, so a nested `root` (a `test.alias` entry, say) is untouched.
19
+ */ const ROOT_IMPORT_META_DIRNAME = `\`defineConfig(() => ({ $props }))\` where {
20
+ $props <: some \`root: __dirname\` as $root,
21
+ $root => \`root: import.meta.dirname\`
22
+ }`;
12
23
  /** Dependencies a caller must declare to configure vitest. */ export const VITEST_DEPENDENCIES = [
13
24
  {
14
25
  name: 'vite'
@@ -28,6 +39,7 @@ export const configureVitest = async (tree, options, declaration)=>{
28
39
  ].find((config)=>tree.exists(config));
29
40
  if (configPath) {
30
41
  await applyGritQL(tree, configPath, readGritPattern('vitest-pass-with-no-tests'));
42
+ await applyGritQL(tree, configPath, ROOT_IMPORT_META_DIRNAME);
31
43
  const nxJson = readNxJson(tree);
32
44
  updateNxJson(tree, {
33
45
  ...nxJson,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/lib/vitest.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { readNxJson, type Tree, updateNxJson } from '@nx/devkit';\nimport { readFileSync } from 'fs';\nimport { join } from 'path';\nimport { applyGritQL } from '../../utils/ast';\nimport {\n type DependencyDeclaration,\n forDependencies,\n type MustDeclare,\n} from '../../utils/declared-dependencies';\nimport { addDependenciesToPackageJson } from '../../utils/dependencies';\nimport { type ITsDepVersion, withVersions } from '../../utils/versions';\nimport type { ConfigureProjectOptions } from './types';\n\nconst readGritPattern = (name: string): string =>\n readFileSync(\n join(import.meta.dirname, 'grit', `${name}.grit`),\n 'utf-8',\n ).trim();\n\n/** Dependencies a caller must declare to configure vitest. */\nexport const VITEST_DEPENDENCIES = [\n { name: 'vite' },\n { name: 'vitest' },\n { name: '@vitest/coverage-v8' },\n] as const satisfies readonly { name: ITsDepVersion }[];\n\nexport const configureVitest = async <const D extends DependencyDeclaration>(\n tree: Tree,\n options: ConfigureProjectOptions,\n declaration: D & MustDeclare<typeof VITEST_DEPENDENCIES, D>,\n) => {\n // Find vitest.config.mts or vite.config.mts\n const configPath = [\n join(options.dir, 'vitest.config.mts'),\n join(options.dir, 'vite.config.mts'),\n ].find((config) => tree.exists(config));\n\n if (configPath) {\n await applyGritQL(\n tree,\n configPath,\n readGritPattern('vitest-pass-with-no-tests'),\n );\n\n const nxJson = readNxJson(tree);\n updateNxJson(tree, {\n ...nxJson,\n targetDefaults: {\n ...(nxJson.targetDefaults ?? {}),\n '@nx/vitest:test': {\n cache: true,\n inputs: ['default', '^production'],\n configurations: {\n 'update-snapshot': {\n args: '--update',\n },\n },\n ...nxJson.targetDefaults['@nx/vitest:test'],\n },\n },\n });\n }\n\n addDependenciesToPackageJson(\n tree,\n {},\n withVersions(forDependencies<typeof VITEST_DEPENDENCIES>(declaration), [\n 'vite',\n 'vitest',\n '@vitest/coverage-v8',\n ]),\n );\n};\n"],"names":["readNxJson","updateNxJson","readFileSync","join","applyGritQL","forDependencies","addDependenciesToPackageJson","withVersions","readGritPattern","name","dirname","trim","VITEST_DEPENDENCIES","configureVitest","tree","options","declaration","configPath","dir","find","config","exists","nxJson","targetDefaults","cache","inputs","configurations","args"],"mappings":"AAAA;;;CAGC,GACD,SAASA,UAAU,EAAaC,YAAY,QAAQ,aAAa;AACjE,SAASC,YAAY,QAAQ,KAAK;AAClC,SAASC,IAAI,QAAQ,OAAO;AAC5B,SAASC,WAAW,QAAQ,qBAAkB;AAC9C,SAEEC,eAAe,QAEV,uCAAoC;AAC3C,SAASC,4BAA4B,QAAQ,8BAA2B;AACxE,SAA6BC,YAAY,QAAQ,0BAAuB;AAGxE,MAAMC,kBAAkB,CAACC,OACvBP,aACEC,KAAK,YAAYO,OAAO,EAAE,QAAQ,GAAGD,KAAK,KAAK,CAAC,GAChD,SACAE,IAAI;AAER,4DAA4D,GAC5D,OAAO,MAAMC,sBAAsB;IACjC;QAAEH,MAAM;IAAO;IACf;QAAEA,MAAM;IAAS;IACjB;QAAEA,MAAM;IAAsB;CAC/B,CAAuD;AAExD,OAAO,MAAMI,kBAAkB,OAC7BC,MACAC,SACAC;IAEA,4CAA4C;IAC5C,MAAMC,aAAa;QACjBd,KAAKY,QAAQG,GAAG,EAAE;QAClBf,KAAKY,QAAQG,GAAG,EAAE;KACnB,CAACC,IAAI,CAAC,CAACC,SAAWN,KAAKO,MAAM,CAACD;IAE/B,IAAIH,YAAY;QACd,MAAMb,YACJU,MACAG,YACAT,gBAAgB;QAGlB,MAAMc,SAAStB,WAAWc;QAC1Bb,aAAaa,MAAM;YACjB,GAAGQ,MAAM;YACTC,gBAAgB;gBACd,GAAID,OAAOC,cAAc,IAAI,CAAC,CAAC;gBAC/B,mBAAmB;oBACjBC,OAAO;oBACPC,QAAQ;wBAAC;wBAAW;qBAAc;oBAClCC,gBAAgB;wBACd,mBAAmB;4BACjBC,MAAM;wBACR;oBACF;oBACA,GAAGL,OAAOC,cAAc,CAAC,kBAAkB;gBAC7C;YACF;QACF;IACF;IAEAjB,6BACEQ,MACA,CAAC,GACDP,aAAaF,gBAA4CW,cAAc;QACrE;QACA;QACA;KACD;AAEL,EAAE"}
1
+ {"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/lib/vitest.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { readNxJson, type Tree, updateNxJson } from '@nx/devkit';\nimport { readFileSync } from 'fs';\nimport { join } from 'path';\nimport { applyGritQL } from '../../utils/ast';\nimport {\n type DependencyDeclaration,\n forDependencies,\n type MustDeclare,\n} from '../../utils/declared-dependencies';\nimport { addDependenciesToPackageJson } from '../../utils/dependencies';\nimport { type ITsDepVersion, withVersions } from '../../utils/versions';\nimport type { ConfigureProjectOptions } from './types';\n\nconst readGritPattern = (name: string): string =>\n readFileSync(\n join(import.meta.dirname, 'grit', `${name}.grit`),\n 'utf-8',\n ).trim();\n\n/**\n * Resolve the config's `root` from `import.meta.dirname`.\n *\n * `@nx/js` writes `root: __dirname`, which Vite's native config loader does not\n * provide — it warns today and will reject once `configLoader: 'native'` becomes\n * the default. Scoped with `some` to a direct property of the object the config\n * factory returns, so a nested `root` (a `test.alias` entry, say) is untouched.\n */\nconst ROOT_IMPORT_META_DIRNAME = `\\`defineConfig(() => ({ $props }))\\` where {\n $props <: some \\`root: __dirname\\` as $root,\n $root => \\`root: import.meta.dirname\\`\n}`;\n\n/** Dependencies a caller must declare to configure vitest. */\nexport const VITEST_DEPENDENCIES = [\n { name: 'vite' },\n { name: 'vitest' },\n { name: '@vitest/coverage-v8' },\n] as const satisfies readonly { name: ITsDepVersion }[];\n\nexport const configureVitest = async <const D extends DependencyDeclaration>(\n tree: Tree,\n options: ConfigureProjectOptions,\n declaration: D & MustDeclare<typeof VITEST_DEPENDENCIES, D>,\n) => {\n // Find vitest.config.mts or vite.config.mts\n const configPath = [\n join(options.dir, 'vitest.config.mts'),\n join(options.dir, 'vite.config.mts'),\n ].find((config) => tree.exists(config));\n\n if (configPath) {\n await applyGritQL(\n tree,\n configPath,\n readGritPattern('vitest-pass-with-no-tests'),\n );\n\n await applyGritQL(tree, configPath, ROOT_IMPORT_META_DIRNAME);\n\n const nxJson = readNxJson(tree);\n updateNxJson(tree, {\n ...nxJson,\n targetDefaults: {\n ...(nxJson.targetDefaults ?? {}),\n '@nx/vitest:test': {\n cache: true,\n inputs: ['default', '^production'],\n configurations: {\n 'update-snapshot': {\n args: '--update',\n },\n },\n ...nxJson.targetDefaults['@nx/vitest:test'],\n },\n },\n });\n }\n\n addDependenciesToPackageJson(\n tree,\n {},\n withVersions(forDependencies<typeof VITEST_DEPENDENCIES>(declaration), [\n 'vite',\n 'vitest',\n '@vitest/coverage-v8',\n ]),\n );\n};\n"],"names":["readNxJson","updateNxJson","readFileSync","join","applyGritQL","forDependencies","addDependenciesToPackageJson","withVersions","readGritPattern","name","dirname","trim","ROOT_IMPORT_META_DIRNAME","VITEST_DEPENDENCIES","configureVitest","tree","options","declaration","configPath","dir","find","config","exists","nxJson","targetDefaults","cache","inputs","configurations","args"],"mappings":"AAAA;;;CAGC,GACD,SAASA,UAAU,EAAaC,YAAY,QAAQ,aAAa;AACjE,SAASC,YAAY,QAAQ,KAAK;AAClC,SAASC,IAAI,QAAQ,OAAO;AAC5B,SAASC,WAAW,QAAQ,qBAAkB;AAC9C,SAEEC,eAAe,QAEV,uCAAoC;AAC3C,SAASC,4BAA4B,QAAQ,8BAA2B;AACxE,SAA6BC,YAAY,QAAQ,0BAAuB;AAGxE,MAAMC,kBAAkB,CAACC,OACvBP,aACEC,KAAK,YAAYO,OAAO,EAAE,QAAQ,GAAGD,KAAK,KAAK,CAAC,GAChD,SACAE,IAAI;AAER;;;;;;;CAOC,GACD,MAAMC,2BAA2B,CAAC;;;CAGjC,CAAC;AAEF,4DAA4D,GAC5D,OAAO,MAAMC,sBAAsB;IACjC;QAAEJ,MAAM;IAAO;IACf;QAAEA,MAAM;IAAS;IACjB;QAAEA,MAAM;IAAsB;CAC/B,CAAuD;AAExD,OAAO,MAAMK,kBAAkB,OAC7BC,MACAC,SACAC;IAEA,4CAA4C;IAC5C,MAAMC,aAAa;QACjBf,KAAKa,QAAQG,GAAG,EAAE;QAClBhB,KAAKa,QAAQG,GAAG,EAAE;KACnB,CAACC,IAAI,CAAC,CAACC,SAAWN,KAAKO,MAAM,CAACD;IAE/B,IAAIH,YAAY;QACd,MAAMd,YACJW,MACAG,YACAV,gBAAgB;QAGlB,MAAMJ,YAAYW,MAAMG,YAAYN;QAEpC,MAAMW,SAASvB,WAAWe;QAC1Bd,aAAac,MAAM;YACjB,GAAGQ,MAAM;YACTC,gBAAgB;gBACd,GAAID,OAAOC,cAAc,IAAI,CAAC,CAAC;gBAC/B,mBAAmB;oBACjBC,OAAO;oBACPC,QAAQ;wBAAC;wBAAW;qBAAc;oBAClCC,gBAAgB;wBACd,mBAAmB;4BACjBC,MAAM;wBACR;oBACF;oBACA,GAAGL,OAAOC,cAAc,CAAC,kBAAkB;gBAC7C;YACF;QACF;IACF;IAEAlB,6BACES,MACA,CAAC,GACDR,aAAaF,gBAA4CY,cAAc;QACrE;QACA;QACA;KACD;AAEL,EAAE"}
@@ -206,7 +206,7 @@ exports[`nx-generator generator > within @aws/nx-plugin > should update generato
206
206
  exports[`nx-generator generator > within another workspace > should generate an example schema, generator and test > local-generator.spec.ts 1`] = `
207
207
  "import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
208
208
  import { Tree } from '@nx/devkit';
209
- import { fooBarGenerator } from './generator';
209
+ import { fooBarGenerator } from './generator.js';
210
210
 
211
211
  describe('foo#bar generator', () => {
212
212
  let tree: Tree;
@@ -1,6 +1,6 @@
1
1
  import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
2
2
  import { Tree } from '@nx/devkit';
3
- import { <%- nameCamelCase %>Generator } from './generator';
3
+ import { <%- nameCamelCase %>Generator } from './generator<% if (esm) { %>.js<% } %>';
4
4
 
5
5
  describe('<%- name %> generator', () => {
6
6
  let tree: Tree;
@@ -1,6 +1,6 @@
1
1
  import type { Tree } from '@nx/devkit';
2
2
  import { createTreeUsingTsSolutionSetup } from '<%- testImportPath %>';
3
- import migration from './migration';
3
+ import migration from './migration<% if (esm) { %>.js<% } %>';
4
4
 
5
5
  describe('<%= name %> migration', () => {
6
6
  let tree: Tree;
@@ -10,6 +10,7 @@ import { formatFilesInSubtree } from "../../utils/format.js";
10
10
  import { installDependencies } from "../../utils/install.js";
11
11
  import { addGeneratorMetricsIfApplicable } from "../../utils/metrics.js";
12
12
  import { LATEST_MIGRATIONS_DIR, migrationKey } from "../../utils/migration-versions.js";
13
+ import { isEsmWorkspace } from "../../utils/module-format.js";
13
14
  import { kebabCase } from "../../utils/names.js";
14
15
  import { getGeneratorInfo, isNxPluginForAwsWorkspace } from "../../utils/nx.js";
15
16
  import { sortObjectKeys } from "../../utils/object.js";
@@ -58,6 +59,10 @@ export const NX_MIGRATION_GENERATOR_INFO = getGeneratorInfo(import.meta.filename
58
59
  // shared utils are relative. Elsewhere they come from the SDK.
59
60
  const formatImportPath = isNxPluginForAws ? '../../../utils/format' : `${PackageJson.name}/sdk/utils/format`;
60
61
  const testImportPath = isNxPluginForAws ? '../../../utils/test' : `${PackageJson.name}/sdk/utils/test`;
62
+ // A generated workspace resolves with `nodenext`, which needs the explicit
63
+ // extension on the spec's sibling import; this repo resolves with `bundler`,
64
+ // which takes it extensionless.
65
+ const esm = !isNxPluginForAws && isEsmWorkspace(tree);
61
66
  // One template set covers all kinds — scaffold it, then prune what this kind
62
67
  // doesn't use.
63
68
  generateFiles(tree, joinPathFragments(import.meta.dirname, 'files'), migrationDir, {
@@ -65,7 +70,8 @@ export const NX_MIGRATION_GENERATOR_INFO = getGeneratorInfo(import.meta.filename
65
70
  description,
66
71
  isHybrid,
67
72
  formatImportPath,
68
- testImportPath
73
+ testImportPath,
74
+ esm
69
75
  }, {
70
76
  overwriteStrategy: OverwriteStrategy.KeepExisting
71
77
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/nx-migration/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n readJson,\n type Tree,\n writeJson,\n} from '@nx/devkit';\nimport PackageJson from '../../../package.json' with { type: 'json' };\nimport { declareDependencies } from '../../utils/declared-dependencies';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { installDependencies } from '../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics';\nimport {\n LATEST_MIGRATIONS_DIR,\n migrationKey,\n} from '../../utils/migration-versions';\nimport { kebabCase } from '../../utils/names';\nimport {\n getGeneratorInfo,\n isNxPluginForAwsWorkspace,\n type NxGeneratorInfo,\n} from '../../utils/nx';\nimport { sortObjectKeys } from '../../utils/object';\nimport {\n addNxPluginDependencies,\n configureNxPluginPackageJson,\n NX_PLUGIN_DEPENDENCIES,\n readNxPluginProject,\n} from '../nx-plugin/utils';\nimport type { TsNxMigrationGeneratorSchema } from './schema';\n\nexport const DEPENDENCIES = declareDependencies()({\n ts: [...NX_PLUGIN_DEPENDENCIES],\n});\n\nexport const NX_MIGRATION_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\n/**\n * Scaffolds a migration in an Nx Plugin project and registers it in the\n * plugin's `migrations.json` (creating the manifest and wiring the\n * `nx-migrations` field into the plugin's `package.json` if absent), so\n * `nx migrate` applies it when users upgrade the plugin.\n *\n * Supports all three migration kinds:\n * - `deterministic`: a codemod (`implementation`).\n * - `agentic`: a `prompt` markdown file applied by the user's agent.\n * - `hybrid`: both — the codemod does the mechanical part and returns\n * `agentContext`, then the prompt hands off to the agent for the rest.\n *\n * No `version` is written — the plugin author stamps versions at release time.\n */\nexport const tsNxMigrationGenerator = async (\n tree: Tree,\n options: TsNxMigrationGeneratorSchema,\n): Promise<GeneratorCallback | void> => {\n const name = kebabCase(options.name);\n // Shown by `nx migrate` when the migration runs, so it needs to say something\n const description =\n options.description ?? 'TODO: Add short description of the migration';\n const kind = options.kind ?? 'deterministic';\n\n const hasImplementation = kind === 'deterministic' || kind === 'hybrid';\n const hasPrompt = kind === 'agentic' || kind === 'hybrid';\n const isHybrid = kind === 'hybrid';\n\n const plugin = readNxPluginProject(tree, options.project);\n\n const sourceRoot = plugin.sourceRoot ?? joinPathFragments(plugin.root, 'src');\n const srcDir = sourceRoot.split('/').filter(Boolean).pop();\n // Migrations are grouped by the release that ships them. A new one lands in\n // `latest` — the release that picks it up moves it into its version folder.\n const migrationPath = `${srcDir}/migrations/${LATEST_MIGRATIONS_DIR}/${name}`;\n const migrationDir = joinPathFragments(\n sourceRoot,\n 'migrations',\n LATEST_MIGRATIONS_DIR,\n name,\n );\n const key = migrationKey(LATEST_MIGRATIONS_DIR, name);\n\n const isNxPluginForAws = isNxPluginForAwsWorkspace(tree);\n\n // Point the plugin at its migrations manifest so `nx migrate` finds them\n const pluginPackageJsonPath = configureNxPluginPackageJson(\n tree,\n plugin,\n 'nx-migrations',\n { migrations: './migrations.json' },\n );\n\n // Migrations sit three levels below the source root, so in this repo the\n // shared utils are relative. Elsewhere they come from the SDK.\n const formatImportPath = isNxPluginForAws\n ? '../../../utils/format'\n : `${PackageJson.name}/sdk/utils/format`;\n const testImportPath = isNxPluginForAws\n ? '../../../utils/test'\n : `${PackageJson.name}/sdk/utils/test`;\n\n // One template set covers all kinds — scaffold it, then prune what this kind\n // doesn't use.\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files'),\n migrationDir,\n { name, description, isHybrid, formatImportPath, testImportPath },\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n if (!hasImplementation) {\n tree.delete(joinPathFragments(migrationDir, 'migration.ts'));\n tree.delete(joinPathFragments(migrationDir, 'migration.spec.ts'));\n }\n if (!hasPrompt) {\n tree.delete(joinPathFragments(migrationDir, 'prompt.md'));\n }\n\n if (isNxPluginForAws) {\n // In the plugin's own repo migrations.json is assembled from these folders\n // at build time (see utils/migration-manifest.ts), so registration is just\n // the description beside the code — its kind comes from the files present.\n // Two migration PRs then touch disjoint files rather than one shared manifest.\n const metadataPath = joinPathFragments(migrationDir, 'metadata.json');\n if (!tree.exists(metadataPath)) {\n writeJson(tree, metadataPath, { description });\n }\n } else {\n // Elsewhere, register the migration under its folder-prefixed key. The fields\n // present discriminate the kind for nx, and paths are relative to\n // migrations.json. No version is written, but an already-stamped one is kept.\n const migrationsJsonPath = joinPathFragments(\n plugin.root,\n 'migrations.json',\n );\n const migrationsJson = tree.exists(migrationsJsonPath)\n ? readJson(tree, migrationsJsonPath)\n : {\n $schema: 'http://json-schema.org/schema',\n name: readJson(tree, pluginPackageJsonPath).name ?? plugin.name,\n generators: {},\n };\n writeJson(tree, migrationsJsonPath, {\n ...migrationsJson,\n generators: sortObjectKeys({\n ...migrationsJson.generators,\n [key]: {\n ...(migrationsJson.generators?.[key]?.version\n ? { version: migrationsJson.generators[key].version }\n : {}),\n description,\n ...(hasImplementation\n ? { implementation: `./${migrationPath}/migration` }\n : {}),\n ...(hasPrompt ? { prompt: `./${migrationPath}/prompt.md` } : {}),\n },\n }),\n });\n }\n\n // Codemods import @nx/devkit and the @aws/nx-plugin SDK, both of which must\n // resolve for nx to run them\n if (hasImplementation) {\n addNxPluginDependencies(tree, pluginPackageJsonPath, DEPENDENCIES);\n }\n\n await addGeneratorMetricsIfApplicable(tree, [NX_MIGRATION_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n\n if (hasImplementation && !isNxPluginForAws) {\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n ensureResolvable: ['@nx/devkit'],\n });\n }\n};\n\nexport default tsNxMigrationGenerator;\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","readJson","writeJson","PackageJson","type","declareDependencies","formatFilesInSubtree","installDependencies","addGeneratorMetricsIfApplicable","LATEST_MIGRATIONS_DIR","migrationKey","kebabCase","getGeneratorInfo","isNxPluginForAwsWorkspace","sortObjectKeys","addNxPluginDependencies","configureNxPluginPackageJson","NX_PLUGIN_DEPENDENCIES","readNxPluginProject","DEPENDENCIES","ts","NX_MIGRATION_GENERATOR_INFO","filename","tsNxMigrationGenerator","tree","options","name","description","kind","hasImplementation","hasPrompt","isHybrid","plugin","project","sourceRoot","root","srcDir","split","filter","Boolean","pop","migrationPath","migrationDir","key","isNxPluginForAws","pluginPackageJsonPath","migrations","formatImportPath","testImportPath","dirname","overwriteStrategy","KeepExisting","delete","metadataPath","exists","migrationsJsonPath","migrationsJson","$schema","generators","version","implementation","prompt","preferInstallDependencies","languages","ensureResolvable"],"mappings":"AAAA;;;CAGC,GACD,SAEEA,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EACjBC,QAAQ,EAERC,SAAS,QACJ,aAAa;AACpB,OAAOC,iBAAiB,6BAA6B;IAAEC,MAAM;AAAO,EAAE;AACtE,SAASC,mBAAmB,QAAQ,uCAAoC;AACxE,SAASC,oBAAoB,QAAQ,wBAAqB;AAC1D,SAASC,mBAAmB,QAAQ,yBAAsB;AAC1D,SAASC,+BAA+B,QAAQ,yBAAsB;AACtE,SACEC,qBAAqB,EACrBC,YAAY,QACP,oCAAiC;AACxC,SAASC,SAAS,QAAQ,uBAAoB;AAC9C,SACEC,gBAAgB,EAChBC,yBAAyB,QAEpB,oBAAiB;AACxB,SAASC,cAAc,QAAQ,wBAAqB;AACpD,SACEC,uBAAuB,EACvBC,4BAA4B,EAC5BC,sBAAsB,EACtBC,mBAAmB,QACd,wBAAqB;AAG5B,OAAO,MAAMC,eAAed,sBAAsB;IAChDe,IAAI;WAAIH;KAAuB;AACjC,GAAG;AAEH,OAAO,MAAMI,8BAA+CT,iBAC1D,YAAYU,QAAQ,EACpB;AAEF;;;;;;;;;;;;;CAaC,GACD,OAAO,MAAMC,yBAAyB,OACpCC,MACAC;IAEA,MAAMC,OAAOf,UAAUc,QAAQC,IAAI;IACnC,8EAA8E;IAC9E,MAAMC,cACJF,QAAQE,WAAW,IAAI;IACzB,MAAMC,OAAOH,QAAQG,IAAI,IAAI;IAE7B,MAAMC,oBAAoBD,SAAS,mBAAmBA,SAAS;IAC/D,MAAME,YAAYF,SAAS,aAAaA,SAAS;IACjD,MAAMG,WAAWH,SAAS;IAE1B,MAAMI,SAASd,oBAAoBM,MAAMC,QAAQQ,O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../packages/nx-plugin/src/ts/nx-migration/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n readJson,\n type Tree,\n writeJson,\n} from '@nx/devkit';\nimport PackageJson from '../../../package.json' with { type: 'json' };\nimport { declareDependencies } from '../../utils/declared-dependencies';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { installDependencies } from '../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics';\nimport {\n LATEST_MIGRATIONS_DIR,\n migrationKey,\n} from '../../utils/migration-versions';\nimport { isEsmWorkspace } from '../../utils/module-format';\nimport { kebabCase } from '../../utils/names';\nimport {\n getGeneratorInfo,\n isNxPluginForAwsWorkspace,\n type NxGeneratorInfo,\n} from '../../utils/nx';\nimport { sortObjectKeys } from '../../utils/object';\nimport {\n addNxPluginDependencies,\n configureNxPluginPackageJson,\n NX_PLUGIN_DEPENDENCIES,\n readNxPluginProject,\n} from '../nx-plugin/utils';\nimport type { TsNxMigrationGeneratorSchema } from './schema';\n\nexport const DEPENDENCIES = declareDependencies()({\n ts: [...NX_PLUGIN_DEPENDENCIES],\n});\n\nexport const NX_MIGRATION_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\n/**\n * Scaffolds a migration in an Nx Plugin project and registers it in the\n * plugin's `migrations.json` (creating the manifest and wiring the\n * `nx-migrations` field into the plugin's `package.json` if absent), so\n * `nx migrate` applies it when users upgrade the plugin.\n *\n * Supports all three migration kinds:\n * - `deterministic`: a codemod (`implementation`).\n * - `agentic`: a `prompt` markdown file applied by the user's agent.\n * - `hybrid`: both — the codemod does the mechanical part and returns\n * `agentContext`, then the prompt hands off to the agent for the rest.\n *\n * No `version` is written — the plugin author stamps versions at release time.\n */\nexport const tsNxMigrationGenerator = async (\n tree: Tree,\n options: TsNxMigrationGeneratorSchema,\n): Promise<GeneratorCallback | void> => {\n const name = kebabCase(options.name);\n // Shown by `nx migrate` when the migration runs, so it needs to say something\n const description =\n options.description ?? 'TODO: Add short description of the migration';\n const kind = options.kind ?? 'deterministic';\n\n const hasImplementation = kind === 'deterministic' || kind === 'hybrid';\n const hasPrompt = kind === 'agentic' || kind === 'hybrid';\n const isHybrid = kind === 'hybrid';\n\n const plugin = readNxPluginProject(tree, options.project);\n\n const sourceRoot = plugin.sourceRoot ?? joinPathFragments(plugin.root, 'src');\n const srcDir = sourceRoot.split('/').filter(Boolean).pop();\n // Migrations are grouped by the release that ships them. A new one lands in\n // `latest` — the release that picks it up moves it into its version folder.\n const migrationPath = `${srcDir}/migrations/${LATEST_MIGRATIONS_DIR}/${name}`;\n const migrationDir = joinPathFragments(\n sourceRoot,\n 'migrations',\n LATEST_MIGRATIONS_DIR,\n name,\n );\n const key = migrationKey(LATEST_MIGRATIONS_DIR, name);\n\n const isNxPluginForAws = isNxPluginForAwsWorkspace(tree);\n\n // Point the plugin at its migrations manifest so `nx migrate` finds them\n const pluginPackageJsonPath = configureNxPluginPackageJson(\n tree,\n plugin,\n 'nx-migrations',\n { migrations: './migrations.json' },\n );\n\n // Migrations sit three levels below the source root, so in this repo the\n // shared utils are relative. Elsewhere they come from the SDK.\n const formatImportPath = isNxPluginForAws\n ? '../../../utils/format'\n : `${PackageJson.name}/sdk/utils/format`;\n const testImportPath = isNxPluginForAws\n ? '../../../utils/test'\n : `${PackageJson.name}/sdk/utils/test`;\n // A generated workspace resolves with `nodenext`, which needs the explicit\n // extension on the spec's sibling import; this repo resolves with `bundler`,\n // which takes it extensionless.\n const esm = !isNxPluginForAws && isEsmWorkspace(tree);\n\n // One template set covers all kinds — scaffold it, then prune what this kind\n // doesn't use.\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files'),\n migrationDir,\n {\n name,\n description,\n isHybrid,\n formatImportPath,\n testImportPath,\n esm,\n },\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n if (!hasImplementation) {\n tree.delete(joinPathFragments(migrationDir, 'migration.ts'));\n tree.delete(joinPathFragments(migrationDir, 'migration.spec.ts'));\n }\n if (!hasPrompt) {\n tree.delete(joinPathFragments(migrationDir, 'prompt.md'));\n }\n\n if (isNxPluginForAws) {\n // In the plugin's own repo migrations.json is assembled from these folders\n // at build time (see utils/migration-manifest.ts), so registration is just\n // the description beside the code — its kind comes from the files present.\n // Two migration PRs then touch disjoint files rather than one shared manifest.\n const metadataPath = joinPathFragments(migrationDir, 'metadata.json');\n if (!tree.exists(metadataPath)) {\n writeJson(tree, metadataPath, { description });\n }\n } else {\n // Elsewhere, register the migration under its folder-prefixed key. The fields\n // present discriminate the kind for nx, and paths are relative to\n // migrations.json. No version is written, but an already-stamped one is kept.\n const migrationsJsonPath = joinPathFragments(\n plugin.root,\n 'migrations.json',\n );\n const migrationsJson = tree.exists(migrationsJsonPath)\n ? readJson(tree, migrationsJsonPath)\n : {\n $schema: 'http://json-schema.org/schema',\n name: readJson(tree, pluginPackageJsonPath).name ?? plugin.name,\n generators: {},\n };\n writeJson(tree, migrationsJsonPath, {\n ...migrationsJson,\n generators: sortObjectKeys({\n ...migrationsJson.generators,\n [key]: {\n ...(migrationsJson.generators?.[key]?.version\n ? { version: migrationsJson.generators[key].version }\n : {}),\n description,\n ...(hasImplementation\n ? { implementation: `./${migrationPath}/migration` }\n : {}),\n ...(hasPrompt ? { prompt: `./${migrationPath}/prompt.md` } : {}),\n },\n }),\n });\n }\n\n // Codemods import @nx/devkit and the @aws/nx-plugin SDK, both of which must\n // resolve for nx to run them\n if (hasImplementation) {\n addNxPluginDependencies(tree, pluginPackageJsonPath, DEPENDENCIES);\n }\n\n await addGeneratorMetricsIfApplicable(tree, [NX_MIGRATION_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n\n if (hasImplementation && !isNxPluginForAws) {\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n ensureResolvable: ['@nx/devkit'],\n });\n }\n};\n\nexport default tsNxMigrationGenerator;\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","readJson","writeJson","PackageJson","type","declareDependencies","formatFilesInSubtree","installDependencies","addGeneratorMetricsIfApplicable","LATEST_MIGRATIONS_DIR","migrationKey","isEsmWorkspace","kebabCase","getGeneratorInfo","isNxPluginForAwsWorkspace","sortObjectKeys","addNxPluginDependencies","configureNxPluginPackageJson","NX_PLUGIN_DEPENDENCIES","readNxPluginProject","DEPENDENCIES","ts","NX_MIGRATION_GENERATOR_INFO","filename","tsNxMigrationGenerator","tree","options","name","description","kind","hasImplementation","hasPrompt","isHybrid","plugin","project","sourceRoot","root","srcDir","split","filter","Boolean","pop","migrationPath","migrationDir","key","isNxPluginForAws","pluginPackageJsonPath","migrations","formatImportPath","testImportPath","esm","dirname","overwriteStrategy","KeepExisting","delete","metadataPath","exists","migrationsJsonPath","migrationsJson","$schema","generators","version","implementation","prompt","preferInstallDependencies","languages","ensureResolvable"],"mappings":"AAAA;;;CAGC,GACD,SAEEA,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EACjBC,QAAQ,EAERC,SAAS,QACJ,aAAa;AACpB,OAAOC,iBAAiB,6BAA6B;IAAEC,MAAM;AAAO,EAAE;AACtE,SAASC,mBAAmB,QAAQ,uCAAoC;AACxE,SAASC,oBAAoB,QAAQ,wBAAqB;AAC1D,SAASC,mBAAmB,QAAQ,yBAAsB;AAC1D,SAASC,+BAA+B,QAAQ,yBAAsB;AACtE,SACEC,qBAAqB,EACrBC,YAAY,QACP,oCAAiC;AACxC,SAASC,cAAc,QAAQ,+BAA4B;AAC3D,SAASC,SAAS,QAAQ,uBAAoB;AAC9C,SACEC,gBAAgB,EAChBC,yBAAyB,QAEpB,oBAAiB;AACxB,SAASC,cAAc,QAAQ,wBAAqB;AACpD,SACEC,uBAAuB,EACvBC,4BAA4B,EAC5BC,sBAAsB,EACtBC,mBAAmB,QACd,wBAAqB;AAG5B,OAAO,MAAMC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EpB,cAAc,UAAU,CAAC;oBAAC,IACjD,CAAC,CAAC;oBACN,GAAIX,YAAY;wBAAEgC,QAAQ,CAAC,EAAE,EAAErB,cAAc,UAAU,CAAC;oBAAC,IAAI,CAAC,CAAC;gBACjE;YACF;QACF;IACF;IAEA,4EAA4E;IAC5E,6BAA6B;IAC7B,IAAIZ,mBAAmB;QACrBd,wBAAwBS,MAAMqB,uBAAuB1B;IACvD;IAEA,MAAMZ,gCAAgCiB,MAAM;QAACH;KAA4B;IAEzE,MAAMhB,qBAAqBmB;IAE3B,IAAIK,qBAAqB,CAACe,kBAAkB;QAC1C,OAAO,IACLtC,oBAAoBkB,MAAMC,QAAQsC,yBAAyB,EAAE;gBAC3DC,WAAW;oBAAC;iBAAa;gBACzBC,kBAAkB;oBAAC;iBAAa;YAClC;IACJ;AACF,EAAE;AAEF,eAAe1C,uBAAuB"}
@@ -4714,7 +4714,7 @@ export default defineConfig([
4714
4714
  output: {
4715
4715
  file: '../../dist/packages/db/bundle/migration/index.js',
4716
4716
  format: 'cjs',
4717
- inlineDynamicImports: true,
4717
+ codeSplitting: false,
4718
4718
  },
4719
4719
  platform: 'node',
4720
4720
  },
@@ -4724,7 +4724,7 @@ export default defineConfig([
4724
4724
  output: {
4725
4725
  file: '../../dist/packages/db/bundle/create-db-user/index.js',
4726
4726
  format: 'cjs',
4727
- inlineDynamicImports: true,
4727
+ codeSplitting: false,
4728
4728
  },
4729
4729
  platform: 'node',
4730
4730
  },
@@ -21,8 +21,8 @@ export default defineConfig(() => ({
21
21
  },
22
22
  plugins: [
23
23
  tanstackRouter({
24
- routesDirectory: resolve(__dirname, 'src/routes'),
25
- generatedRouteTree: resolve(__dirname, 'src/routeTree.gen.ts'),
24
+ routesDirectory: resolve(import.meta.dirname, 'src/routes'),
25
+ generatedRouteTree: resolve(import.meta.dirname, 'src/routeTree.gen.ts'),
26
26
  }),
27
27
  react(),
28
28
  tailwindcss(),
@@ -78,8 +78,8 @@ export default defineConfig(() => ({
78
78
  },
79
79
  plugins: [
80
80
  tanstackRouter({
81
- routesDirectory: resolve(__dirname, 'src/routes'),
82
- generatedRouteTree: resolve(__dirname, 'src/routeTree.gen.ts'),
81
+ routesDirectory: resolve(import.meta.dirname, 'src/routes'),
82
+ generatedRouteTree: resolve(import.meta.dirname, 'src/routeTree.gen.ts'),
83
83
  }),
84
84
  react(),
85
85
  ],
@@ -2152,7 +2152,7 @@ exports[`react-website generator > Tanstack router integration > should generate
2152
2152
  "import { defineConfig } from 'vitest/config';
2153
2153
 
2154
2154
  export default defineConfig(() => ({
2155
- root: __dirname,
2155
+ root: import.meta.dirname,
2156
2156
  cacheDir: '../../../node_modules/.vite/packages/common/constructs',
2157
2157
  test: {
2158
2158
  passWithNoTests: true,
@@ -3977,7 +3977,7 @@ exports[`react-website generator > Tanstack router integration > should generate
3977
3977
  "import { defineConfig } from 'vitest/config';
3978
3978
 
3979
3979
  export default defineConfig(() => ({
3980
- root: __dirname,
3980
+ root: import.meta.dirname,
3981
3981
  cacheDir: '../../../node_modules/.vite/packages/common/constructs',
3982
3982
  test: {
3983
3983
  passWithNoTests: true,
@@ -4706,8 +4706,8 @@ export default defineConfig(() => ({
4706
4706
  },
4707
4707
  plugins: [
4708
4708
  tanstackRouter({
4709
- routesDirectory: resolve(__dirname, 'src/routes'),
4710
- generatedRouteTree: resolve(__dirname, 'src/routeTree.gen.ts'),
4709
+ routesDirectory: resolve(import.meta.dirname, 'src/routes'),
4710
+ generatedRouteTree: resolve(import.meta.dirname, 'src/routeTree.gen.ts'),
4711
4711
  }),
4712
4712
  react(),
4713
4713
  tailwindcss(),
@@ -4835,8 +4835,8 @@ export default defineConfig(() => ({
4835
4835
  },
4836
4836
  plugins: [
4837
4837
  tanstackRouter({
4838
- routesDirectory: resolve(__dirname, 'src/routes'),
4839
- generatedRouteTree: resolve(__dirname, 'src/routeTree.gen.ts'),
4838
+ routesDirectory: resolve(import.meta.dirname, 'src/routes'),
4839
+ generatedRouteTree: resolve(import.meta.dirname, 'src/routeTree.gen.ts'),
4840
4840
  }),
4841
4841
  react(),
4842
4842
  tailwindcss(),
@@ -355,7 +355,7 @@ export async function tsReactWebsiteGenerator(tree, schema) {
355
355
  // Add plugins to the plugins array
356
356
  if (tanstackRouter) {
357
357
  // Prepend tanstackRouter (must be first plugin) — rewrite works for both single/multi-element
358
- await applyGritQL(tree, viteConfigPath, "`plugins: [$items]` => `plugins: [tanstackRouter({ routesDirectory: resolve(__dirname, 'src/routes'), generatedRouteTree: resolve(__dirname, 'src/routeTree.gen.ts') }), $items]` where { $items <: within `defineConfig($_)`, $items <: not contains `tanstackRouter` }");
358
+ await applyGritQL(tree, viteConfigPath, "`plugins: [$items]` => `plugins: [tanstackRouter({ routesDirectory: resolve(import.meta.dirname, 'src/routes'), generatedRouteTree: resolve(import.meta.dirname, 'src/routeTree.gen.ts') }), $items]` where { $items <: within `defineConfig($_)`, $items <: not contains `tanstackRouter` }");
359
359
  }
360
360
  if (tailwind) {
361
361
  await applyGritQL(tree, viteConfigPath, '`plugins: [$items]` => `plugins: [$items, tailwindcss()]` where { $items <: within `defineConfig($_)`, $items <: not some `tailwindcss()` }');
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../packages/nx-plugin/src/ts/react-website/app/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n generateFiles,\n joinPathFragments,\n names,\n OverwriteStrategy,\n readProjectConfiguration,\n removeDependenciesFromPackageJson,\n type Tree,\n updateJson,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { applicationGenerator } from '@nx/react';\nimport { relative, sep } from 'path';\nimport { addTsDependencies } from '../../../utils/add-dependencies';\nimport {\n addDestructuredImport,\n addSingleImport,\n applyGritQL,\n} from '../../../utils/ast';\nimport {\n declareDependencies,\n ownedElsewhere,\n} from '../../../utils/declared-dependencies';\nimport { formatFilesInSubtree } from '../../../utils/format';\nimport { resolveIac } from '../../../utils/iac';\nimport { installDependencies } from '../../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../../utils/metrics';\nimport { kebabCase, toClassName, toKebabCase } from '../../../utils/names';\nimport { getNpmScopePrefix } from '../../../utils/npm-scope';\nimport {\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n} from '../../../utils/nx';\nimport { sortObjectKeys } from '../../../utils/object';\nimport { getRelativePathToRoot } from '../../../utils/paths';\nimport { getPackageManagerDisplayCommands } from '../../../utils/pkg-manager';\nimport {\n SHARED_CONSTRUCTS_DEPENDENCIES,\n sharedConstructsGenerator,\n} from '../../../utils/shared-constructs';\nimport {\n type IacMetadata,\n PACKAGES_DIR,\n SHARED_SHADCN_DIR,\n} from '../../../utils/shared-constructs-constants';\nimport {\n SHADCN_DEPENDENCIES,\n sharedShadcnGenerator,\n} from '../../../utils/shared-shadcn';\nimport {\n addWebsiteInfra,\n WEBSITE_CONSTRUCTS_PY_DEPENDENCIES,\n} from '../../../utils/website-constructs/website-constructs';\nimport { configureTsProject } from '../../lib/ts-project-utils';\nimport { VITEST_DEPENDENCIES } from '../../lib/vitest';\n// typescript factory imports removed — now using GritQL for vite config transforms\nimport type {\n TsReactWebsiteGeneratorSchema,\n WebsiteInfraOption,\n} from './schema';\n\n/** The metadata this generator records, which its predicates read. */\nexport interface TsReactWebsiteMetadata extends IacMetadata {\n readonly ux: UxOption;\n readonly framework: string;\n readonly infra: WebsiteInfraOption;\n readonly tailwind: boolean;\n readonly tanstackRouter: boolean;\n}\n\n// Each entry names the branch it belongs to, so the same declaration drives both\n// adding and the version sync.\nexport const DEPENDENCIES = declareDependencies<TsReactWebsiteMetadata>()({\n ts: [\n { name: 'react' },\n { name: 'react-dom' },\n // Build/test tooling imported only from vite.config.mts stays at the root.\n { name: '@nx/react', dev: true, root: true },\n { name: '@vitest/ui', dev: true, root: true },\n {\n name: '@cloudscape-design/components',\n when: (m) => m.ux === 'cloudscape',\n },\n {\n name: '@cloudscape-design/board-components',\n when: (m) => m.ux === 'cloudscape',\n },\n {\n name: '@cloudscape-design/global-styles',\n when: (m) => m.ux === 'cloudscape',\n },\n // Shared shadcn components live in the common/shadcn package, but the\n // website's own generated components (e.g. the tanstack-router sidebar)\n // import lucide-react directly, so the website must declare it.\n {\n name: 'lucide-react',\n when: (m) => m.ux === 'shadcn' && m.tanstackRouter,\n },\n { name: 'tailwindcss', when: (m) => m.tailwind },\n {\n name: '@tailwindcss/vite',\n when: (m) => m.tailwind,\n dev: true,\n root: true,\n },\n { name: '@tanstack/react-router', when: (m) => m.tanstackRouter },\n {\n name: '@tanstack/router-plugin',\n when: (m) => m.tanstackRouter,\n dev: true,\n root: true,\n },\n {\n name: '@tanstack/router-generator',\n when: (m) => m.tanstackRouter,\n dev: true,\n root: true,\n },\n {\n name: '@tanstack/virtual-file-routes',\n when: (m) => m.tanstackRouter,\n dev: true,\n root: true,\n },\n {\n name: '@tanstack/router-utils',\n when: (m) => m.tanstackRouter,\n dev: true,\n root: true,\n },\n ...ownedElsewhere(SHADCN_DEPENDENCIES),\n ...ownedElsewhere(VITEST_DEPENDENCIES),\n ...ownedElsewhere(SHARED_CONSTRUCTS_DEPENDENCIES),\n ],\n py: ownedElsewhere(WEBSITE_CONSTRUCTS_PY_DEPENDENCIES),\n});\n\nexport const SUPPORTED_UX_PROVIDERS = ['none', 'cloudscape', 'shadcn'] as const;\n\nexport type UxOption = (typeof SUPPORTED_UX_PROVIDERS)[number];\n\nexport type Ux = UxOption;\n\nexport const REACT_WEBSITE_APP_GENERATOR_INFO: NxGeneratorInfo =\n getGeneratorInfo(import.meta.filename);\n\nexport async function tsReactWebsiteGenerator(\n tree: Tree,\n schema: TsReactWebsiteGeneratorSchema,\n) {\n const tailwind = schema.tailwind ?? true;\n const tanstackRouter = schema.tanstackRouter ?? true;\n const ux: Ux = schema.ux ?? 'shadcn';\n if (ux === 'shadcn' && !tailwind) {\n throw new Error('Shadcn requires TailwindCSS to be enabled.');\n }\n const npmScopePrefix = getNpmScopePrefix(tree);\n const scopeAlias = npmScopePrefix;\n const websiteNameClassName = toClassName(schema.name);\n const websiteNameKebabCase = toKebabCase(schema.name);\n const fullyQualifiedName = `${npmScopePrefix}${websiteNameKebabCase}`;\n // NB: interactive nx generator cli can pass empty string\n const websiteContentPath = joinPathFragments(\n schema.directory || '.',\n schema.subDirectory || websiteNameKebabCase,\n );\n\n const projectAlreadyExists = tree.exists(\n joinPathFragments(websiteContentPath, 'project.json'),\n );\n\n // TODO: consider exposing and supporting e2e tests\n const e2eTestRunner = 'none';\n\n if (!projectAlreadyExists) {\n await applicationGenerator(tree, {\n ...schema,\n name: fullyQualifiedName,\n directory: websiteContentPath,\n routing: false,\n e2eTestRunner,\n linter: 'none',\n bundler: 'vite',\n unitTestRunner: 'vitest',\n useProjectJson: true,\n style: 'css',\n // Register the @nx/vite and @nx/vitest plugins so build/serve/test\n // targets are inferred rather than emitting deprecated executor targets.\n addPlugin: true,\n });\n\n // Pin the inferred target names. The vite production build is exposed as\n // `bundle` (which produces the deployable artifact), leaving `build` as an\n // aggregator over lint/compile/test/bundle. vite's own typecheck is dropped\n // in favour of the tsc `compile`.\n updateJson(tree, 'nx.json', (nxJson) => {\n for (const plugin of nxJson.plugins ?? []) {\n if (typeof plugin === 'string') continue;\n if (plugin.plugin === '@nx/vite/plugin') {\n plugin.options = {\n ...plugin.options,\n buildTargetName: 'bundle',\n // Map both of vite's inferred dev-server targets onto `serve` so the\n // plugin doesn't emit a separate `dev`; we author our own `dev`\n // below running the local-dev vite mode.\n serveTargetName: 'serve',\n devTargetName: 'serve',\n previewTargetName: 'preview',\n serveStaticTargetName: 'serve-static',\n typecheckTargetName: 'vite:typecheck',\n };\n } else if (plugin.plugin === '@nx/vitest') {\n plugin.options = {\n ...plugin.options,\n testTargetName: 'test',\n };\n }\n }\n return nxJson;\n });\n\n // Replace with simpler sample source code\n tree.delete(joinPathFragments(websiteContentPath, 'src'));\n }\n\n const projectConfiguration = readProjectConfiguration(\n tree,\n fullyQualifiedName,\n );\n\n const targets = projectConfiguration.targets;\n\n const infra = schema.infra ?? 'cloudfront-s3';\n\n // Configure load-runtime-config target based on IaC provider (only when infra is not none)\n const iac = infra !== 'none' ? await resolveIac(tree, schema.iac) : undefined;\n\n if (iac === 'cdk') {\n targets['load-runtime-config'] = {\n executor: 'nx:run-commands',\n metadata: {\n description: `Load runtime config from your deployed stack for dev purposes. You must set your AWS CLI credentials whilst calling '${getPackageManagerDisplayCommands().exec} nx load-runtime-config ${fullyQualifiedName}'`,\n },\n options: {\n command: `aws s3 cp s3://\\`aws cloudformation describe-stacks --query \"Stacks[?starts_with(StackName, '${kebabCase(npmScopePrefix)}-')][].Outputs[] | [?contains(OutputKey, '${websiteNameClassName}WebsiteBucketName')].OutputValue\" --output text\\`/runtime-config.json \"{projectRoot}/public/runtime-config.json\"`,\n },\n };\n } else if (iac === 'terraform') {\n targets['load-runtime-config'] = {\n executor: 'nx:run-commands',\n metadata: {\n description:\n \"Load runtime config from most recently applied terraform env for dev purposes. Copies the runtime config from the Terraform dist directory to the website's public directory.\",\n },\n options: {\n command:\n 'node -e \"const fs=require(\\'fs\\');fs.mkdirSync(process.env.DEST_DIR,{recursive:true});fs.copyFileSync(process.env.SRC_FILE,process.env.DEST_FILE);\"',\n env: {\n SRC_FILE: 'dist/packages/common/terraform/runtime-config.json',\n DEST_DIR: `{projectRoot}/public`,\n DEST_FILE: `{projectRoot}/public/runtime-config.json`,\n },\n },\n };\n }\n\n if (!projectAlreadyExists) {\n targets['compile'] = {\n dependsOn: ['^build'],\n executor: 'nx:run-commands',\n outputs: ['{workspaceRoot}/dist/{projectRoot}/tsc'],\n options: {\n command: 'tsc --build tsconfig.app.json',\n cwd: '{projectRoot}',\n },\n };\n // bundle is the @nx/vite/plugin inferred `vite build` (writing to the\n // bundle dir configured in vite.config) — it produces the deployable\n // artifact. build aggregates lint/compile/test/bundle.\n targets['build'] = {\n dependsOn: ['lint', 'compile', 'test', 'bundle'],\n };\n\n // Run the website and its connected dependencies locally. Mirrors the\n // inferred `serve` target but with the local-dev vite mode.\n targets['dev'] = {\n executor: 'nx:run-commands',\n continuous: true,\n options: {\n command: 'vite --mode local-dev',\n cwd: '{projectRoot}',\n },\n };\n }\n\n projectConfiguration.targets = sortObjectKeys(targets);\n\n updateProjectConfiguration(tree, fullyQualifiedName, projectConfiguration);\n\n // Recorded here and read by the declaration's predicates, so the packages\n // added below are exactly the ones the version sync will own.\n const metadata: TsReactWebsiteMetadata = {\n ux,\n framework: 'react',\n infra,\n tailwind,\n tanstackRouter,\n // Undefined when no infrastructure was generated, so neither provider's\n // packages were added.\n ...(iac ? { iac } : {}),\n };\n addGeneratorMetadata(\n tree,\n projectConfiguration.name,\n REACT_WEBSITE_APP_GENERATOR_INFO,\n metadata,\n );\n\n await configureTsProject(\n tree,\n {\n dir: websiteContentPath,\n fullyQualifiedName,\n },\n DEPENDENCIES,\n );\n\n if (ux === 'shadcn') {\n await sharedShadcnGenerator(tree, DEPENDENCIES);\n }\n\n if (iac) {\n await sharedConstructsGenerator(\n tree,\n {\n iac,\n },\n DEPENDENCIES,\n );\n\n await addWebsiteInfra(tree, {\n iac,\n websiteProjectName: fullyQualifiedName,\n scopeAlias,\n websiteContentPath: joinPathFragments('dist', websiteContentPath),\n websiteNameKebabCase,\n websiteNameClassName,\n });\n }\n\n const projectConfig = readProjectConfiguration(tree, fullyQualifiedName);\n const libraryRoot = projectConfig.root;\n const sharedShadcnStylesImport = relative(\n joinPathFragments(libraryRoot, 'src'),\n joinPathFragments(\n PACKAGES_DIR,\n SHARED_SHADCN_DIR,\n 'src',\n 'styles',\n 'globals.css',\n ),\n )\n .split(sep)\n .join('/');\n const sharedShadcnTsconfigRef = relative(\n joinPathFragments(tree.root, websiteContentPath),\n joinPathFragments(\n tree.root,\n PACKAGES_DIR,\n SHARED_SHADCN_DIR,\n 'tsconfig.json',\n ),\n )\n .split(sep)\n .join('/');\n const templateOptions = {\n ...schema,\n fullyQualifiedName,\n pkgMgrCmd: getPackageManagerDisplayCommands().exec,\n tailwind,\n tanstackRouter,\n scopeAlias,\n sharedShadcnStylesImport,\n };\n tree.delete(joinPathFragments(libraryRoot, 'src', 'app'));\n const appCommonTemplatePath = joinPathFragments(\n import.meta.dirname,\n './files/app/common',\n );\n const appTemplatePath = joinPathFragments(\n import.meta.dirname,\n `./files/app/${ux.toLowerCase()}`,\n );\n\n generateFiles(\n tree, // the virtual file system\n appCommonTemplatePath, // path to the file templates\n libraryRoot, // destination path of the files\n templateOptions, // config object to replace variable in file templates\n {\n // User-editable source - preserve any edits on re-run\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n generateFiles(\n tree, // the virtual file system\n appTemplatePath, // path to the file templates\n libraryRoot, // destination path of the files\n templateOptions, // config object to replace variable in file templates\n {\n // User-editable source - preserve any edits on re-run\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n if (tanstackRouter) {\n const routerCommonTemplatePath = joinPathFragments(\n import.meta.dirname,\n './files/tanstack-router/common',\n );\n const routerTemplatePath = joinPathFragments(\n import.meta.dirname,\n `./files/tanstack-router/${ux.toLowerCase()}`,\n );\n\n generateFiles(\n tree,\n routerCommonTemplatePath,\n libraryRoot,\n templateOptions,\n {\n // User-editable source (and the TanStack-managed route tree) - preserve on re-run\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n generateFiles(\n tree,\n routerTemplatePath,\n libraryRoot,\n templateOptions, // config object to replace variable in file templates\n {\n // User-editable source - preserve any edits on re-run\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n tree.delete(joinPathFragments(websiteContentPath, 'src', 'app.tsx'));\n }\n\n if (e2eTestRunner !== 'none') {\n const e2eFullyQualifiedName = `${fullyQualifiedName}-e2e`;\n const e2eRoot = readProjectConfiguration(tree, e2eFullyQualifiedName).root;\n generateFiles(\n tree, // the virtual file system\n joinPathFragments(import.meta.dirname, `./files/e2e/${e2eTestRunner}`), // path to the file templates\n e2eRoot, // destination path of the files\n { ...schema, ...names(fullyQualifiedName) },\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n await configureTsProject(\n tree,\n {\n fullyQualifiedName: e2eFullyQualifiedName,\n dir: e2eRoot,\n },\n DEPENDENCIES,\n );\n }\n const viteConfigPath = joinPathFragments(libraryRoot, 'vite.config.mts');\n\n if (tree.exists(viteConfigPath)) {\n // Add Tanstack Router import if enabled\n if (tanstackRouter) {\n await addDestructuredImport(\n tree,\n viteConfigPath,\n ['tanstackRouter'],\n '@tanstack/router-plugin/vite',\n );\n\n await addDestructuredImport(tree, viteConfigPath, ['resolve'], 'path');\n }\n\n // Add TailwindCSS import if enabled\n if (tailwind) {\n await addSingleImport(\n tree,\n viteConfigPath,\n 'tailwindcss',\n '@tailwindcss/vite',\n );\n }\n\n // Update build.outDir. The inferred `vite build` target writes here, so\n // point it at the bundle dir the website infrastructure consumes.\n const outDir = joinPathFragments(\n getRelativePathToRoot(tree, fullyQualifiedName),\n 'dist',\n websiteContentPath,\n 'bundle',\n );\n await applyGritQL(\n tree,\n viteConfigPath,\n `\\`build: { $bprops }\\` where { $bprops <: contains \\`outDir: $_\\` => \\`outDir: '${outDir}'\\` }`,\n );\n\n // Add plugins to the plugins array\n if (tanstackRouter) {\n // Prepend tanstackRouter (must be first plugin) — rewrite works for both single/multi-element\n await applyGritQL(\n tree,\n viteConfigPath,\n \"`plugins: [$items]` => `plugins: [tanstackRouter({ routesDirectory: resolve(__dirname, 'src/routes'), generatedRouteTree: resolve(__dirname, 'src/routeTree.gen.ts') }), $items]` where { $items <: within `defineConfig($_)`, $items <: not contains `tanstackRouter` }\",\n );\n }\n\n if (tailwind) {\n await applyGritQL(\n tree,\n viteConfigPath,\n '`plugins: [$items]` => `plugins: [$items, tailwindcss()]` where { $items <: within `defineConfig($_)`, $items <: not some `tailwindcss()` }',\n );\n }\n\n // Use Vite's native tsconfig paths resolution (replaces vite-tsconfig-paths).\n // `dedupe` forces a single copy of react/react-dom into the bundle: each\n // project declares its own react dependency, so without this a workspace\n // library's hoisted copy can produce a second React instance and the\n // \"Invalid hook call\" runtime crash.\n await applyGritQL(\n tree,\n viteConfigPath,\n \"or { `defineConfig(() => ({ $props }))` where { $props <: not some `resolve: $_`, $props += `resolve: { tsconfigPaths: true, dedupe: ['react', 'react-dom'] }` }, `defineConfig({ $props })` where { $props <: not some `resolve: $_`, $props += `resolve: { tsconfigPaths: true, dedupe: ['react', 'react-dom'] }` } }\",\n );\n\n // Add define: { global: {} } to the config (handles both callback and direct forms)\n await applyGritQL(\n tree,\n viteConfigPath,\n 'or { `defineConfig(() => ({ $props }))` where { $props <: not contains `define`, $props += `define: { global: {} }` }, `defineConfig({ $props })` where { $props <: not contains `define`, $props += `define: { global: {} }` } }',\n );\n }\n\n updateJson(\n tree,\n joinPathFragments(websiteContentPath, 'tsconfig.json'),\n (tsconfig) => ({\n ...tsconfig,\n compilerOptions: {\n ...tsconfig.compilerOptions,\n moduleResolution: 'Bundler',\n module: 'Preserve',\n },\n }),\n );\n const outDirToRootRelativePath = relative(\n joinPathFragments(tree.root, websiteContentPath),\n tree.root,\n );\n const distDir = joinPathFragments(\n outDirToRootRelativePath,\n 'dist',\n websiteContentPath,\n 'tsc',\n );\n updateJson(\n tree,\n joinPathFragments(websiteContentPath, 'tsconfig.app.json'),\n (tsconfig) => ({\n ...tsconfig,\n compilerOptions: {\n ...tsconfig.compilerOptions,\n outDir: distDir,\n tsBuildInfoFile: joinPathFragments(distDir, 'tsconfig.lib.tsbuildinfo'),\n lib: ['DOM'],\n },\n references:\n ux === 'shadcn'\n ? [\n ...(tsconfig.references ?? []).filter(\n (ref) => ref.path !== sharedShadcnTsconfigRef,\n ),\n {\n path: sharedShadcnTsconfigRef,\n },\n ]\n : tsconfig.references,\n }),\n );\n\n addTsDependencies(tree, DEPENDENCIES, { metadata, projectRoot: libraryRoot });\n\n // @nx/react's applicationGenerator seeds react/react-dom into the root\n // manifest. The website now declares its own pinned versions, so drop the\n // root copies: without catalogs (npm) the root's floating range resolves to\n // a different version than the website's pin, installing a second React and\n // producing the \"Invalid hook call\" runtime crash.\n removeDependenciesFromPackageJson(tree, ['react', 'react-dom'], []);\n\n await addGeneratorMetricsIfApplicable(tree, [\n REACT_WEBSITE_APP_GENERATOR_INFO,\n ]);\n\n // TanStack Router's vite plugin owns this website's route tree and rewrites it\n // in its own (unformatted) shape whenever the config is loaded — including when\n // Nx computes the project graph — so formatting it here would only make\n // generation non-idempotent. The vended biome config excludes `**/*.gen.*`, so\n // the workspace's own `format` target leaves it alone too.\n await formatFilesInSubtree(tree, undefined, {\n ignore: tanstackRouter\n ? [joinPathFragments(libraryRoot, 'src', 'routeTree.gen.ts')]\n : [],\n });\n // The generated vite.config.mts imports these, and Nx's inferred `@nx/vite`\n // plugin loads that config when computing the project graph — so they must be\n // installed even if the caller would otherwise prefer to defer.\n return () =>\n installDependencies(tree, schema.preferInstallDependencies, {\n languages: ['typescript'],\n ensureResolvable: [\n ...(tailwind ? (['@tailwindcss/vite'] as const) : []),\n ...(tanstackRouter ? (['@tanstack/router-plugin'] as const) : []),\n ],\n });\n}\nexport default tsReactWebsiteGenerator;\n"],"names":["generateFiles","joinPathFragments","names","OverwriteStrategy","readProjectConfiguration","removeDependenciesFromPackageJson","updateJson","updateProjectConfiguration","applicationGenerator","relative","sep","addTsDependencies","addDestructuredImport","addSingleImport","applyGritQL","declareDependencies","ownedElsewhere","formatFilesInSubtree","resolveIac","installDependencies","addGeneratorMetricsIfApplicable","kebabCase","toClassName","toKebabCase","getNpmScopePrefix","addGeneratorMetadata","getGeneratorInfo","sortObjectKeys","getRelativePathToRoot","getPackageManagerDisplayCommands","SHARED_CONSTRUCTS_DEPENDENCIES","sharedConstructsGenerator","PACKAGES_DIR","SHARED_SHADCN_DIR","SHADCN_DEPENDENCIES","sharedShadcnGenerator","addWebsiteInfra","WEBSITE_CONSTRUCTS_PY_DEPENDENCIES","configureTsProject","VITEST_DEPENDENCIES","DEPENDENCIES","ts","name","dev","root","when","m","ux","tanstackRouter","tailwind","py","SUPPORTED_UX_PROVIDERS","REACT_WEBSITE_APP_GENERATOR_INFO","filename","tsReactWebsiteGenerator","tree","schema","Error","npmScopePrefix","scopeAlias","websiteNameClassName","websiteNameKebabCase","fullyQualifiedName","websiteContentPath","directory","subDirectory","projectAlreadyExists","exists","e2eTestRunner","routing","linter","bundler","unitTestRunner","useProjectJson","style","addPlugin","nxJson","plugin","plugins","options","buildTargetName","serveTargetName","devTargetName","previewTargetName","serveStaticTargetName","typecheckTargetName","testTargetName","delete","projectConfiguration","targets","infra","iac","undefined","executor","metadata","description","exec","command","env","SRC_FILE","DEST_DIR","DEST_FILE","dependsOn","outputs","cwd","continuous","framework","dir","websiteProjectName","projectConfig","libraryRoot","sharedShadcnStylesImport","split","join","sharedShadcnTsconfigRef","templateOptions","pkgMgrCmd","appCommonTemplatePath","dirname","appTemplatePath","toLowerCase","overwriteStrategy","KeepExisting","routerCommonTemplatePath","routerTemplatePath","e2eFullyQualifiedName","e2eRoot","viteConfigPath","outDir","tsconfig","compilerOptions","moduleResolution","module","outDirToRootRelativePath","distDir","tsBuildInfoFile","lib","references","filter","ref","path","projectRoot","ignore","preferInstallDependencies","languages","ensureResolvable"],"mappings":"AAAA;;;CAGC,GACD,SACEA,aAAa,EACbC,iBAAiB,EACjBC,KAAK,EACLC,iBAAiB,EACjBC,wBAAwB,EACxBC,iCAAiC,EAEjCC,UAAU,EACVC,0BAA0B,QACrB,aAAa;AACpB,SAASC,oBAAoB,QAAQ,YAAY;AACjD,SAASC,QAAQ,EAAEC,GAAG,QAAQ,OAAO;AACrC,SAASC,iBAAiB,QAAQ,qCAAkC;AACpE,SACEC,qBAAqB,EACrBC,eAAe,EACfC,WAAW,QACN,wBAAqB;AAC5B,SACEC,mBAAmB,EACnBC,cAAc,QACT,0CAAuC;AAC9C,SAASC,oBAAoB,QAAQ,2BAAwB;AAC7D,SAASC,UAAU,QAAQ,wBAAqB;AAChD,SAASC,mBAAmB,QAAQ,4BAAyB;AA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sD;QAAU+C,aAAa/B;IAAY;IAE3E,uEAAuE;IACvE,0EAA0E;IAC1E,4EAA4E;IAC5E,4EAA4E;IAC5E,mDAAmD;IACnDzG,kCAAkCkD,MAAM;QAAC;QAAS;KAAY,EAAE,EAAE;IAElE,MAAMnC,gCAAgCmC,MAAM;QAC1CH;KACD;IAED,+EAA+E;IAC/E,gFAAgF;IAChF,wEAAwE;IACxE,+EAA+E;IAC/E,2DAA2D;IAC3D,MAAMnC,qBAAqBsC,MAAMqC,WAAW;QAC1CkD,QAAQ9F,iBACJ;YAAC/C,kBAAkB6G,aAAa,OAAO;SAAoB,GAC3D,EAAE;IACR;IACA,4EAA4E;IAC5E,8EAA8E;IAC9E,gEAAgE;IAChE,OAAO,IACL3F,oBAAoBoC,MAAMC,OAAOuF,yBAAyB,EAAE;YAC1DC,WAAW;gBAAC;aAAa;YACzBC,kBAAkB;mBACZhG,WAAY;oBAAC;iBAAoB,GAAa,EAAE;mBAChDD,iBAAkB;oBAAC;iBAA0B,GAAa,EAAE;aACjE;QACH;AACJ;AACA,eAAeM,wBAAwB"}
1
+ {"version":3,"sources":["../../../../../../../packages/nx-plugin/src/ts/react-website/app/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n generateFiles,\n joinPathFragments,\n names,\n OverwriteStrategy,\n readProjectConfiguration,\n removeDependenciesFromPackageJson,\n type Tree,\n updateJson,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { applicationGenerator } from '@nx/react';\nimport { relative, sep } from 'path';\nimport { addTsDependencies } from '../../../utils/add-dependencies';\nimport {\n addDestructuredImport,\n addSingleImport,\n applyGritQL,\n} from '../../../utils/ast';\nimport {\n declareDependencies,\n ownedElsewhere,\n} from '../../../utils/declared-dependencies';\nimport { formatFilesInSubtree } from '../../../utils/format';\nimport { resolveIac } from '../../../utils/iac';\nimport { installDependencies } from '../../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../../utils/metrics';\nimport { kebabCase, toClassName, toKebabCase } from '../../../utils/names';\nimport { getNpmScopePrefix } from '../../../utils/npm-scope';\nimport {\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n} from '../../../utils/nx';\nimport { sortObjectKeys } from '../../../utils/object';\nimport { getRelativePathToRoot } from '../../../utils/paths';\nimport { getPackageManagerDisplayCommands } from '../../../utils/pkg-manager';\nimport {\n SHARED_CONSTRUCTS_DEPENDENCIES,\n sharedConstructsGenerator,\n} from '../../../utils/shared-constructs';\nimport {\n type IacMetadata,\n PACKAGES_DIR,\n SHARED_SHADCN_DIR,\n} from '../../../utils/shared-constructs-constants';\nimport {\n SHADCN_DEPENDENCIES,\n sharedShadcnGenerator,\n} from '../../../utils/shared-shadcn';\nimport {\n addWebsiteInfra,\n WEBSITE_CONSTRUCTS_PY_DEPENDENCIES,\n} from '../../../utils/website-constructs/website-constructs';\nimport { configureTsProject } from '../../lib/ts-project-utils';\nimport { VITEST_DEPENDENCIES } from '../../lib/vitest';\n// typescript factory imports removed — now using GritQL for vite config transforms\nimport type {\n TsReactWebsiteGeneratorSchema,\n WebsiteInfraOption,\n} from './schema';\n\n/** The metadata this generator records, which its predicates read. */\nexport interface TsReactWebsiteMetadata extends IacMetadata {\n readonly ux: UxOption;\n readonly framework: string;\n readonly infra: WebsiteInfraOption;\n readonly tailwind: boolean;\n readonly tanstackRouter: boolean;\n}\n\n// Each entry names the branch it belongs to, so the same declaration drives both\n// adding and the version sync.\nexport const DEPENDENCIES = declareDependencies<TsReactWebsiteMetadata>()({\n ts: [\n { name: 'react' },\n { name: 'react-dom' },\n // Build/test tooling imported only from vite.config.mts stays at the root.\n { name: '@nx/react', dev: true, root: true },\n { name: '@vitest/ui', dev: true, root: true },\n {\n name: '@cloudscape-design/components',\n when: (m) => m.ux === 'cloudscape',\n },\n {\n name: '@cloudscape-design/board-components',\n when: (m) => m.ux === 'cloudscape',\n },\n {\n name: '@cloudscape-design/global-styles',\n when: (m) => m.ux === 'cloudscape',\n },\n // Shared shadcn components live in the common/shadcn package, but the\n // website's own generated components (e.g. the tanstack-router sidebar)\n // import lucide-react directly, so the website must declare it.\n {\n name: 'lucide-react',\n when: (m) => m.ux === 'shadcn' && m.tanstackRouter,\n },\n { name: 'tailwindcss', when: (m) => m.tailwind },\n {\n name: '@tailwindcss/vite',\n when: (m) => m.tailwind,\n dev: true,\n root: true,\n },\n { name: '@tanstack/react-router', when: (m) => m.tanstackRouter },\n {\n name: '@tanstack/router-plugin',\n when: (m) => m.tanstackRouter,\n dev: true,\n root: true,\n },\n {\n name: '@tanstack/router-generator',\n when: (m) => m.tanstackRouter,\n dev: true,\n root: true,\n },\n {\n name: '@tanstack/virtual-file-routes',\n when: (m) => m.tanstackRouter,\n dev: true,\n root: true,\n },\n {\n name: '@tanstack/router-utils',\n when: (m) => m.tanstackRouter,\n dev: true,\n root: true,\n },\n ...ownedElsewhere(SHADCN_DEPENDENCIES),\n ...ownedElsewhere(VITEST_DEPENDENCIES),\n ...ownedElsewhere(SHARED_CONSTRUCTS_DEPENDENCIES),\n ],\n py: ownedElsewhere(WEBSITE_CONSTRUCTS_PY_DEPENDENCIES),\n});\n\nexport const SUPPORTED_UX_PROVIDERS = ['none', 'cloudscape', 'shadcn'] as const;\n\nexport type UxOption = (typeof SUPPORTED_UX_PROVIDERS)[number];\n\nexport type Ux = UxOption;\n\nexport const REACT_WEBSITE_APP_GENERATOR_INFO: NxGeneratorInfo =\n getGeneratorInfo(import.meta.filename);\n\nexport async function tsReactWebsiteGenerator(\n tree: Tree,\n schema: TsReactWebsiteGeneratorSchema,\n) {\n const tailwind = schema.tailwind ?? true;\n const tanstackRouter = schema.tanstackRouter ?? true;\n const ux: Ux = schema.ux ?? 'shadcn';\n if (ux === 'shadcn' && !tailwind) {\n throw new Error('Shadcn requires TailwindCSS to be enabled.');\n }\n const npmScopePrefix = getNpmScopePrefix(tree);\n const scopeAlias = npmScopePrefix;\n const websiteNameClassName = toClassName(schema.name);\n const websiteNameKebabCase = toKebabCase(schema.name);\n const fullyQualifiedName = `${npmScopePrefix}${websiteNameKebabCase}`;\n // NB: interactive nx generator cli can pass empty string\n const websiteContentPath = joinPathFragments(\n schema.directory || '.',\n schema.subDirectory || websiteNameKebabCase,\n );\n\n const projectAlreadyExists = tree.exists(\n joinPathFragments(websiteContentPath, 'project.json'),\n );\n\n // TODO: consider exposing and supporting e2e tests\n const e2eTestRunner = 'none';\n\n if (!projectAlreadyExists) {\n await applicationGenerator(tree, {\n ...schema,\n name: fullyQualifiedName,\n directory: websiteContentPath,\n routing: false,\n e2eTestRunner,\n linter: 'none',\n bundler: 'vite',\n unitTestRunner: 'vitest',\n useProjectJson: true,\n style: 'css',\n // Register the @nx/vite and @nx/vitest plugins so build/serve/test\n // targets are inferred rather than emitting deprecated executor targets.\n addPlugin: true,\n });\n\n // Pin the inferred target names. The vite production build is exposed as\n // `bundle` (which produces the deployable artifact), leaving `build` as an\n // aggregator over lint/compile/test/bundle. vite's own typecheck is dropped\n // in favour of the tsc `compile`.\n updateJson(tree, 'nx.json', (nxJson) => {\n for (const plugin of nxJson.plugins ?? []) {\n if (typeof plugin === 'string') continue;\n if (plugin.plugin === '@nx/vite/plugin') {\n plugin.options = {\n ...plugin.options,\n buildTargetName: 'bundle',\n // Map both of vite's inferred dev-server targets onto `serve` so the\n // plugin doesn't emit a separate `dev`; we author our own `dev`\n // below running the local-dev vite mode.\n serveTargetName: 'serve',\n devTargetName: 'serve',\n previewTargetName: 'preview',\n serveStaticTargetName: 'serve-static',\n typecheckTargetName: 'vite:typecheck',\n };\n } else if (plugin.plugin === '@nx/vitest') {\n plugin.options = {\n ...plugin.options,\n testTargetName: 'test',\n };\n }\n }\n return nxJson;\n });\n\n // Replace with simpler sample source code\n tree.delete(joinPathFragments(websiteContentPath, 'src'));\n }\n\n const projectConfiguration = readProjectConfiguration(\n tree,\n fullyQualifiedName,\n );\n\n const targets = projectConfiguration.targets;\n\n const infra = schema.infra ?? 'cloudfront-s3';\n\n // Configure load-runtime-config target based on IaC provider (only when infra is not none)\n const iac = infra !== 'none' ? await resolveIac(tree, schema.iac) : undefined;\n\n if (iac === 'cdk') {\n targets['load-runtime-config'] = {\n executor: 'nx:run-commands',\n metadata: {\n description: `Load runtime config from your deployed stack for dev purposes. You must set your AWS CLI credentials whilst calling '${getPackageManagerDisplayCommands().exec} nx load-runtime-config ${fullyQualifiedName}'`,\n },\n options: {\n command: `aws s3 cp s3://\\`aws cloudformation describe-stacks --query \"Stacks[?starts_with(StackName, '${kebabCase(npmScopePrefix)}-')][].Outputs[] | [?contains(OutputKey, '${websiteNameClassName}WebsiteBucketName')].OutputValue\" --output text\\`/runtime-config.json \"{projectRoot}/public/runtime-config.json\"`,\n },\n };\n } else if (iac === 'terraform') {\n targets['load-runtime-config'] = {\n executor: 'nx:run-commands',\n metadata: {\n description:\n \"Load runtime config from most recently applied terraform env for dev purposes. Copies the runtime config from the Terraform dist directory to the website's public directory.\",\n },\n options: {\n command:\n 'node -e \"const fs=require(\\'fs\\');fs.mkdirSync(process.env.DEST_DIR,{recursive:true});fs.copyFileSync(process.env.SRC_FILE,process.env.DEST_FILE);\"',\n env: {\n SRC_FILE: 'dist/packages/common/terraform/runtime-config.json',\n DEST_DIR: `{projectRoot}/public`,\n DEST_FILE: `{projectRoot}/public/runtime-config.json`,\n },\n },\n };\n }\n\n if (!projectAlreadyExists) {\n targets['compile'] = {\n dependsOn: ['^build'],\n executor: 'nx:run-commands',\n outputs: ['{workspaceRoot}/dist/{projectRoot}/tsc'],\n options: {\n command: 'tsc --build tsconfig.app.json',\n cwd: '{projectRoot}',\n },\n };\n // bundle is the @nx/vite/plugin inferred `vite build` (writing to the\n // bundle dir configured in vite.config) — it produces the deployable\n // artifact. build aggregates lint/compile/test/bundle.\n targets['build'] = {\n dependsOn: ['lint', 'compile', 'test', 'bundle'],\n };\n\n // Run the website and its connected dependencies locally. Mirrors the\n // inferred `serve` target but with the local-dev vite mode.\n targets['dev'] = {\n executor: 'nx:run-commands',\n continuous: true,\n options: {\n command: 'vite --mode local-dev',\n cwd: '{projectRoot}',\n },\n };\n }\n\n projectConfiguration.targets = sortObjectKeys(targets);\n\n updateProjectConfiguration(tree, fullyQualifiedName, projectConfiguration);\n\n // Recorded here and read by the declaration's predicates, so the packages\n // added below are exactly the ones the version sync will own.\n const metadata: TsReactWebsiteMetadata = {\n ux,\n framework: 'react',\n infra,\n tailwind,\n tanstackRouter,\n // Undefined when no infrastructure was generated, so neither provider's\n // packages were added.\n ...(iac ? { iac } : {}),\n };\n addGeneratorMetadata(\n tree,\n projectConfiguration.name,\n REACT_WEBSITE_APP_GENERATOR_INFO,\n metadata,\n );\n\n await configureTsProject(\n tree,\n {\n dir: websiteContentPath,\n fullyQualifiedName,\n },\n DEPENDENCIES,\n );\n\n if (ux === 'shadcn') {\n await sharedShadcnGenerator(tree, DEPENDENCIES);\n }\n\n if (iac) {\n await sharedConstructsGenerator(\n tree,\n {\n iac,\n },\n DEPENDENCIES,\n );\n\n await addWebsiteInfra(tree, {\n iac,\n websiteProjectName: fullyQualifiedName,\n scopeAlias,\n websiteContentPath: joinPathFragments('dist', websiteContentPath),\n websiteNameKebabCase,\n websiteNameClassName,\n });\n }\n\n const projectConfig = readProjectConfiguration(tree, fullyQualifiedName);\n const libraryRoot = projectConfig.root;\n const sharedShadcnStylesImport = relative(\n joinPathFragments(libraryRoot, 'src'),\n joinPathFragments(\n PACKAGES_DIR,\n SHARED_SHADCN_DIR,\n 'src',\n 'styles',\n 'globals.css',\n ),\n )\n .split(sep)\n .join('/');\n const sharedShadcnTsconfigRef = relative(\n joinPathFragments(tree.root, websiteContentPath),\n joinPathFragments(\n tree.root,\n PACKAGES_DIR,\n SHARED_SHADCN_DIR,\n 'tsconfig.json',\n ),\n )\n .split(sep)\n .join('/');\n const templateOptions = {\n ...schema,\n fullyQualifiedName,\n pkgMgrCmd: getPackageManagerDisplayCommands().exec,\n tailwind,\n tanstackRouter,\n scopeAlias,\n sharedShadcnStylesImport,\n };\n tree.delete(joinPathFragments(libraryRoot, 'src', 'app'));\n const appCommonTemplatePath = joinPathFragments(\n import.meta.dirname,\n './files/app/common',\n );\n const appTemplatePath = joinPathFragments(\n import.meta.dirname,\n `./files/app/${ux.toLowerCase()}`,\n );\n\n generateFiles(\n tree, // the virtual file system\n appCommonTemplatePath, // path to the file templates\n libraryRoot, // destination path of the files\n templateOptions, // config object to replace variable in file templates\n {\n // User-editable source - preserve any edits on re-run\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n generateFiles(\n tree, // the virtual file system\n appTemplatePath, // path to the file templates\n libraryRoot, // destination path of the files\n templateOptions, // config object to replace variable in file templates\n {\n // User-editable source - preserve any edits on re-run\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n if (tanstackRouter) {\n const routerCommonTemplatePath = joinPathFragments(\n import.meta.dirname,\n './files/tanstack-router/common',\n );\n const routerTemplatePath = joinPathFragments(\n import.meta.dirname,\n `./files/tanstack-router/${ux.toLowerCase()}`,\n );\n\n generateFiles(\n tree,\n routerCommonTemplatePath,\n libraryRoot,\n templateOptions,\n {\n // User-editable source (and the TanStack-managed route tree) - preserve on re-run\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n generateFiles(\n tree,\n routerTemplatePath,\n libraryRoot,\n templateOptions, // config object to replace variable in file templates\n {\n // User-editable source - preserve any edits on re-run\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n tree.delete(joinPathFragments(websiteContentPath, 'src', 'app.tsx'));\n }\n\n if (e2eTestRunner !== 'none') {\n const e2eFullyQualifiedName = `${fullyQualifiedName}-e2e`;\n const e2eRoot = readProjectConfiguration(tree, e2eFullyQualifiedName).root;\n generateFiles(\n tree, // the virtual file system\n joinPathFragments(import.meta.dirname, `./files/e2e/${e2eTestRunner}`), // path to the file templates\n e2eRoot, // destination path of the files\n { ...schema, ...names(fullyQualifiedName) },\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n await configureTsProject(\n tree,\n {\n fullyQualifiedName: e2eFullyQualifiedName,\n dir: e2eRoot,\n },\n DEPENDENCIES,\n );\n }\n const viteConfigPath = joinPathFragments(libraryRoot, 'vite.config.mts');\n\n if (tree.exists(viteConfigPath)) {\n // Add Tanstack Router import if enabled\n if (tanstackRouter) {\n await addDestructuredImport(\n tree,\n viteConfigPath,\n ['tanstackRouter'],\n '@tanstack/router-plugin/vite',\n );\n\n await addDestructuredImport(tree, viteConfigPath, ['resolve'], 'path');\n }\n\n // Add TailwindCSS import if enabled\n if (tailwind) {\n await addSingleImport(\n tree,\n viteConfigPath,\n 'tailwindcss',\n '@tailwindcss/vite',\n );\n }\n\n // Update build.outDir. The inferred `vite build` target writes here, so\n // point it at the bundle dir the website infrastructure consumes.\n const outDir = joinPathFragments(\n getRelativePathToRoot(tree, fullyQualifiedName),\n 'dist',\n websiteContentPath,\n 'bundle',\n );\n await applyGritQL(\n tree,\n viteConfigPath,\n `\\`build: { $bprops }\\` where { $bprops <: contains \\`outDir: $_\\` => \\`outDir: '${outDir}'\\` }`,\n );\n\n // Add plugins to the plugins array\n if (tanstackRouter) {\n // Prepend tanstackRouter (must be first plugin) — rewrite works for both single/multi-element\n await applyGritQL(\n tree,\n viteConfigPath,\n \"`plugins: [$items]` => `plugins: [tanstackRouter({ routesDirectory: resolve(import.meta.dirname, 'src/routes'), generatedRouteTree: resolve(import.meta.dirname, 'src/routeTree.gen.ts') }), $items]` where { $items <: within `defineConfig($_)`, $items <: not contains `tanstackRouter` }\",\n );\n }\n\n if (tailwind) {\n await applyGritQL(\n tree,\n viteConfigPath,\n '`plugins: [$items]` => `plugins: [$items, tailwindcss()]` where { $items <: within `defineConfig($_)`, $items <: not some `tailwindcss()` }',\n );\n }\n\n // Use Vite's native tsconfig paths resolution (replaces vite-tsconfig-paths).\n // `dedupe` forces a single copy of react/react-dom into the bundle: each\n // project declares its own react dependency, so without this a workspace\n // library's hoisted copy can produce a second React instance and the\n // \"Invalid hook call\" runtime crash.\n await applyGritQL(\n tree,\n viteConfigPath,\n \"or { `defineConfig(() => ({ $props }))` where { $props <: not some `resolve: $_`, $props += `resolve: { tsconfigPaths: true, dedupe: ['react', 'react-dom'] }` }, `defineConfig({ $props })` where { $props <: not some `resolve: $_`, $props += `resolve: { tsconfigPaths: true, dedupe: ['react', 'react-dom'] }` } }\",\n );\n\n // Add define: { global: {} } to the config (handles both callback and direct forms)\n await applyGritQL(\n tree,\n viteConfigPath,\n 'or { `defineConfig(() => ({ $props }))` where { $props <: not contains `define`, $props += `define: { global: {} }` }, `defineConfig({ $props })` where { $props <: not contains `define`, $props += `define: { global: {} }` } }',\n );\n }\n\n updateJson(\n tree,\n joinPathFragments(websiteContentPath, 'tsconfig.json'),\n (tsconfig) => ({\n ...tsconfig,\n compilerOptions: {\n ...tsconfig.compilerOptions,\n moduleResolution: 'Bundler',\n module: 'Preserve',\n },\n }),\n );\n const outDirToRootRelativePath = relative(\n joinPathFragments(tree.root, websiteContentPath),\n tree.root,\n );\n const distDir = joinPathFragments(\n outDirToRootRelativePath,\n 'dist',\n websiteContentPath,\n 'tsc',\n );\n updateJson(\n tree,\n joinPathFragments(websiteContentPath, 'tsconfig.app.json'),\n (tsconfig) => ({\n ...tsconfig,\n compilerOptions: {\n ...tsconfig.compilerOptions,\n outDir: distDir,\n tsBuildInfoFile: joinPathFragments(distDir, 'tsconfig.lib.tsbuildinfo'),\n lib: ['DOM'],\n },\n references:\n ux === 'shadcn'\n ? [\n ...(tsconfig.references ?? []).filter(\n (ref) => ref.path !== sharedShadcnTsconfigRef,\n ),\n {\n path: sharedShadcnTsconfigRef,\n },\n ]\n : tsconfig.references,\n }),\n );\n\n addTsDependencies(tree, DEPENDENCIES, { metadata, projectRoot: libraryRoot });\n\n // @nx/react's applicationGenerator seeds react/react-dom into the root\n // manifest. The website now declares its own pinned versions, so drop the\n // root copies: without catalogs (npm) the root's floating range resolves to\n // a different version than the website's pin, installing a second React and\n // producing the \"Invalid hook call\" runtime crash.\n removeDependenciesFromPackageJson(tree, ['react', 'react-dom'], []);\n\n await addGeneratorMetricsIfApplicable(tree, [\n REACT_WEBSITE_APP_GENERATOR_INFO,\n ]);\n\n // TanStack Router's vite plugin owns this website's route tree and rewrites it\n // in its own (unformatted) shape whenever the config is loaded — including when\n // Nx computes the project graph — so formatting it here would only make\n // generation non-idempotent. The vended biome config excludes `**/*.gen.*`, so\n // the workspace's own `format` target leaves it alone too.\n await formatFilesInSubtree(tree, undefined, {\n ignore: tanstackRouter\n ? [joinPathFragments(libraryRoot, 'src', 'routeTree.gen.ts')]\n : [],\n });\n // The generated vite.config.mts imports these, and Nx's inferred `@nx/vite`\n // plugin loads that config when computing the project graph — so they must be\n // installed even if the caller would otherwise prefer to defer.\n return () =>\n installDependencies(tree, schema.preferInstallDependencies, {\n languages: ['typescript'],\n ensureResolvable: [\n ...(tailwind ? (['@tailwindcss/vite'] as const) : []),\n ...(tanstackRouter ? (['@tanstack/router-plugin'] as const) : []),\n ],\n });\n}\nexport default tsReactWebsiteGenerator;\n"],"names":["generateFiles","joinPathFragments","names","OverwriteStrategy","readProjectConfiguration","removeDependenciesFromPackageJson","updateJson","updateProjectConfiguration","applicationGenerator","relative","sep","addTsDependencies","addDestructuredImport","addSingleImport","applyGritQL","declareDependencies","ownedElsewhere","formatFilesInSubtree","resolveIac","installDependencies","addGeneratorMetricsIfApplicable","kebabCase","toClassName","toKebabCase","getNpmScopePrefix","addGeneratorMetadata","getGeneratorInfo","sortObjectKeys","getRelativePathToRoot","getPackageManagerDisplayCommands","SHARED_CONSTRUCTS_DEPENDENCIES","sharedConstructsGenerator","PACKAGES_DIR","SHARED_SHADCN_DIR","SHADCN_DEPENDENCIES","sharedShadcnGenerator","addWebsiteInfra","WEBSITE_CONSTRUCTS_PY_DEPENDENCIES","configureTsProject","VITEST_DEPENDENCIES","DEPENDENCIES","ts","name","dev","root","when","m","ux","tanstackRouter","tailwind","py","SUPPORTED_UX_PROVIDERS","REACT_WEBSITE_APP_GENERATOR_INFO","filename","tsReactWebsiteGenerator","tree","schema","Error","npmScopePrefix","scopeAlias","websiteNameClassName","websiteNameKebabCase","fullyQualifiedName","websiteContentPath","directory","subDirectory","projectAlreadyExists","exists","e2eTestRunner","routing","linter","bundler","unitTestRunner","useProjectJson","style","addPlugin","nxJson","plugin","plugins","options","buildTargetName","serveTargetName","devTargetName","previewTargetName","serveStaticTargetName","typecheckTargetName","testTargetName","delete","projectConfiguration","targets","infra","iac","undefined","executor","metadata","description","exec","command","env","SRC_FILE","DEST_DIR","DEST_FILE","dependsOn","outputs","cwd","continuous","framework","dir","websiteProjectName","projectConfig","libraryRoot","sharedShadcnStylesImport","split","join","sharedShadcnTsconfigRef","templateOptions","pkgMgrCmd","appCommonTemplatePath","dirname","appTemplatePath","toLowerCase","overwriteStrategy","KeepExisting","routerCommonTemplatePath","routerTemplatePath","e2eFullyQualifiedName","e2eRoot","viteConfigPath","outDir","tsconfig","compilerOptions","moduleResolution","module","outDirToRootRelativePath","distDir","tsBuildInfoFile","lib","references","filter","ref","path","projectRoot","ignore","preferInstallDependencies","languages","ensureResolvable"],"mappings":"AAAA;;;CAGC,GACD,SACEA,aAAa,EACbC,iBAAiB,EACjBC,KAAK,EACLC,iBAAiB,EACjBC,wBAAwB,EACxBC,iCAAiC,EAEjCC,UAAU,EACVC,0BAA0B,QACrB,aAAa;AACpB,SAASC,oBAAoB,QAAQ,YAAY;AACjD,SAASC,QAAQ,EAAEC,GAAG,QAAQ,OAAO;AACrC,SAASC,iBAAiB,QAAQ,qCAAkC;AACpE,SACEC,qBAAqB,EACrBC,eAAe,EACfC,WAAW,QACN,wBAAqB;AAC5B,SACEC,mBAAmB,EACnBC,cAAc,QACT,0CAAuC;AAC9C,SAASC,oBAAoB,QAAQ,2BAAwB;AAC7D,SAASC,UAAU,QAAQ,wBAAqB;AAChD,SAASC,mBAAmB,QAAQ,4BAAyB;AAC7D,SAASC,+BAA+B,QAAQ,4BAAyB;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EAAuE;IACvE,0EAA0E;IAC1E,4EAA4E;IAC5E,4EAA4E;IAC5E,mDAAmD;IACnDzG,kCAAkCkD,MAAM;QAAC;QAAS;KAAY,EAAE,EAAE;IAElE,MAAMnC,gCAAgCmC,MAAM;QAC1CH;KACD;IAED,+EAA+E;IAC/E,gFAAgF;IAChF,wEAAwE;IACxE,+EAA+E;IAC/E,2DAA2D;IAC3D,MAAMnC,qBAAqBsC,MAAMqC,WAAW;QAC1CkD,QAAQ9F,iBACJ;YAAC/C,kBAAkB6G,aAAa,OAAO;SAAoB,GAC3D,EAAE;IACR;IACA,4EAA4E;IAC5E,8EAA8E;IAC9E,gEAAgE;IAChE,OAAO,IACL3F,oBAAoBoC,MAAMC,OAAOuF,yBAAyB,EAAE;YAC1DC,WAAW;gBAAC;aAAa;YACzBC,kBAAkB;mBACZhG,WAAY;oBAAC;iBAAoB,GAAa,EAAE;mBAChDD,iBAAkB;oBAAC;iBAA0B,GAAa,EAAE;aACjE;QACH;AACJ;AACA,eAAeM,wBAAwB"}
@@ -96,7 +96,7 @@ import { withVersions } from "../versions.js";
96
96
  const entry = `{
97
97
  tsconfig: 'tsconfig.lib.json',
98
98
  input: '${opts.targetFilePath}',
99
- output: { file: '${outputFile}', format: 'cjs', inlineDynamicImports: true },
99
+ output: { file: '${outputFile}', format: 'cjs', codeSplitting: false },
100
100
  platform: '${opts.platform ?? 'node'}',
101
101
  ${external ? `external: [${external}],` : ''}
102
102
  }`;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/nx-plugin/src/utils/bundle/bundle.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n type ProjectConfiguration,\n type TargetConfiguration,\n type Tree,\n} from '@nx/devkit';\nimport { applyGritQL } from '../ast';\nimport {\n type DependencyDeclaration,\n forDependencies,\n type MustDeclare,\n} from '../declared-dependencies';\nimport { addDependenciesToPackageJson } from '../dependencies';\nimport {\n addDependencyToTargetIfNotPresent,\n normalizeTargetKeyOrder,\n} from '../nx';\nimport { getRelativePathToRoot } from '../paths';\nimport { type ITsDepVersion, withVersions } from '../versions';\n\n/** Dependencies a caller must declare to add a TypeScript bundle target. */\nexport const BUNDLE_DEPENDENCIES = [\n { name: 'rolldown' },\n] as const satisfies readonly { name: ITsDepVersion }[];\n\nexport interface AddPythonBundleTargetOptions {\n /**\n * Python platform\n * @default x86_64-manylinux_2_28\n */\n pythonPlatform?: 'x86_64-manylinux_2_28' | 'aarch64-manylinux_2_28';\n}\n\ninterface CreatePythonBundleTargetOptions\n extends Required<AddPythonBundleTargetOptions> {\n /**\n * Python package name\n */\n packageName: string;\n\n /**\n * Name of the bundle target, used for the outdir for the bundle\n */\n bundleTargetName: string;\n}\n\n/**\n * Create a target for bundling a python project\n */\nconst createPythonBundleTarget = ({\n packageName,\n pythonPlatform,\n bundleTargetName,\n}: CreatePythonBundleTargetOptions): TargetConfiguration => {\n return {\n cache: true,\n inputs: ['default', '^production'],\n executor: 'nx:run-commands',\n outputs: [`{workspaceRoot}/dist/{projectRoot}/${bundleTargetName}`],\n options: {\n commands: [\n `uv export --frozen --no-dev --no-editable --project {projectRoot} --package ${packageName} -o dist/{projectRoot}/${bundleTargetName}/requirements.txt`,\n `uv pip install -n --no-deps --no-installer-metadata --no-compile-bytecode --python-platform ${pythonPlatform} --target dist/{projectRoot}/${bundleTargetName} -r dist/{projectRoot}/${bundleTargetName}/requirements.txt`,\n ],\n parallel: false,\n },\n };\n};\n\n/**\n * Adds a bundle target to the given project if it does not exist, and updates the build target to depend on it\n */\nexport const addPythonBundleTarget = (\n project: ProjectConfiguration,\n opts?: AddPythonBundleTargetOptions,\n) => {\n if (!project.targets) {\n project.targets = {};\n }\n\n const pythonPlatform = opts?.pythonPlatform ?? 'x86_64-manylinux_2_28';\n const bundleTargetName =\n pythonPlatform === 'aarch64-manylinux_2_28' ? 'bundle-arm' : 'bundle-x86';\n\n if (!project.targets?.[bundleTargetName]) {\n project.targets[bundleTargetName] = normalizeTargetKeyOrder({\n ...createPythonBundleTarget({\n packageName: project.name,\n pythonPlatform,\n bundleTargetName,\n }),\n dependsOn: ['compile'],\n });\n }\n\n // Add a \"bundle\" target which depends on either bundle-arm or bundle-x86 (or both)\n addDependencyToTargetIfNotPresent(project, 'bundle', bundleTargetName);\n addDependencyToTargetIfNotPresent(project, 'build', 'bundle');\n\n return {\n bundleTargetName,\n bundleOutputDir: joinPathFragments('dist', project.root, bundleTargetName),\n };\n};\n\nexport interface AddTypeScriptBundleTargetOptions {\n /**\n * Path to the target file relative to the project dir\n */\n targetFilePath: string;\n\n /**\n * Sub directory to write bundled index.js file to (if any)\n * Outputs to dist/{projectRoot}/bundle/{bundleOutputDir}/index.js\n */\n bundleOutputDir?: string;\n\n /**\n * Modules to omit from the bundle and treat as external\n */\n external?: (string | RegExp)[];\n\n /**\n * Target platform for the bundle\n * @default 'node'\n */\n platform?: 'node' | 'browser' | 'neutral';\n}\n\n/**\n * Add a TypeScript bundle target using rolldown\n */\nexport const addTypeScriptBundleTarget = async <\n const D extends DependencyDeclaration,\n>(\n tree: Tree,\n project: ProjectConfiguration,\n opts: AddTypeScriptBundleTargetOptions,\n declaration: D & MustDeclare<typeof BUNDLE_DEPENDENCIES, D>,\n) => {\n project.targets ??= {};\n\n // Generate empty rolldown config if it doesn't exist\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'ts'),\n project.root,\n {},\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n // Add the bundle target\n if (!project.targets.bundle) {\n project.targets.bundle = normalizeTargetKeyOrder({\n cache: true,\n outputs: [`{workspaceRoot}/dist/{projectRoot}/bundle`],\n executor: 'nx:run-commands',\n options: {\n command: 'rolldown -c rolldown.config.ts',\n cwd: '{projectRoot}',\n },\n dependsOn: ['compile'],\n });\n }\n\n // Add bundle to the build target\n addDependencyToTargetIfNotPresent(project, 'build', 'bundle');\n\n const rolldownConfigPath = joinPathFragments(\n project.root,\n 'rolldown.config.ts',\n );\n\n const outputFile = joinPathFragments(\n getRelativePathToRoot(tree, project.name),\n 'dist',\n project.root,\n 'bundle',\n opts.bundleOutputDir ?? '.',\n 'index.js',\n );\n\n const external = opts.external?.length\n ? opts.external\n .map((ext) =>\n typeof ext === 'string' ? `'${ext}'` : `/${ext.source}/`,\n )\n .join(', ')\n : '';\n\n const entry = `{\n tsconfig: 'tsconfig.lib.json',\n input: '${opts.targetFilePath}',\n output: { file: '${outputFile}', format: 'cjs', inlineDynamicImports: true },\n platform: '${opts.platform ?? 'node'}',\n ${external ? `external: [${external}],` : ''}\n }`;\n\n // Use GritQL to append the config entry to the defineConfig array.\n // First try the non-empty array case using the accumulate (+=) operator,\n // with an idempotency guard that checks the input path is not already present.\n const appended = await applyGritQL(\n tree,\n rolldownConfigPath,\n `\\`defineConfig([$items])\\` where { $items <: not contains \\`'${opts.targetFilePath}'\\`, $items += \", ${entry}\" }`,\n );\n\n if (!appended) {\n // Empty array — GritQL's += cannot accumulate into an empty list, so we\n // first insert a placeholder to make the array non-empty, then replace\n // the placeholder with the real entry via += (which handles regex\n // literals that are invalid inside GritQL backtick snippets).\n const inserted = await applyGritQL(\n tree,\n rolldownConfigPath,\n `\\`defineConfig([])\\` => \\`defineConfig([__PLACEHOLDER__])\\``,\n );\n if (inserted) {\n await applyGritQL(\n tree,\n rolldownConfigPath,\n `\\`defineConfig([$items])\\` where { $items <: \\`__PLACEHOLDER__\\` => ., $items += \"${entry}\" }`,\n );\n }\n }\n\n addDependenciesToPackageJson(\n tree,\n {},\n withVersions(forDependencies<typeof BUNDLE_DEPENDENCIES>(declaration), [\n 'rolldown',\n ]),\n );\n};\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","applyGritQL","forDependencies","addDependenciesToPackageJson","addDependencyToTargetIfNotPresent","normalizeTargetKeyOrder","getRelativePathToRoot","withVersions","BUNDLE_DEPENDENCIES","name","createPythonBundleTarget","packageName","pythonPlatform","bundleTargetName","cache","inputs","executor","outputs","options","commands","parallel","addPythonBundleTarget","project","opts","targets","dependsOn","bundleOutputDir","root","addTypeScriptBundleTarget","tree","declaration","dirname","overwriteStrategy","KeepExisting","bundle","command","cwd","rolldownConfigPath","outputFile","external","length","map","ext","source","join","entry","targetFilePath","platform","appended","inserted"],"mappings":"AAAA;;;CAGC,GAED,SACEA,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,QAIZ,aAAa;AACpB,SAASC,WAAW,QAAQ,YAAS;AACrC,SAEEC,eAAe,QAEV,8BAA2B;AAClC,SAASC,4BAA4B,QAAQ,qBAAkB;AAC/D,SACEC,iCAAiC,EACjCC,uBAAuB,QAClB,WAAQ;AACf,SAASC,qBAAqB,QAAQ,cAAW;AACjD,SAA6BC,YAAY,QAAQ,iBAAc;AAE/D,0EAA0E,GAC1E,OAAO,MAAMC,sBAAsB;IACjC;QAAEC,MAAM;IAAW;CACpB,CAAuD;AAuBxD;;CAEC,GACD,MAAMC,2BAA2B,CAAC,EAChCC,WAAW,EACXC,cAAc,EACdC,gBAAgB,EACgB;IAChC,OAAO;QACLC,OAAO;QACPC,QAAQ;YAAC;YAAW;SAAc;QAClCC,UAAU;QACVC,SAAS;YAAC,CAAC,mCAAmC,EAAEJ,kBAAkB;SAAC;QACnEK,SAAS;YACPC,UAAU;gBACR,CAAC,4EAA4E,EAAER,YAAY,uBAAuB,EAAEE,iBAAiB,iBAAiB,CAAC;gBACvJ,CAAC,4FAA4F,EAAED,eAAe,6BAA6B,EAAEC,iBAAiB,uBAAuB,EAAEA,iBAAiB,iBAAiB,CAAC;aAC3N;YACDO,UAAU;QACZ;IACF;AACF;AAEA;;CAEC,GACD,OAAO,MAAMC,wBAAwB,CACnCC,SACAC;IAEA,IAAI,CAACD,QAAQE,OAAO,EAAE;QACpBF,QAAQE,OAAO,GAAG,CAAC;IACrB;IAEA,MAAMZ,iBAAiBW,MAAMX,kBAAkB;IAC/C,MAA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B,QAAQ,CACVE,GAAG,CAAC,CAACC,MACJ,OAAOA,QAAQ,WAAW,CAAC,CAAC,EAAEA,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,EAAEA,IAAIC,MAAM,CAAC,CAAC,CAAC,EAEzDC,IAAI,CAAC,QACR;IAEJ,MAAMC,QAAQ,CAAC;;YAEL,EAAEtB,KAAKuB,cAAc,CAAC;qBACb,EAAER,WAAW;eACnB,EAAEf,KAAKwB,QAAQ,IAAI,OAAO;IACrC,EAAER,WAAW,CAAC,WAAW,EAAEA,SAAS,EAAE,CAAC,GAAG,GAAG;GAC9C,CAAC;IAEF,mEAAmE;IACnE,yEAAyE;IACzE,+EAA+E;IAC/E,MAAMS,WAAW,MAAM/C,YACrB4B,MACAQ,oBACA,CAAC,6DAA6D,EAAEd,KAAKuB,cAAc,CAAC,kBAAkB,EAAED,MAAM,GAAG,CAAC;IAGpH,IAAI,CAACG,UAAU;QACb,wEAAwE;QACxE,uEAAuE;QACvE,kEAAkE;QAClE,8DAA8D;QAC9D,MAAMC,WAAW,MAAMhD,YACrB4B,MACAQ,oBACA,CAAC,2DAA2D,CAAC;QAE/D,IAAIY,UAAU;YACZ,MAAMhD,YACJ4B,MACAQ,oBACA,CAAC,kFAAkF,EAAEQ,MAAM,GAAG,CAAC;QAEnG;IACF;IAEA1C,6BACE0B,MACA,CAAC,GACDtB,aAAaL,gBAA4C4B,cAAc;QACrE;KACD;AAEL,EAAE"}
1
+ {"version":3,"sources":["../../../../../../packages/nx-plugin/src/utils/bundle/bundle.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n type ProjectConfiguration,\n type TargetConfiguration,\n type Tree,\n} from '@nx/devkit';\nimport { applyGritQL } from '../ast';\nimport {\n type DependencyDeclaration,\n forDependencies,\n type MustDeclare,\n} from '../declared-dependencies';\nimport { addDependenciesToPackageJson } from '../dependencies';\nimport {\n addDependencyToTargetIfNotPresent,\n normalizeTargetKeyOrder,\n} from '../nx';\nimport { getRelativePathToRoot } from '../paths';\nimport { type ITsDepVersion, withVersions } from '../versions';\n\n/** Dependencies a caller must declare to add a TypeScript bundle target. */\nexport const BUNDLE_DEPENDENCIES = [\n { name: 'rolldown' },\n] as const satisfies readonly { name: ITsDepVersion }[];\n\nexport interface AddPythonBundleTargetOptions {\n /**\n * Python platform\n * @default x86_64-manylinux_2_28\n */\n pythonPlatform?: 'x86_64-manylinux_2_28' | 'aarch64-manylinux_2_28';\n}\n\ninterface CreatePythonBundleTargetOptions\n extends Required<AddPythonBundleTargetOptions> {\n /**\n * Python package name\n */\n packageName: string;\n\n /**\n * Name of the bundle target, used for the outdir for the bundle\n */\n bundleTargetName: string;\n}\n\n/**\n * Create a target for bundling a python project\n */\nconst createPythonBundleTarget = ({\n packageName,\n pythonPlatform,\n bundleTargetName,\n}: CreatePythonBundleTargetOptions): TargetConfiguration => {\n return {\n cache: true,\n inputs: ['default', '^production'],\n executor: 'nx:run-commands',\n outputs: [`{workspaceRoot}/dist/{projectRoot}/${bundleTargetName}`],\n options: {\n commands: [\n `uv export --frozen --no-dev --no-editable --project {projectRoot} --package ${packageName} -o dist/{projectRoot}/${bundleTargetName}/requirements.txt`,\n `uv pip install -n --no-deps --no-installer-metadata --no-compile-bytecode --python-platform ${pythonPlatform} --target dist/{projectRoot}/${bundleTargetName} -r dist/{projectRoot}/${bundleTargetName}/requirements.txt`,\n ],\n parallel: false,\n },\n };\n};\n\n/**\n * Adds a bundle target to the given project if it does not exist, and updates the build target to depend on it\n */\nexport const addPythonBundleTarget = (\n project: ProjectConfiguration,\n opts?: AddPythonBundleTargetOptions,\n) => {\n if (!project.targets) {\n project.targets = {};\n }\n\n const pythonPlatform = opts?.pythonPlatform ?? 'x86_64-manylinux_2_28';\n const bundleTargetName =\n pythonPlatform === 'aarch64-manylinux_2_28' ? 'bundle-arm' : 'bundle-x86';\n\n if (!project.targets?.[bundleTargetName]) {\n project.targets[bundleTargetName] = normalizeTargetKeyOrder({\n ...createPythonBundleTarget({\n packageName: project.name,\n pythonPlatform,\n bundleTargetName,\n }),\n dependsOn: ['compile'],\n });\n }\n\n // Add a \"bundle\" target which depends on either bundle-arm or bundle-x86 (or both)\n addDependencyToTargetIfNotPresent(project, 'bundle', bundleTargetName);\n addDependencyToTargetIfNotPresent(project, 'build', 'bundle');\n\n return {\n bundleTargetName,\n bundleOutputDir: joinPathFragments('dist', project.root, bundleTargetName),\n };\n};\n\nexport interface AddTypeScriptBundleTargetOptions {\n /**\n * Path to the target file relative to the project dir\n */\n targetFilePath: string;\n\n /**\n * Sub directory to write bundled index.js file to (if any)\n * Outputs to dist/{projectRoot}/bundle/{bundleOutputDir}/index.js\n */\n bundleOutputDir?: string;\n\n /**\n * Modules to omit from the bundle and treat as external\n */\n external?: (string | RegExp)[];\n\n /**\n * Target platform for the bundle\n * @default 'node'\n */\n platform?: 'node' | 'browser' | 'neutral';\n}\n\n/**\n * Add a TypeScript bundle target using rolldown\n */\nexport const addTypeScriptBundleTarget = async <\n const D extends DependencyDeclaration,\n>(\n tree: Tree,\n project: ProjectConfiguration,\n opts: AddTypeScriptBundleTargetOptions,\n declaration: D & MustDeclare<typeof BUNDLE_DEPENDENCIES, D>,\n) => {\n project.targets ??= {};\n\n // Generate empty rolldown config if it doesn't exist\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'ts'),\n project.root,\n {},\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n // Add the bundle target\n if (!project.targets.bundle) {\n project.targets.bundle = normalizeTargetKeyOrder({\n cache: true,\n outputs: [`{workspaceRoot}/dist/{projectRoot}/bundle`],\n executor: 'nx:run-commands',\n options: {\n command: 'rolldown -c rolldown.config.ts',\n cwd: '{projectRoot}',\n },\n dependsOn: ['compile'],\n });\n }\n\n // Add bundle to the build target\n addDependencyToTargetIfNotPresent(project, 'build', 'bundle');\n\n const rolldownConfigPath = joinPathFragments(\n project.root,\n 'rolldown.config.ts',\n );\n\n const outputFile = joinPathFragments(\n getRelativePathToRoot(tree, project.name),\n 'dist',\n project.root,\n 'bundle',\n opts.bundleOutputDir ?? '.',\n 'index.js',\n );\n\n const external = opts.external?.length\n ? opts.external\n .map((ext) =>\n typeof ext === 'string' ? `'${ext}'` : `/${ext.source}/`,\n )\n .join(', ')\n : '';\n\n const entry = `{\n tsconfig: 'tsconfig.lib.json',\n input: '${opts.targetFilePath}',\n output: { file: '${outputFile}', format: 'cjs', codeSplitting: false },\n platform: '${opts.platform ?? 'node'}',\n ${external ? `external: [${external}],` : ''}\n }`;\n\n // Use GritQL to append the config entry to the defineConfig array.\n // First try the non-empty array case using the accumulate (+=) operator,\n // with an idempotency guard that checks the input path is not already present.\n const appended = await applyGritQL(\n tree,\n rolldownConfigPath,\n `\\`defineConfig([$items])\\` where { $items <: not contains \\`'${opts.targetFilePath}'\\`, $items += \", ${entry}\" }`,\n );\n\n if (!appended) {\n // Empty array — GritQL's += cannot accumulate into an empty list, so we\n // first insert a placeholder to make the array non-empty, then replace\n // the placeholder with the real entry via += (which handles regex\n // literals that are invalid inside GritQL backtick snippets).\n const inserted = await applyGritQL(\n tree,\n rolldownConfigPath,\n `\\`defineConfig([])\\` => \\`defineConfig([__PLACEHOLDER__])\\``,\n );\n if (inserted) {\n await applyGritQL(\n tree,\n rolldownConfigPath,\n `\\`defineConfig([$items])\\` where { $items <: \\`__PLACEHOLDER__\\` => ., $items += \"${entry}\" }`,\n );\n }\n }\n\n addDependenciesToPackageJson(\n tree,\n {},\n withVersions(forDependencies<typeof BUNDLE_DEPENDENCIES>(declaration), [\n 'rolldown',\n ]),\n );\n};\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","applyGritQL","forDependencies","addDependenciesToPackageJson","addDependencyToTargetIfNotPresent","normalizeTargetKeyOrder","getRelativePathToRoot","withVersions","BUNDLE_DEPENDENCIES","name","createPythonBundleTarget","packageName","pythonPlatform","bundleTargetName","cache","inputs","executor","outputs","options","commands","parallel","addPythonBundleTarget","project","opts","targets","dependsOn","bundleOutputDir","root","addTypeScriptBundleTarget","tree","declaration","dirname","overwriteStrategy","KeepExisting","bundle","command","cwd","rolldownConfigPath","outputFile","external","length","map","ext","source","join","entry","targetFilePath","platform","appended","inserted"],"mappings":"AAAA;;;CAGC,GAED,SACEA,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,QAIZ,aAAa;AACpB,SAASC,WAAW,QAAQ,YAAS;AACrC,SAEEC,eAAe,QAEV,8BAA2B;AAClC,SAASC,4BAA4B,QAAQ,qBAAkB;AAC/D,SACEC,iCAAiC,EACjCC,uBAAuB,QAClB,WAAQ;AACf,SAASC,qBAAqB,QAAQ,cAAW;AACjD,SAA6BC,YAAY,QAAQ,iBAAc;AAE/D,0EAA0E,GAC1E,OAAO,MAAMC,sBAAsB;IACjC;QAAEC,MAAM;IAAW;CACpB,CAAuD;AAuBxD;;CAEC,GACD,MAAMC,2BAA2B,CAAC,EAChCC,WAAW,EACXC,cAAc,EACdC,gBAAgB,EACgB;IAChC,OAAO;QACLC,OAAO;QACPC,QAAQ;YAAC;YAAW;SAAc;QAClCC,UAAU;QACVC,SAAS;YAAC,CAAC,mCAAmC,EAAEJ,kBAAkB;SAAC;QACnEK,SAAS;YACPC,UAAU;gBACR,CAAC,4EAA4E,EAAER,YAAY,uBAAuB,EAAEE,iBAAiB,iBAAiB,CAAC;gBACvJ,CAAC,4FAA4F,EAAED,eAAe,6BAA6B,EAAEC,iBAAiB,uBAAuB,EAAEA,iBAAiB,iBAAiB,CAAC;aAC3N;YACDO,UAAU;QACZ;IACF;AACF;AAEA;;CAEC,GACD,OAAO,MAAMC,wBAAwB,CACnCC,SACAC;IAEA,IAAI,CAACD,QAAQE,OAAO,EAAE;QACpBF,QAAQE,OAAO,GAAG,CAAC;IACrB;IAEA,MAAMZ,iBAAiBW,MAAMX,kBAAkB;IAC/C,MAAMC,mBACJD,mBAAmB,2BAA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