@_linked/cli 1.46.2 → 1.47.0
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.
- package/CHANGELOG.md +107 -0
- package/README.md +48 -36
- package/hooks/drift.cjs +169 -0
- package/hooks/git-hook.cjs +170 -0
- package/hooks/hook-shim.cjs +63 -0
- package/hooks/lock-at-rest.cjs +268 -0
- package/hooks/manifests.cjs +216 -0
- package/hooks/platform.cjs +25 -0
- package/lib/esm/app-release/build-backend.d.ts.map +1 -1
- package/lib/esm/app-release/build-backend.js +2 -1
- package/lib/esm/app-release/build-backend.js.map +1 -1
- package/lib/esm/cli-methods.d.ts.map +1 -1
- package/lib/esm/cli-methods.js +166 -150
- package/lib/esm/cli-methods.js.map +1 -1
- package/lib/esm/cli.js +20 -22
- package/lib/esm/cli.js.map +1 -1
- package/lib/esm/commands/build-app.d.ts.map +1 -1
- package/lib/esm/commands/build-app.js +2 -1
- package/lib/esm/commands/build-app.js.map +1 -1
- package/lib/esm/commands/build-package.d.ts.map +1 -1
- package/lib/esm/commands/build-package.js +6 -2
- package/lib/esm/commands/build-package.js.map +1 -1
- package/lib/esm/commands/localize.d.ts +9 -15
- package/lib/esm/commands/localize.d.ts.map +1 -1
- package/lib/esm/commands/localize.js +43 -74
- package/lib/esm/commands/localize.js.map +1 -1
- package/lib/esm/commands/setup-publish.d.ts.map +1 -1
- package/lib/esm/commands/setup-publish.js +22 -15
- package/lib/esm/commands/setup-publish.js.map +1 -1
- package/lib/esm/commands/start.d.ts +8 -0
- package/lib/esm/commands/start.d.ts.map +1 -1
- package/lib/esm/commands/start.js +20 -8
- package/lib/esm/commands/start.js.map +1 -1
- package/lib/esm/installed-packages.d.ts +5 -13
- package/lib/esm/installed-packages.d.ts.map +1 -1
- package/lib/esm/installed-packages.js +5 -38
- package/lib/esm/installed-packages.js.map +1 -1
- package/lib/esm/lifecycle.d.ts +35 -22
- package/lib/esm/lifecycle.d.ts.map +1 -1
- package/lib/esm/lifecycle.js +62 -36
- package/lib/esm/lifecycle.js.map +1 -1
- package/lib/esm/localize/adopt.d.ts +5 -5
- package/lib/esm/localize/adopt.d.ts.map +1 -1
- package/lib/esm/localize/adopt.js +46 -55
- package/lib/esm/localize/adopt.js.map +1 -1
- package/lib/esm/localize/app-root.d.ts +16 -0
- package/lib/esm/localize/app-root.d.ts.map +1 -0
- package/lib/esm/localize/app-root.js +94 -0
- package/lib/esm/localize/app-root.js.map +1 -0
- package/lib/esm/localize/app-setup.d.ts +21 -0
- package/lib/esm/localize/app-setup.d.ts.map +1 -0
- package/lib/esm/localize/app-setup.js +178 -0
- package/lib/esm/localize/app-setup.js.map +1 -0
- package/lib/esm/localize/delocalize.d.ts.map +1 -1
- package/lib/esm/localize/delocalize.js +169 -104
- package/lib/esm/localize/delocalize.js.map +1 -1
- package/lib/esm/localize/drift-hook.d.ts +18 -0
- package/lib/esm/localize/drift-hook.d.ts.map +1 -0
- package/lib/esm/localize/drift-hook.js +37 -0
- package/lib/esm/localize/drift-hook.js.map +1 -0
- package/lib/esm/localize/drift.d.ts +36 -0
- package/lib/esm/localize/drift.d.ts.map +1 -0
- package/lib/esm/localize/drift.js +34 -0
- package/lib/esm/localize/drift.js.map +1 -0
- package/lib/esm/localize/errors.d.ts +14 -8
- package/lib/esm/localize/errors.d.ts.map +1 -1
- package/lib/esm/localize/errors.js +14 -8
- package/lib/esm/localize/errors.js.map +1 -1
- package/lib/esm/localize/fsops.d.ts +11 -27
- package/lib/esm/localize/fsops.d.ts.map +1 -1
- package/lib/esm/localize/fsops.js +40 -115
- package/lib/esm/localize/fsops.js.map +1 -1
- package/lib/esm/localize/git-hooks.d.ts +33 -0
- package/lib/esm/localize/git-hooks.d.ts.map +1 -0
- package/lib/esm/localize/git-hooks.js +146 -0
- package/lib/esm/localize/git-hooks.js.map +1 -0
- package/lib/esm/localize/hook-module.d.ts +6 -0
- package/lib/esm/localize/hook-module.d.ts.map +1 -0
- package/lib/esm/localize/hook-module.js +37 -0
- package/lib/esm/localize/hook-module.js.map +1 -0
- package/lib/esm/localize/index.d.ts +14 -15
- package/lib/esm/localize/index.d.ts.map +1 -1
- package/lib/esm/localize/index.js +8 -9
- package/lib/esm/localize/index.js.map +1 -1
- package/lib/esm/localize/list.d.ts +6 -10
- package/lib/esm/localize/list.d.ts.map +1 -1
- package/lib/esm/localize/list.js +49 -189
- package/lib/esm/localize/list.js.map +1 -1
- package/lib/esm/localize/localize.d.ts +46 -62
- package/lib/esm/localize/localize.d.ts.map +1 -1
- package/lib/esm/localize/localize.js +411 -285
- package/lib/esm/localize/localize.js.map +1 -1
- package/lib/esm/localize/members.d.ts +13 -0
- package/lib/esm/localize/members.d.ts.map +1 -0
- package/lib/esm/localize/members.js +46 -0
- package/lib/esm/localize/members.js.map +1 -0
- package/lib/esm/localize/resolve.d.ts +1 -2
- package/lib/esm/localize/resolve.d.ts.map +1 -1
- package/lib/esm/localize/resolve.js +3 -5
- package/lib/esm/localize/resolve.js.map +1 -1
- package/lib/esm/localize/run.d.ts +1 -0
- package/lib/esm/localize/run.d.ts.map +1 -1
- package/lib/esm/localize/run.js +11 -6
- package/lib/esm/localize/run.js.map +1 -1
- package/lib/esm/localize/setup-lockfile.d.ts +13 -0
- package/lib/esm/localize/setup-lockfile.d.ts.map +1 -0
- package/lib/esm/localize/setup-lockfile.js +80 -0
- package/lib/esm/localize/setup-lockfile.js.map +1 -0
- package/lib/esm/utils/createPackageLocation.d.ts +4 -13
- package/lib/esm/utils/createPackageLocation.d.ts.map +1 -1
- package/lib/esm/utils/createPackageLocation.js +12 -21
- package/lib/esm/utils/createPackageLocation.js.map +1 -1
- package/lib/esm/utils/packageSetup.d.ts +5 -2
- package/lib/esm/utils/packageSetup.d.ts.map +1 -1
- package/lib/esm/utils/packageSetup.js +9 -3
- package/lib/esm/utils/packageSetup.js.map +1 -1
- package/lib/esm/utils/platform.d.ts +24 -0
- package/lib/esm/utils/platform.d.ts.map +1 -0
- package/lib/esm/utils/platform.js +62 -0
- package/lib/esm/utils/platform.js.map +1 -0
- package/lib/esm/utils/shapeReferences.d.ts.map +1 -1
- package/lib/esm/utils/shapeReferences.js +3 -2
- package/lib/esm/utils/shapeReferences.js.map +1 -1
- package/lib/esm/utils/spawn.d.ts +65 -0
- package/lib/esm/utils/spawn.d.ts.map +1 -0
- package/lib/esm/utils/spawn.js +181 -0
- package/lib/esm/utils/spawn.js.map +1 -0
- package/lib/esm/utils.d.ts.map +1 -1
- package/lib/esm/utils.js +19 -5
- package/lib/esm/utils.js.map +1 -1
- package/lib/esm/vite-config.d.ts +5 -12
- package/lib/esm/vite-config.d.ts.map +1 -1
- package/lib/esm/vite-config.js +41 -33
- package/lib/esm/vite-config.js.map +1 -1
- package/package.json +4 -3
- package/lib/esm/localize/ensure.d.ts +0 -44
- package/lib/esm/localize/ensure.d.ts.map +0 -1
- package/lib/esm/localize/ensure.js +0 -151
- package/lib/esm/localize/ensure.js.map +0 -1
- package/lib/esm/localize/manifest.d.ts +0 -63
- package/lib/esm/localize/manifest.d.ts.map +0 -1
- package/lib/esm/localize/manifest.js +0 -133
- package/lib/esm/localize/manifest.js.map +0 -1
- package/lib/esm/localize/one-copy-hook.d.ts +0 -16
- package/lib/esm/localize/one-copy-hook.d.ts.map +0 -1
- package/lib/esm/localize/one-copy-hook.js +0 -20
- package/lib/esm/localize/one-copy-hook.js.map +0 -1
- package/lib/esm/localize/provided.d.ts +0 -28
- package/lib/esm/localize/provided.d.ts.map +0 -1
- package/lib/esm/localize/provided.js +0 -89
- package/lib/esm/localize/provided.js.map +0 -1
- package/lib/esm/localize/prune.d.ts +0 -182
- package/lib/esm/localize/prune.d.ts.map +0 -1
- package/lib/esm/localize/prune.js +0 -703
- package/lib/esm/localize/prune.js.map +0 -1
- package/lib/esm/localize/relink.d.ts +0 -13
- package/lib/esm/localize/relink.d.ts.map +0 -1
- package/lib/esm/localize/relink.js +0 -181
- package/lib/esm/localize/relink.js.map +0 -1
- package/lib/esm/localized-dedupe.d.ts +0 -26
- package/lib/esm/localized-dedupe.d.ts.map +0 -1
- package/lib/esm/localized-dedupe.js +0 -139
- package/lib/esm/localized-dedupe.js.map +0 -1
- package/lib/esm/utils/relinkHooks.d.ts +0 -19
- package/lib/esm/utils/relinkHooks.d.ts.map +0 -1
- package/lib/esm/utils/relinkHooks.js +0 -74
- package/lib/esm/utils/relinkHooks.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-backend.js","sourceRoot":"","sources":["../../../src/app-release/build-backend.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;;;;;GAMG;AACH,MAAM,eAAe,GAA6B;IAChD,OAAO,EAAE,CAAC,gBAAgB,EAAE,iBAAiB,CAAC;IAC9C,GAAG,EAAE,CAAC,aAAa,EAAE,YAAY,CAAC;IAClC,MAAM,EAAE,CAAC,gBAAgB,EAAE,eAAe,CAAC;CAC5C,CAAC;AAEF;;;;;GAKG;AACH,MAAM,iBAAiB,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;AAE7C,wDAAwD;AACxD,MAAM,aAAa,GAAG;IACpB,GAAG,cAAc;IACjB,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,IAAI,EAAE,CAAC;CAChD,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,OAAe,EACf,SAAiC,EAAE,CAAC,UAAU,EACtB,EAAE;IAC1B,MAAM,OAAO,GAA2B,EAAE,CAAC;IAC3C,KAAK,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,CAAC;QACjE,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EA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,GAAG,MAAM,YAAY,CAAC,YAAY,CAAC,CAAC;IAClD,MAAM,OAAO,CAAC,GAAG,CACf,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACpB,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;QAC5D,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;QACxC,OAAO,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IACvC,CAAC,CAAC,CACH,CAAC;IACF,OAAO,QAAQ,CAAC,MAAM,CAAC;AACzB,CAAC,CAAA,CAAC","sourcesContent":["import {builtinModules} from 'module';\nimport fs from 'fs-extra';\nimport path from 'path';\n\n/**\n * The backend entry points a compiled app is started from.\n *\n * `serve-app` requires all three on disk and `startServer` imports `lib/App.js`\n * and `lib/routes.js` by those exact paths, so the names are a contract, not a\n * convention.\n */\nconst BACKEND_ENTRIES: Record<string, string[]> = {\n backend: ['src/backend.ts', 'src/backend.tsx'],\n App: ['src/App.tsx', 'src/App.ts'],\n routes: ['src/routes.tsx', 'src/routes.ts'],\n};\n\n/**\n * Vite's default server conditions minus the `development|production` token.\n *\n * See the note at the `resolve` option below: dropping the token is what stops\n * a workspace package resolving to its TypeScript source.\n */\nconst SERVER_CONDITIONS = ['module', 'node'];\n\n/** Both spellings, because a backend may use either. */\nconst NODE_BUILTINS = [\n ...builtinModules,\n ...builtinModules.map((name) => `node:${name}`),\n];\n\nexport const resolveBackendEntries = (\n appRoot: string,\n exists: (p: string) => boolean = fs.existsSync\n): Record<string, string> => {\n const entries: Record<string, string> = {};\n for (const [name, candidates] of Object.entries(BACKEND_ENTRIES)) {\n const found = candidates.find((candidate) =>\n exists(path.join(appRoot, candidate))\n );\n if (found) {\n entries[name] = path.join(appRoot, found);\n }\n }\n return entries;\n};\n\n/**\n * Workspace package names to list as `ssr.external`.\n *\n * Vite will not externalise these on its own, and the reason is worth\n * recording because it is entirely non-obvious. `node_modules/@_linked/core`\n * is a symlink into `packages/core`; Vite resolves package data with\n * `preserveSymlinks: false`, so the resolved id realpaths *out* of\n * `node_modules`; and Vite refuses to externalise anything that does not look\n * like it lives there:\n *\n * if (!configuredAsExternal && !isInNodeModules(resolved.id)) return false;\n *\n * So every workspace package got compiled into `lib/`. That is not merely\n * wasteful — `linked.backend.storage.js` is loaded from the APP ROOT by a raw\n * Node `import()` and resolves `@_linked/core` through node_modules, so the\n * storage config configured one copy of `LinkedStorage` while the compiled\n * backend queried another. `LinkedStorage`'s routing state is a per-copy\n * static, so the app's single-instance guard refuses to boot. The old `tsc`\n * build never hit this: it emitted bare specifiers and Node converged on one\n * copy. Naming the packages here restores that.\n *\n * `configuredAsExternal` is the one thing that overrides the symlink rule, and\n * it is keyed on exact package names — no regexes.\n */\nexport const workspacePackagesToExternalize = async (\n appRoot: string,\n discover: (\n globs: string[],\n cwd: string\n ) => Promise<{name: string}[]> = async (globs, cwd) => {\n const {discoverWorkspaces} = await import('../vite-config.js');\n return discoverWorkspaces(globs, cwd);\n }\n): Promise<string[]> => {\n const workspaces = await discover([], appRoot);\n return [...new Set(workspaces.map((w) => w.name))].sort();\n};\n\n/**\n * Every module specifier a compiled file imports: static `from \"…\"`, side-effect\n * `import \"…\"`, dynamic `import(\"…\")`, and `require(\"…\")`.\n *\n * Deliberately loose — it can match text inside a string or a comment. That is\n * harmless: only specifiers that resolve to a file on disk are acted on, and\n * only when that file turns out to be a copy of a package.\n */\nexport const findImportSpecifiers = (source: string): string[] => {\n const matches = source.matchAll(\n /(?:\\bfrom\\s*|\\bimport\\s*\\(?\\s*|\\brequire\\s*\\(\\s*)[\"']([^\"'\\n]+)[\"']/g\n );\n return [...new Set([...matches].map((m) => m[1]))].sort();\n};\n\n/** One import in `lib/` that reaches a compiled-in copy of a package. */\nexport interface InlinedPackageImport {\n /** The importing file, relative to the app root (`lib/…/PageView.js`). */\n file: string;\n /** The specifier exactly as it appears in that file. */\n specifier: string;\n /** Real path of the package source the imported module was compiled from. */\n origin: string;\n /** Name of the package that source belongs to, when it is known. */\n packageName?: string;\n}\n\n/**\n * A directory whose real path is package code the backend must import rather\n * than compile: a workspace package, a localized checkout, an installed\n * framework package.\n */\nexport interface PackageRoot {\n root: string;\n name?: string;\n}\n\n/**\n * Top-level directories of `lib/` that only exist when code from outside\n * `src/` was compiled in.\n *\n * `preserveModules` lays `lib/` out relative to the common ancestor of every\n * module in the build. With `preserveModulesRoot: src` the app's own files lose\n * their `src/` prefix, and anything else keeps its path from the app root — so\n * a compiled-in workspace package lands at `lib/packages/…`, an installed one at\n * `lib/node_modules/…`. Only when the app has no `src/` directory of that name,\n * since an app is free to have its own `src/packages/`.\n */\nconst STRAY_OUTPUT_DIRS = ['packages', 'packages-local', 'node_modules'];\n\nconst realpathOr = (p: string): string => {\n try {\n return fs.realpathSync(p);\n } catch {\n return path.resolve(p);\n }\n};\n\nconst isInside = (child: string, parent: string): boolean => {\n const rel = path.relative(parent, child);\n return rel === '' || (!rel.startsWith('..') && !path.isAbsolute(rel));\n};\n\nconst listJsFiles = async (dir: string): Promise<string[]> => {\n const out: string[] = [];\n const walk = async (current: string) => {\n const entries = await fs.promises.readdir(current, {withFileTypes: true});\n await Promise.all(\n entries.map(async (entry) => {\n const full = path.join(current, entry.name);\n if (entry.isDirectory()) await walk(full);\n else if (/\\.(?:m|c)?js$/.test(entry.name)) out.push(full);\n })\n );\n };\n await walk(dir);\n return out.sort();\n};\n\n/**\n * The package roots an app's compiled backend must never contain a copy of,\n * as real paths: every discovered workspace package, everything under\n * `packages-local/`, and every installed `@_linked/*` package (whose real path\n * is a localized checkout when it has been localized).\n */\nexport const packageRootsForApp = async (\n appRoot: string,\n discover: (\n globs: string[],\n cwd: string\n ) => Promise<{name: string; srcDir: string}[]> = async (globs, cwd) => {\n const {discoverWorkspaces} = await import('../vite-config.js');\n return discoverWorkspaces(globs, cwd);\n }\n): Promise<PackageRoot[]> => {\n const roots: PackageRoot[] = [];\n for (const ws of await discover([], appRoot)) {\n roots.push({root: realpathOr(path.dirname(ws.srcDir)), name: ws.name});\n }\n const packagesLocal = path.join(appRoot, 'packages-local');\n if (fs.existsSync(packagesLocal)) {\n for (const entry of await fs.readdir(packagesLocal)) {\n roots.push({root: realpathOr(path.join(packagesLocal, entry))});\n }\n roots.push({root: realpathOr(packagesLocal)});\n }\n const linkedScope = path.join(appRoot, 'node_modules', '@_linked');\n if (fs.existsSync(linkedScope)) {\n for (const entry of await fs.readdir(linkedScope)) {\n roots.push({\n root: realpathOr(path.join(linkedScope, entry)),\n name: `@_linked/${entry}`,\n });\n }\n roots.push({root: realpathOr(linkedScope)});\n }\n // The app itself can be discovered as a workspace; its own source is not a\n // second copy of anything.\n const appSrc = realpathOr(path.join(appRoot, 'src'));\n return roots.filter(({root}) => !isInside(appSrc, root));\n};\n\n/**\n * Find every import in the compiled backend that reaches a compiled-in copy of\n * a package.\n *\n * Each relative specifier is resolved against its file, and the module it\n * lands on is traced back to the source it was compiled from through that\n * module's sourcemap. The source's REAL path is then compared with the\n * package roots — so it does not matter what the copy's directory in `lib/` is\n * called, or whether the package was reached through a symlink. An import that\n * leaves `lib/` altogether is judged by its own real path.\n *\n * Only imports from the app's own modules are reported: they are the ones to\n * change, and every compiled-in copy is reached through one of them.\n */\nexport const findInlinedPackageImports = async (\n appRoot: string,\n packageRoots: PackageRoot[]\n): Promise<{imports: InlinedPackageImport[]; strayDirs: string[]}> => {\n const libDir = path.join(appRoot, 'lib');\n const strayDirs = STRAY_OUTPUT_DIRS.filter(\n (name) =>\n fs.existsSync(path.join(libDir, name)) &&\n !fs.existsSync(path.join(appRoot, 'src', name))\n ).map((name) => `lib/${name}/`);\n if (!fs.existsSync(libDir)) return {imports: [], strayDirs};\n\n const ownerOf = (real: string): PackageRoot | undefined =>\n packageRoots\n .filter(({root}) => isInside(real, root))\n // The most specific root names the package; a named one wins a tie.\n .sort(\n (a, b) =>\n b.root.length - a.root.length || Number(!!b.name) - Number(!!a.name)\n )[0];\n\n // Where a module in lib/ was compiled from, via its sourcemap.\n const originCache = new Map<string, string[]>();\n const originsOf = async (moduleFile: string): Promise<string[]> => {\n const cached = originCache.get(moduleFile);\n if (cached) return cached;\n let origins: string[] = [];\n try {\n const map = JSON.parse(await fs.readFile(`${moduleFile}.map`, 'utf8'));\n const base = path.resolve(path.dirname(moduleFile), map.sourceRoot || '');\n origins = (map.sources || [])\n .filter((s: unknown) => typeof s === 'string' && !s.startsWith('\\0'))\n .map((s: string) => realpathOr(path.resolve(base, s.replace(/^file:\\/\\//, ''))));\n } catch {\n // No sourcemap: nothing to trace. The stray-directory check still\n // catches the usual layout of a compiled-in package.\n }\n originCache.set(moduleFile, origins);\n return origins;\n };\n const packageSourceOf = async (moduleFile: string) => {\n for (const origin of await originsOf(moduleFile)) {\n const owner = ownerOf(origin);\n if (owner) return {origin, owner};\n }\n return undefined;\n };\n\n const imports: InlinedPackageImport[] = [];\n for (const file of await listJsFiles(libDir)) {\n // A compiled-in copy importing its own siblings is noise; report where the\n // app reaches into it.\n if (await packageSourceOf(file)) continue;\n const source = await fs.readFile(file, 'utf8');\n for (const specifier of findImportSpecifiers(source)) {\n const isPath =\n specifier.startsWith('./') ||\n specifier.startsWith('../') ||\n specifier.startsWith('/') ||\n specifier.startsWith('file://');\n if (!isPath) continue;\n const target = specifier.startsWith('file://')\n ? specifier.slice('file://'.length)\n : path.resolve(path.dirname(file), specifier);\n\n let found: {origin: string; owner: PackageRoot} | undefined;\n if (isInside(target, libDir)) {\n found = await packageSourceOf(target);\n } else {\n const real = realpathOr(target);\n const owner = ownerOf(real);\n if (owner) found = {origin: real, owner};\n }\n if (!found) continue;\n imports.push({\n file: path.relative(appRoot, file),\n specifier,\n origin: found.origin,\n packageName: found.owner.name,\n });\n }\n }\n return {imports, strayDirs};\n};\n\n/**\n * Fail the build when the compiled backend contains a copy of a package.\n *\n * A copy compiles and runs — and then fails somewhere else entirely: a second\n * `@_linked/core` splits `LinkedStorage`'s routing state from the one the\n * storage config configures, and a second `@_linked/server-utils` is a second\n * `ShapeProvider` class, so the server's `instanceof` check rejects every\n * provider the app exports. Neither message points anywhere near here.\n *\n * Every file in `lib/` is checked, not only the entries: a copy reached from\n * a feature folder three imports deep is just as much a second copy.\n */\nexport const assertNoInlinedWorkspaces = async (\n appRoot: string,\n packageRoots?: PackageRoot[]\n): Promise<void> => {\n const roots = packageRoots || (await packageRootsForApp(appRoot));\n const {imports, strayDirs} = await findInlinedPackageImports(appRoot, roots);\n if (imports.length === 0 && strayDirs.length === 0) return;\n\n const lines = imports.slice(0, 8).map(\n (found) =>\n ` ${found.file} imports \"${found.specifier}\"\\n` +\n ` — a compiled-in copy of ${found.origin}` +\n (found.packageName ? ` (${found.packageName})` : '')\n );\n if (imports.length > 8) lines.push(` …and ${imports.length - 8} more`);\n const names = [\n ...new Set(imports.map((i) => i.packageName).filter(Boolean)),\n ] as string[];\n throw new Error(\n 'The compiled backend contains a copy of package code instead of importing it:\\n' +\n (lines.length ? lines.join('\\n') + '\\n' : '') +\n (strayDirs.length\n ? ` ${strayDirs.join(', ')} exists — only code compiled from outside src/ lands there\\n`\n : '') +\n 'Each copy is a second instance of that package: its classes fail `instanceof` ' +\n 'and its registries are empty. Import the package through its public export ' +\n (names.length ? `(${names.map((n) => `\"${n}\" or \"${n}/…\"`).join(', ')}) ` : '') +\n 'rather than a path into its files, and check that nothing — a resolve.alias, ' +\n 'a `development` export condition — maps that import to its source. A ' +\n 'workspace package must also be discoverable, so it can be named in ssr.external.'\n );\n};\n\n/**\n * Turn Rollup's unresolved-import error into one that names the actual cause.\n *\n * Externalizing a workspace package means the build now resolves it through\n * its published `exports` — its `lib/`, not its `src/`. A package whose `lib/`\n * is stale therefore fails here, on a file that plainly exists in source.\n * Rollup's own message (\"failed to resolve import X\") sends you looking at the\n * import, which is fine.\n */\nexport const explainUnresolvedWorkspaceImport = (\n message: string,\n externalWorkspaces: string[]\n): string | null => {\n const match = message.match(/failed to resolve import \"([^\"]+)\"/i);\n if (!match) return null;\n const specifier = match[1];\n const pkg = externalWorkspaces.find(\n (name) => specifier === name || specifier.startsWith(`${name}/`)\n );\n if (!pkg) return null;\n return (\n `${message}\\n\\n` +\n `\"${pkg}\" is a workspace package, so a release build resolves it through its ` +\n `published exports — its lib/, not its src/. If this file exists in ` +\n `${pkg}/src but not in its build output, that package's lib/ is stale. ` +\n `Build it first (\\`linked build\\` in the package, or \\`linked build-workspace\\`) ` +\n `and run build-app again.`\n );\n};\n\n/**\n * Strip the client build's `manualChunks` from the SSR output options.\n *\n * Rollup refuses `manualChunks` together with `preserveModules`, and passing\n * `undefined` in the inline config does not remove it — Vite's config merge\n * keeps the app's value. So it is cleared in the output hook instead, after\n * the merge. Chunk grouping is a client concern; the backend wants one output\n * file per source file.\n */\nconst dropManualChunks = () => ({\n name: 'linked:backend-no-manual-chunks',\n enforce: 'post' as const,\n outputOptions(options: Record<string, unknown>) {\n if (!options.manualChunks) return null;\n const {manualChunks: _dropped, ...rest} = options;\n return rest;\n },\n});\n\n/**\n * Compile the app's backend to `lib/`.\n *\n * This runs Vite in SSR mode against the app's own `vite.config`, which is the\n * point: `linked start` already loads `src/backend.ts`, `src/App.tsx` and\n * `src/routes.tsx` through `vite.ssrLoadModule`, so a production build that\n * used anything else was resolving the same source differently from dev. The\n * workspace resolver, the decorator transform and extensionless relative\n * imports all come along for free.\n *\n * `preserveModules` keeps `src/`'s file layout in `lib/`, so the entry paths\n * stay where `serve-app` and `startServer` look for them and lazily imported\n * pages keep their own files. `manualChunks` is cleared because Rollup refuses\n * to run it alongside `preserveModules` — and it is a client-side concern\n * anyway.\n *\n * Workspace packages are named as `ssr.external` explicitly; see\n * `workspacePackagesToExternalize` for why Vite does not do it on its own.\n * Node's built-ins are listed by hand for a related reason: Vite externalises\n * them for SSR only when it recognises the specifier, and a bare `crypto` —\n * which a backend written for Node may perfectly well import — resolved\n * instead to the abandoned `crypto` shim package sitting in node_modules, and\n * failed the build.\n *\n * `copyPublicDir` is off because `public/` is the client build's output, not\n * the backend's. Left on, it copied 38MB of already-built bundles into `lib/`.\n */\nexport const buildBackendWithVite = async (\n options: {appRoot?: string} = {},\n dependencies: {viteBuild?: (config: any) => Promise<unknown>} = {}\n): Promise<void> => {\n const appRoot = options.appRoot || process.cwd();\n const entries = resolveBackendEntries(appRoot);\n\n if (!entries.backend) {\n throw new Error(\n 'No backend entry found: expected src/backend.ts in ' + appRoot\n );\n }\n\n const viteBuild =\n dependencies.viteBuild ||\n (async (config: any) => {\n const {build} = await import('vite');\n return build(config);\n });\n\n const externalWorkspaces = await workspacePackagesToExternalize(appRoot);\n\n try {\n await viteBuild({\n root: appRoot,\n mode: 'production',\n isProduction: true,\n // The client build sets `base` to the release URL. The backend emits no\n // asset URLs of its own, so it must not inherit one.\n base: '/',\n // Never resolve a `development` export condition in a release build.\n //\n // The workspace-source convention is\n // \"development\": \"./src/*.ts\", \"import\": \"./lib/esm/*.js\"\n // and Vite expands its `development|production` token from NODE_ENV —\n // which during a release build is whatever the app's `.env` says,\n // routinely `development`. The package then resolves to TypeScript, which\n // cannot be externalised because Node could not load it, so it is\n // compiled in regardless of what `ssr.external` says.\n //\n // Dropping the token (rather than pinning it to `production`) leaves\n // `import` — which Vite always appends last — to win. Same treatment\n // `createViteConfig` already applies to a standalone install, for the\n // mirror-image reason.\n //\n // All three lists have to say it: `ssr.resolve.conditions` does not\n // inherit from `resolve.conditions` here, and `externalConditions`\n // governs the packages that end up external.\n resolve: {conditions: SERVER_CONDITIONS},\n ssr: {\n // Merged with the app's own ssr.external rather than replacing it.\n external: externalWorkspaces,\n resolve: {\n conditions: SERVER_CONDITIONS,\n externalConditions: SERVER_CONDITIONS,\n },\n },\n plugins: [dropManualChunks()],\n build: {\n ssr: true,\n outDir: 'lib',\n emptyOutDir: true,\n copyPublicDir: false,\n manifest: false,\n sourcemap: true,\n rollupOptions: {\n input: entries,\n external: NODE_BUILTINS,\n output: {\n format: 'es',\n preserveModules: true,\n preserveModulesRoot: path.join(appRoot, 'src'),\n entryFileNames: '[name].js',\n chunkFileNames: '[name].js',\n },\n },\n },\n });\n } catch (err) {\n const explained = explainUnresolvedWorkspaceImport(\n err instanceof Error ? err.message : String(err),\n externalWorkspaces\n );\n if (!explained) throw err;\n throw new Error(explained);\n }\n\n await assertNoInlinedWorkspaces(appRoot);\n};\n\n/**\n * Copy `src`'s CSS next to the compiled backend.\n *\n * The server reads stylesheets like `lib/css/theme.css` off disk by path, so\n * they have to exist as files whether or not any module imported them.\n */\nexport const copyBackendStylesheets = async (\n appRoot: string,\n listCssFiles: (dir: string) => Promise<string[]>\n): Promise<number> => {\n const sourceFolder = path.join(appRoot, 'src');\n const targetFolder = path.join(appRoot, 'lib');\n const cssFiles = await listCssFiles(sourceFolder);\n await Promise.all(\n cssFiles.map((file) => {\n const targetFile = file.replace(sourceFolder, targetFolder);\n fs.mkdirpSync(path.dirname(targetFile));\n return fs.copyFile(file, targetFile);\n })\n );\n return cssFiles.length;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"build-backend.js","sourceRoot":"","sources":["../../../src/app-release/build-backend.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAC,aAAa,EAAC,MAAM,KAAK,CAAC;AAElC;;;;;;GAMG;AACH,MAAM,eAAe,GAA6B;IAChD,OAAO,EAAE,CAAC,gBAAgB,EAAE,iBAAiB,CAAC;IAC9C,GAAG,EAAE,CAAC,aAAa,EAAE,YAAY,CAAC;IAClC,MAAM,EAAE,CAAC,gBAAgB,EAAE,eAAe,CAAC;CAC5C,CAAC;AAEF;;;;;GAKG;AACH,MAAM,iBAAiB,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;AAE7C,wDAAwD;AACxD,MAAM,aAAa,GAAG;IACp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AC1B,MAAM,IAAI,KAAK,CAAC,SAAS,CAAC,CAAC;IAC7B,CAAC;IAED,MAAM,yBAAyB,CAAC,OAAO,CAAC,CAAC;AAC3C,CAAC,CAAA,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,OAAe,EACf,YAAgD,EAC/B,EAAE;IACnB,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC/C,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC/C,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,YAAY,CAAC,CAAC;IAClD,MAAM,OAAO,CAAC,GAAG,CACf,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACpB,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;QAC5D,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;QACxC,OAAO,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IACvC,CAAC,CAAC,CACH,CAAC;IACF,OAAO,QAAQ,CAAC,MAAM,CAAC;AACzB,CAAC,CAAA,CAAC","sourcesContent":["import {builtinModules} from 'module';\nimport fs from 'fs-extra';\nimport path from 'path';\nimport {fileURLToPath} from 'url';\n\n/**\n * The backend entry points a compiled app is started from.\n *\n * `serve-app` requires all three on disk and `startServer` imports `lib/App.js`\n * and `lib/routes.js` by those exact paths, so the names are a contract, not a\n * convention.\n */\nconst BACKEND_ENTRIES: Record<string, string[]> = {\n backend: ['src/backend.ts', 'src/backend.tsx'],\n App: ['src/App.tsx', 'src/App.ts'],\n routes: ['src/routes.tsx', 'src/routes.ts'],\n};\n\n/**\n * Vite's default server conditions minus the `development|production` token.\n *\n * See the note at the `resolve` option below: dropping the token is what stops\n * a workspace package resolving to its TypeScript source.\n */\nconst SERVER_CONDITIONS = ['module', 'node'];\n\n/** Both spellings, because a backend may use either. */\nconst NODE_BUILTINS = [\n ...builtinModules,\n ...builtinModules.map((name) => `node:${name}`),\n];\n\nexport const resolveBackendEntries = (\n appRoot: string,\n exists: (p: string) => boolean = fs.existsSync\n): Record<string, string> => {\n const entries: Record<string, string> = {};\n for (const [name, candidates] of Object.entries(BACKEND_ENTRIES)) {\n const found = candidates.find((candidate) =>\n exists(path.join(appRoot, candidate))\n );\n if (found) {\n entries[name] = path.join(appRoot, found);\n }\n }\n return entries;\n};\n\n/**\n * Workspace package names to list as `ssr.external`.\n *\n * Vite will not externalise these on its own, and the reason is worth\n * recording because it is entirely non-obvious. `node_modules/@_linked/core`\n * is a symlink into `packages/core`; Vite resolves package data with\n * `preserveSymlinks: false`, so the resolved id realpaths *out* of\n * `node_modules`; and Vite refuses to externalise anything that does not look\n * like it lives there:\n *\n * if (!configuredAsExternal && !isInNodeModules(resolved.id)) return false;\n *\n * So every workspace package got compiled into `lib/`. That is not merely\n * wasteful — `linked.backend.storage.js` is loaded from the APP ROOT by a raw\n * Node `import()` and resolves `@_linked/core` through node_modules, so the\n * storage config configured one copy of `LinkedStorage` while the compiled\n * backend queried another. `LinkedStorage`'s routing state is a per-copy\n * static, so the app's single-instance guard refuses to boot. The old `tsc`\n * build never hit this: it emitted bare specifiers and Node converged on one\n * copy. Naming the packages here restores that.\n *\n * `configuredAsExternal` is the one thing that overrides the symlink rule, and\n * it is keyed on exact package names — no regexes.\n */\nexport const workspacePackagesToExternalize = async (\n appRoot: string,\n discover: (\n globs: string[],\n cwd: string\n ) => Promise<{name: string}[]> = async (globs, cwd) => {\n const {discoverWorkspaces} = await import('../vite-config.js');\n return discoverWorkspaces(globs, cwd);\n }\n): Promise<string[]> => {\n const workspaces = await discover([], appRoot);\n return [...new Set(workspaces.map((w) => w.name))].sort();\n};\n\n/**\n * Every module specifier a compiled file imports: static `from \"…\"`, side-effect\n * `import \"…\"`, dynamic `import(\"…\")`, and `require(\"…\")`.\n *\n * Deliberately loose — it can match text inside a string or a comment. That is\n * harmless: only specifiers that resolve to a file on disk are acted on, and\n * only when that file turns out to be a copy of a package.\n */\nexport const findImportSpecifiers = (source: string): string[] => {\n const matches = source.matchAll(\n /(?:\\bfrom\\s*|\\bimport\\s*\\(?\\s*|\\brequire\\s*\\(\\s*)[\"']([^\"'\\n]+)[\"']/g\n );\n return [...new Set([...matches].map((m) => m[1]))].sort();\n};\n\n/** One import in `lib/` that reaches a compiled-in copy of a package. */\nexport interface InlinedPackageImport {\n /** The importing file, relative to the app root (`lib/…/PageView.js`). */\n file: string;\n /** The specifier exactly as it appears in that file. */\n specifier: string;\n /** Real path of the package source the imported module was compiled from. */\n origin: string;\n /** Name of the package that source belongs to, when it is known. */\n packageName?: string;\n}\n\n/**\n * A directory whose real path is package code the backend must import rather\n * than compile: a workspace package, a localized checkout, an installed\n * framework package.\n */\nexport interface PackageRoot {\n root: string;\n name?: string;\n}\n\n/**\n * Top-level directories of `lib/` that only exist when code from outside\n * `src/` was compiled in.\n *\n * `preserveModules` lays `lib/` out relative to the common ancestor of every\n * module in the build. With `preserveModulesRoot: src` the app's own files lose\n * their `src/` prefix, and anything else keeps its path from the app root — so\n * a compiled-in workspace package lands at `lib/packages/…`, an installed one at\n * `lib/node_modules/…`. Only when the app has no `src/` directory of that name,\n * since an app is free to have its own `src/packages/`.\n */\nconst STRAY_OUTPUT_DIRS = ['packages', 'packages-local', 'node_modules'];\n\nconst realpathOr = (p: string): string => {\n try {\n return fs.realpathSync(p);\n } catch {\n return path.resolve(p);\n }\n};\n\nconst isInside = (child: string, parent: string): boolean => {\n const rel = path.relative(parent, child);\n return rel === '' || (!rel.startsWith('..') && !path.isAbsolute(rel));\n};\n\nconst listJsFiles = async (dir: string): Promise<string[]> => {\n const out: string[] = [];\n const walk = async (current: string) => {\n const entries = await fs.promises.readdir(current, {withFileTypes: true});\n await Promise.all(\n entries.map(async (entry) => {\n const full = path.join(current, entry.name);\n if (entry.isDirectory()) await walk(full);\n else if (/\\.(?:m|c)?js$/.test(entry.name)) out.push(full);\n })\n );\n };\n await walk(dir);\n return out.sort();\n};\n\n/**\n * The package roots an app's compiled backend must never contain a copy of,\n * as real paths: every discovered workspace package, everything under\n * `packages-local/`, and every installed `@_linked/*` package (whose real path\n * is a localized checkout when it has been localized).\n */\nexport const packageRootsForApp = async (\n appRoot: string,\n discover: (\n globs: string[],\n cwd: string\n ) => Promise<{name: string; srcDir: string}[]> = async (globs, cwd) => {\n const {discoverWorkspaces} = await import('../vite-config.js');\n return discoverWorkspaces(globs, cwd);\n }\n): Promise<PackageRoot[]> => {\n const roots: PackageRoot[] = [];\n for (const ws of await discover([], appRoot)) {\n roots.push({root: realpathOr(path.dirname(ws.srcDir)), name: ws.name});\n }\n const packagesLocal = path.join(appRoot, 'packages-local');\n if (fs.existsSync(packagesLocal)) {\n for (const entry of await fs.readdir(packagesLocal)) {\n roots.push({root: realpathOr(path.join(packagesLocal, entry))});\n }\n roots.push({root: realpathOr(packagesLocal)});\n }\n const linkedScope = path.join(appRoot, 'node_modules', '@_linked');\n if (fs.existsSync(linkedScope)) {\n for (const entry of await fs.readdir(linkedScope)) {\n roots.push({\n root: realpathOr(path.join(linkedScope, entry)),\n name: `@_linked/${entry}`,\n });\n }\n roots.push({root: realpathOr(linkedScope)});\n }\n // The app itself can be discovered as a workspace; its own source is not a\n // second copy of anything.\n const appSrc = realpathOr(path.join(appRoot, 'src'));\n return roots.filter(({root}) => !isInside(appSrc, root));\n};\n\n/**\n * Find every import in the compiled backend that reaches a compiled-in copy of\n * a package.\n *\n * Each relative specifier is resolved against its file, and the module it\n * lands on is traced back to the source it was compiled from through that\n * module's sourcemap. The source's REAL path is then compared with the\n * package roots — so it does not matter what the copy's directory in `lib/` is\n * called, or whether the package was reached through a symlink. An import that\n * leaves `lib/` altogether is judged by its own real path.\n *\n * Only imports from the app's own modules are reported: they are the ones to\n * change, and every compiled-in copy is reached through one of them.\n */\nexport const findInlinedPackageImports = async (\n appRoot: string,\n packageRoots: PackageRoot[]\n): Promise<{imports: InlinedPackageImport[]; strayDirs: string[]}> => {\n const libDir = path.join(appRoot, 'lib');\n const strayDirs = STRAY_OUTPUT_DIRS.filter(\n (name) =>\n fs.existsSync(path.join(libDir, name)) &&\n !fs.existsSync(path.join(appRoot, 'src', name))\n ).map((name) => `lib/${name}/`);\n if (!fs.existsSync(libDir)) return {imports: [], strayDirs};\n\n const ownerOf = (real: string): PackageRoot | undefined =>\n packageRoots\n .filter(({root}) => isInside(real, root))\n // The most specific root names the package; a named one wins a tie.\n .sort(\n (a, b) =>\n b.root.length - a.root.length || Number(!!b.name) - Number(!!a.name)\n )[0];\n\n // Where a module in lib/ was compiled from, via its sourcemap.\n const originCache = new Map<string, string[]>();\n const originsOf = async (moduleFile: string): Promise<string[]> => {\n const cached = originCache.get(moduleFile);\n if (cached) return cached;\n let origins: string[] = [];\n try {\n const map = JSON.parse(await fs.readFile(`${moduleFile}.map`, 'utf8'));\n const base = path.resolve(path.dirname(moduleFile), map.sourceRoot || '');\n origins = (map.sources || [])\n .filter((s: unknown) => typeof s === 'string' && !s.startsWith('\\0'))\n .map((s: string) => realpathOr(path.resolve(base, s.replace(/^file:\\/\\//, ''))));\n } catch {\n // No sourcemap: nothing to trace. The stray-directory check still\n // catches the usual layout of a compiled-in package.\n }\n originCache.set(moduleFile, origins);\n return origins;\n };\n const packageSourceOf = async (moduleFile: string) => {\n for (const origin of await originsOf(moduleFile)) {\n const owner = ownerOf(origin);\n if (owner) return {origin, owner};\n }\n return undefined;\n };\n\n const imports: InlinedPackageImport[] = [];\n for (const file of await listJsFiles(libDir)) {\n // A compiled-in copy importing its own siblings is noise; report where the\n // app reaches into it.\n if (await packageSourceOf(file)) continue;\n const source = await fs.readFile(file, 'utf8');\n for (const specifier of findImportSpecifiers(source)) {\n const isPath =\n specifier.startsWith('./') ||\n specifier.startsWith('../') ||\n specifier.startsWith('/') ||\n specifier.startsWith('file://');\n if (!isPath) continue;\n const target = specifier.startsWith('file://')\n ? fileURLToPath(specifier)\n : path.resolve(path.dirname(file), specifier);\n\n let found: {origin: string; owner: PackageRoot} | undefined;\n if (isInside(target, libDir)) {\n found = await packageSourceOf(target);\n } else {\n const real = realpathOr(target);\n const owner = ownerOf(real);\n if (owner) found = {origin: real, owner};\n }\n if (!found) continue;\n imports.push({\n file: path.relative(appRoot, file),\n specifier,\n origin: found.origin,\n packageName: found.owner.name,\n });\n }\n }\n return {imports, strayDirs};\n};\n\n/**\n * Fail the build when the compiled backend contains a copy of a package.\n *\n * A copy compiles and runs — and then fails somewhere else entirely: a second\n * `@_linked/core` splits `LinkedStorage`'s routing state from the one the\n * storage config configures, and a second `@_linked/server-utils` is a second\n * `ShapeProvider` class, so the server's `instanceof` check rejects every\n * provider the app exports. Neither message points anywhere near here.\n *\n * Every file in `lib/` is checked, not only the entries: a copy reached from\n * a feature folder three imports deep is just as much a second copy.\n */\nexport const assertNoInlinedWorkspaces = async (\n appRoot: string,\n packageRoots?: PackageRoot[]\n): Promise<void> => {\n const roots = packageRoots || (await packageRootsForApp(appRoot));\n const {imports, strayDirs} = await findInlinedPackageImports(appRoot, roots);\n if (imports.length === 0 && strayDirs.length === 0) return;\n\n const lines = imports.slice(0, 8).map(\n (found) =>\n ` ${found.file} imports \"${found.specifier}\"\\n` +\n ` — a compiled-in copy of ${found.origin}` +\n (found.packageName ? ` (${found.packageName})` : '')\n );\n if (imports.length > 8) lines.push(` …and ${imports.length - 8} more`);\n const names = [\n ...new Set(imports.map((i) => i.packageName).filter(Boolean)),\n ] as string[];\n throw new Error(\n 'The compiled backend contains a copy of package code instead of importing it:\\n' +\n (lines.length ? lines.join('\\n') + '\\n' : '') +\n (strayDirs.length\n ? ` ${strayDirs.join(', ')} exists — only code compiled from outside src/ lands there\\n`\n : '') +\n 'Each copy is a second instance of that package: its classes fail `instanceof` ' +\n 'and its registries are empty. Import the package through its public export ' +\n (names.length ? `(${names.map((n) => `\"${n}\" or \"${n}/…\"`).join(', ')}) ` : '') +\n 'rather than a path into its files, and check that nothing — a resolve.alias, ' +\n 'a `development` export condition — maps that import to its source. A ' +\n 'workspace package must also be discoverable, so it can be named in ssr.external.'\n );\n};\n\n/**\n * Turn Rollup's unresolved-import error into one that names the actual cause.\n *\n * Externalizing a workspace package means the build now resolves it through\n * its published `exports` — its `lib/`, not its `src/`. A package whose `lib/`\n * is stale therefore fails here, on a file that plainly exists in source.\n * Rollup's own message (\"failed to resolve import X\") sends you looking at the\n * import, which is fine.\n */\nexport const explainUnresolvedWorkspaceImport = (\n message: string,\n externalWorkspaces: string[]\n): string | null => {\n const match = message.match(/failed to resolve import \"([^\"]+)\"/i);\n if (!match) return null;\n const specifier = match[1];\n const pkg = externalWorkspaces.find(\n (name) => specifier === name || specifier.startsWith(`${name}/`)\n );\n if (!pkg) return null;\n return (\n `${message}\\n\\n` +\n `\"${pkg}\" is a workspace package, so a release build resolves it through its ` +\n `published exports — its lib/, not its src/. If this file exists in ` +\n `${pkg}/src but not in its build output, that package's lib/ is stale. ` +\n `Build it first (\\`linked build\\` in the package, or \\`linked build-workspace\\`) ` +\n `and run build-app again.`\n );\n};\n\n/**\n * Strip the client build's `manualChunks` from the SSR output options.\n *\n * Rollup refuses `manualChunks` together with `preserveModules`, and passing\n * `undefined` in the inline config does not remove it — Vite's config merge\n * keeps the app's value. So it is cleared in the output hook instead, after\n * the merge. Chunk grouping is a client concern; the backend wants one output\n * file per source file.\n */\nconst dropManualChunks = () => ({\n name: 'linked:backend-no-manual-chunks',\n enforce: 'post' as const,\n outputOptions(options: Record<string, unknown>) {\n if (!options.manualChunks) return null;\n const {manualChunks: _dropped, ...rest} = options;\n return rest;\n },\n});\n\n/**\n * Compile the app's backend to `lib/`.\n *\n * This runs Vite in SSR mode against the app's own `vite.config`, which is the\n * point: `linked start` already loads `src/backend.ts`, `src/App.tsx` and\n * `src/routes.tsx` through `vite.ssrLoadModule`, so a production build that\n * used anything else was resolving the same source differently from dev. The\n * workspace resolver, the decorator transform and extensionless relative\n * imports all come along for free.\n *\n * `preserveModules` keeps `src/`'s file layout in `lib/`, so the entry paths\n * stay where `serve-app` and `startServer` look for them and lazily imported\n * pages keep their own files. `manualChunks` is cleared because Rollup refuses\n * to run it alongside `preserveModules` — and it is a client-side concern\n * anyway.\n *\n * Workspace packages are named as `ssr.external` explicitly; see\n * `workspacePackagesToExternalize` for why Vite does not do it on its own.\n * Node's built-ins are listed by hand for a related reason: Vite externalises\n * them for SSR only when it recognises the specifier, and a bare `crypto` —\n * which a backend written for Node may perfectly well import — resolved\n * instead to the abandoned `crypto` shim package sitting in node_modules, and\n * failed the build.\n *\n * `copyPublicDir` is off because `public/` is the client build's output, not\n * the backend's. Left on, it copied 38MB of already-built bundles into `lib/`.\n */\nexport const buildBackendWithVite = async (\n options: {appRoot?: string} = {},\n dependencies: {viteBuild?: (config: any) => Promise<unknown>} = {}\n): Promise<void> => {\n const appRoot = options.appRoot || process.cwd();\n const entries = resolveBackendEntries(appRoot);\n\n if (!entries.backend) {\n throw new Error(\n 'No backend entry found: expected src/backend.ts in ' + appRoot\n );\n }\n\n const viteBuild =\n dependencies.viteBuild ||\n (async (config: any) => {\n const {build} = await import('vite');\n return build(config);\n });\n\n const externalWorkspaces = await workspacePackagesToExternalize(appRoot);\n\n try {\n await viteBuild({\n root: appRoot,\n mode: 'production',\n isProduction: true,\n // The client build sets `base` to the release URL. The backend emits no\n // asset URLs of its own, so it must not inherit one.\n base: '/',\n // Never resolve a `development` export condition in a release build.\n //\n // The workspace-source convention is\n // \"development\": \"./src/*.ts\", \"import\": \"./lib/esm/*.js\"\n // and Vite expands its `development|production` token from NODE_ENV —\n // which during a release build is whatever the app's `.env` says,\n // routinely `development`. The package then resolves to TypeScript, which\n // cannot be externalised because Node could not load it, so it is\n // compiled in regardless of what `ssr.external` says.\n //\n // Dropping the token (rather than pinning it to `production`) leaves\n // `import` — which Vite always appends last — to win. Same treatment\n // `createViteConfig` already applies to a standalone install, for the\n // mirror-image reason.\n //\n // All three lists have to say it: `ssr.resolve.conditions` does not\n // inherit from `resolve.conditions` here, and `externalConditions`\n // governs the packages that end up external.\n resolve: {conditions: SERVER_CONDITIONS},\n ssr: {\n // Merged with the app's own ssr.external rather than replacing it.\n external: externalWorkspaces,\n resolve: {\n conditions: SERVER_CONDITIONS,\n externalConditions: SERVER_CONDITIONS,\n },\n },\n plugins: [dropManualChunks()],\n build: {\n ssr: true,\n outDir: 'lib',\n emptyOutDir: true,\n copyPublicDir: false,\n manifest: false,\n sourcemap: true,\n rollupOptions: {\n input: entries,\n external: NODE_BUILTINS,\n output: {\n format: 'es',\n preserveModules: true,\n preserveModulesRoot: path.join(appRoot, 'src'),\n entryFileNames: '[name].js',\n chunkFileNames: '[name].js',\n },\n },\n },\n });\n } catch (err) {\n const explained = explainUnresolvedWorkspaceImport(\n err instanceof Error ? err.message : String(err),\n externalWorkspaces\n );\n if (!explained) throw err;\n throw new Error(explained);\n }\n\n await assertNoInlinedWorkspaces(appRoot);\n};\n\n/**\n * Copy `src`'s CSS next to the compiled backend.\n *\n * The server reads stylesheets like `lib/css/theme.css` off disk by path, so\n * they have to exist as files whether or not any module imported them.\n */\nexport const copyBackendStylesheets = async (\n appRoot: string,\n listCssFiles: (dir: string) => Promise<string[]>\n): Promise<number> => {\n const sourceFolder = path.join(appRoot, 'src');\n const targetFolder = path.join(appRoot, 'lib');\n const cssFiles = await listCssFiles(sourceFolder);\n await Promise.all(\n cssFiles.map((file) => {\n const targetFile = file.replace(sourceFolder, targetFolder);\n fs.mkdirpSync(path.dirname(targetFile));\n return fs.copyFile(file, targetFile);\n })\n );\n return cssFiles.length;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-methods.d.ts","sourceRoot":"","sources":["../../src/cli-methods.ts"],"names":[],"mappings":"AA+BA,OAAO,KAAK,EACV,oBAAoB,EAErB,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"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