@_linked/cli 1.33.0 → 1.33.2
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 +16 -0
- package/lib/esm/css-module-names.d.ts +28 -0
- package/lib/esm/css-module-names.d.ts.map +1 -0
- package/lib/esm/css-module-names.js +103 -0
- package/lib/esm/css-module-names.js.map +1 -0
- package/lib/esm/index.d.ts +18 -18
- package/lib/esm/index.d.ts.map +1 -1
- package/lib/esm/index.js +16 -16
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/loaders/css-loader.d.mts.map +1 -1
- package/lib/esm/loaders/css-loader.mjs +8 -19
- package/lib/esm/loaders/css-loader.mjs.map +1 -1
- package/lib/esm/utils.d.ts +1 -1
- package/lib/esm/utils.d.ts.map +1 -1
- package/lib/esm/utils.js +1 -12
- package/lib/esm/utils.js.map +1 -1
- package/lib/esm/vite-config.d.ts.map +1 -1
- package/lib/esm/vite-config.js +4 -2
- package/lib/esm/vite-config.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.33.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#188](https://github.com/linked-fw/cli/pull/188) [`b160ea2`](https://github.com/linked-fw/cli/commit/b160ea2f1571bfba6708fc653dbc96d53503c235) Thanks [@flyon](https://github.com/flyon)! - Server-rendered components from packages now get the CSS-module class names the client's stylesheet defines.
|
|
8
|
+
|
|
9
|
+
In a production build the client (Vite) named CSS-module classes by a hash of the processed CSS, while the Node CSS loader that `serve-app` uses for packages in `node_modules` (e.g. every `@_linked/primitives` component) hashed the class with the file's absolute URL. The two never agreed, so every element the server rendered from a package carried a class no stylesheet defined — for example the loading spinner and `Typography` were unstyled on first load, and stayed unstyled after hydration because React does not patch class names.
|
|
10
|
+
|
|
11
|
+
Both now use one `generateScopedNameProduction`: `_<class>_<hash>`, hashing the owning package's name, the file's path inside it (without `src/`, `lib/esm/` or `lib/cjs/`) and the class, so the name does not depend on the install location or build flavour. The Node loader also finds every class a stylesheet defines (it used to miss a class directly followed by `{`, `.`, `,` or `>`, and truncated hyphenated ones), and uses the development names only when `NODE_ENV` is `development`, matching `startServer`.
|
|
12
|
+
|
|
13
|
+
## 1.33.1
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [#186](https://github.com/linked-fw/cli/pull/186) [`b0357c1`](https://github.com/linked-fw/cli/commit/b0357c14f4db5eabf55899e4503dde8f413616f8) Thanks [@flyon](https://github.com/flyon)! - `import('@_linked/cli')` works in Node again. The root entry re-exported its modules with extensionless specifiers (`./tailwind.config`, `./utils`, …), which Node's ESM resolver does not complete, so importing the package failed with `ERR_MODULE_NOT_FOUND`. The source now names the `.js` files, and a unit test rejects extensionless relative imports anywhere in `src`.
|
|
18
|
+
|
|
3
19
|
## 1.33.0
|
|
4
20
|
|
|
5
21
|
### Minor Changes
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a stylesheet lives, independent of where it is installed: the name of
|
|
3
|
+
* the nearest package.json that has one, and the path below it. The leading
|
|
4
|
+
* `src/`, `lib/`, `lib/esm/` or `lib/cjs/` is dropped, so a package resolved
|
|
5
|
+
* from its source, its ESM output or its CJS output yields the same location.
|
|
6
|
+
*/
|
|
7
|
+
export declare const cssModuleLocation: (filepath: string) => {
|
|
8
|
+
packageName: string;
|
|
9
|
+
relativePath: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* The production CSS-module class name: `_<class>_<hash>`. The underscore keeps
|
|
13
|
+
* it a valid CSS identifier even when the hash starts with a digit.
|
|
14
|
+
*/
|
|
15
|
+
export declare function generateScopedNameProduction(cssClassName: string, filepath: string, _css?: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* The local class names a stylesheet defines, as the Node loader reports them
|
|
18
|
+
* to the module that imports it. Comments are removed first so a commented-out
|
|
19
|
+
* rule does not produce a name.
|
|
20
|
+
*/
|
|
21
|
+
export declare const cssModuleClassNames: (source: string) => string[];
|
|
22
|
+
/**
|
|
23
|
+
* What `import styles from './x.module.css'` evaluates to on the server: each
|
|
24
|
+
* local class name mapped to its scoped name. `scope` is the naming function
|
|
25
|
+
* of the current mode.
|
|
26
|
+
*/
|
|
27
|
+
export declare const cssModuleExports: (source: string, filepath: string, scope?: (cssClassName: string, filepath: string) => string) => Record<string, string>;
|
|
28
|
+
//# sourceMappingURL=css-module-names.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"css-module-names.d.ts","sourceRoot":"","sources":["../../src/css-module-names.ts"],"names":[],"mappings":"AAsBA;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,UAAU,MAAM,KAAG;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAiC9F,CAAC;AAEF;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,UAQjG;AAED;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,QAAQ,MAAM,KAAG,MAAM,EAO1D,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAC3B,QAAQ,MAAM,EACd,UAAU,MAAM,EAChB,QAAO,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,MAAqC,KACvF,MAAM,CAAC,MAAM,EAAE,MAAM,CAMvB,CAAC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// CSS-module class names for production builds.
|
|
2
|
+
//
|
|
3
|
+
// A production app computes the same class name in three places, and they must
|
|
4
|
+
// agree or the element the server rendered carries a class no stylesheet defines:
|
|
5
|
+
//
|
|
6
|
+
// - the client build (Vite, `css.modules.generateScopedName`), which also
|
|
7
|
+
// writes the stylesheet;
|
|
8
|
+
// - the backend/SSR build of the app's own source (Vite again);
|
|
9
|
+
// - the Node runtime (`loaders/css-loader.mts`), which maps the `.module.css`
|
|
10
|
+
// files that externalised packages in node_modules import, e.g. every
|
|
11
|
+
// `@_linked/primitives` component.
|
|
12
|
+
//
|
|
13
|
+
// Vite's default name is a hash of the processed CSS text, which the Node loader
|
|
14
|
+
// cannot reproduce; the loader used to hash the absolute file URL, which the
|
|
15
|
+
// client build never sees and which changes with every install location. So the
|
|
16
|
+
// name is derived only from facts all three agree on: the owning package's
|
|
17
|
+
// name, the file's path inside that package with the build-output prefix
|
|
18
|
+
// removed, and the class.
|
|
19
|
+
import * as crypto from 'crypto';
|
|
20
|
+
import * as fs from 'fs';
|
|
21
|
+
import * as path from 'path';
|
|
22
|
+
/**
|
|
23
|
+
* Where a stylesheet lives, independent of where it is installed: the name of
|
|
24
|
+
* the nearest package.json that has one, and the path below it. The leading
|
|
25
|
+
* `src/`, `lib/`, `lib/esm/` or `lib/cjs/` is dropped, so a package resolved
|
|
26
|
+
* from its source, its ESM output or its CJS output yields the same location.
|
|
27
|
+
*/
|
|
28
|
+
export const cssModuleLocation = (filepath) => {
|
|
29
|
+
const clean = filepath
|
|
30
|
+
.replace(/\?.*$/, '')
|
|
31
|
+
.replace(/^file:\/\//, '');
|
|
32
|
+
let resolved = path.resolve(decodeURIComponent(clean));
|
|
33
|
+
try {
|
|
34
|
+
resolved = fs.realpathSync(resolved);
|
|
35
|
+
}
|
|
36
|
+
catch (_a) {
|
|
37
|
+
// A path that does not exist (tests, virtual modules) is used as given.
|
|
38
|
+
}
|
|
39
|
+
let dir = path.dirname(resolved);
|
|
40
|
+
for (;;) {
|
|
41
|
+
const manifest = path.join(dir, 'package.json');
|
|
42
|
+
if (fs.existsSync(manifest)) {
|
|
43
|
+
try {
|
|
44
|
+
const name = JSON.parse(fs.readFileSync(manifest, 'utf8')).name;
|
|
45
|
+
if (typeof name === 'string' && name) {
|
|
46
|
+
const relativePath = path
|
|
47
|
+
.relative(dir, resolved)
|
|
48
|
+
.split(path.sep)
|
|
49
|
+
.join('/')
|
|
50
|
+
.replace(/^(?:src|lib\/esm|lib\/cjs|lib)\//, '');
|
|
51
|
+
return { packageName: name, relativePath };
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
catch (_b) {
|
|
55
|
+
// An unreadable package.json does not name the package; keep walking.
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const parent = path.dirname(dir);
|
|
59
|
+
if (parent === dir)
|
|
60
|
+
break;
|
|
61
|
+
dir = parent;
|
|
62
|
+
}
|
|
63
|
+
return { packageName: 'unknown', relativePath: path.basename(resolved) };
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* The production CSS-module class name: `_<class>_<hash>`. The underscore keeps
|
|
67
|
+
* it a valid CSS identifier even when the hash starts with a digit.
|
|
68
|
+
*/
|
|
69
|
+
export function generateScopedNameProduction(cssClassName, filepath, _css) {
|
|
70
|
+
const { packageName, relativePath } = cssModuleLocation(filepath);
|
|
71
|
+
const hash = crypto
|
|
72
|
+
.createHash('md5')
|
|
73
|
+
.update(`${packageName}/${relativePath}:${cssClassName}`)
|
|
74
|
+
.digest('hex')
|
|
75
|
+
.substring(0, 6);
|
|
76
|
+
return `_${cssClassName}_${hash}`;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The local class names a stylesheet defines, as the Node loader reports them
|
|
80
|
+
* to the module that imports it. Comments are removed first so a commented-out
|
|
81
|
+
* rule does not produce a name.
|
|
82
|
+
*/
|
|
83
|
+
export const cssModuleClassNames = (source) => {
|
|
84
|
+
const withoutComments = source.replace(/\/\*[\s\S]*?\*\//g, '');
|
|
85
|
+
const names = new Set();
|
|
86
|
+
for (const match of withoutComments.matchAll(/\.(-?[_a-zA-Z][\w-]*)/g)) {
|
|
87
|
+
names.add(match[1]);
|
|
88
|
+
}
|
|
89
|
+
return [...names];
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* What `import styles from './x.module.css'` evaluates to on the server: each
|
|
93
|
+
* local class name mapped to its scoped name. `scope` is the naming function
|
|
94
|
+
* of the current mode.
|
|
95
|
+
*/
|
|
96
|
+
export const cssModuleExports = (source, filepath, scope = generateScopedNameProduction) => {
|
|
97
|
+
const output = {};
|
|
98
|
+
for (const name of cssModuleClassNames(source)) {
|
|
99
|
+
output[name] = scope(name, filepath);
|
|
100
|
+
}
|
|
101
|
+
return output;
|
|
102
|
+
};
|
|
103
|
+
//# sourceMappingURL=css-module-names.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"css-module-names.js","sourceRoot":"","sources":["../../src/css-module-names.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,EAAE;AACF,+EAA+E;AAC/E,kFAAkF;AAClF,EAAE;AACF,4EAA4E;AAC5E,6BAA6B;AAC7B,kEAAkE;AAClE,gFAAgF;AAChF,0EAA0E;AAC1E,uCAAuC;AACvC,EAAE;AACF,iFAAiF;AACjF,6EAA6E;AAC7E,gFAAgF;AAChF,2EAA2E;AAC3E,yEAAyE;AACzE,0BAA0B;AAC1B,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,QAAgB,EAA+C,EAAE;IACjG,MAAM,KAAK,GAAG,QAAQ;SACnB,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;SACpB,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;IAC7B,IAAI,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC;IACvD,IAAI,CAAC;QACH,QAAQ,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC;IAAC,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,CAAC;IAChE,MAAM,IAAI,GAAG,MAAM;SAChB,UAAU,CAAC,KAAK,CAAC;SACjB,MAAM,CAAC,GAAG,WAAW,IAAI,YAAY,IAAI,YAAY,EAAE,CAAC;SACxD,MAAM,CAAC,KAAK,CAAC;SACb,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACnB,OAAO,IAAI,YAAY,IAAI,IAAI,EAAE,CAAC;AACpC,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,MAAc,EAAY,EAAE;IAC9D,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAC;IAChE,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAChC,KAAK,MAAM,KAAK,IAAI,eAAe,CAAC,QAAQ,CAAC,wBAAwB,CAAC,EAAE,CAAC;QACvE,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACtB,CAAC;IACD,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC;AACpB,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,MAAc,EACd,QAAgB,EAChB,QAA4D,4BAA4B,EAChE,EAAE;IAC1B,MAAM,MAAM,GAA2B,EAAE,CAAC;IAC1C,KAAK,MAAM,IAAI,IAAI,mBAAmB,CAAC,MAAM,CAAC,EAAE,CAAC;QAC/C,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC","sourcesContent":["// CSS-module class names for production builds.\n//\n// A production app computes the same class name in three places, and they must\n// agree or the element the server rendered carries a class no stylesheet defines:\n//\n// - the client build (Vite, `css.modules.generateScopedName`), which also\n// writes the stylesheet;\n// - the backend/SSR build of the app's own source (Vite again);\n// - the Node runtime (`loaders/css-loader.mts`), which maps the `.module.css`\n// files that externalised packages in node_modules import, e.g. every\n// `@_linked/primitives` component.\n//\n// Vite's default name is a hash of the processed CSS text, which the Node loader\n// cannot reproduce; the loader used to hash the absolute file URL, which the\n// client build never sees and which changes with every install location. So the\n// name is derived only from facts all three agree on: the owning package's\n// name, the file's path inside that package with the build-output prefix\n// removed, and the class.\nimport * as crypto from 'crypto';\nimport * as fs from 'fs';\nimport * as path from 'path';\n\n/**\n * Where a stylesheet lives, independent of where it is installed: the name of\n * the nearest package.json that has one, and the path below it. The leading\n * `src/`, `lib/`, `lib/esm/` or `lib/cjs/` is dropped, so a package resolved\n * from its source, its ESM output or its CJS output yields the same location.\n */\nexport const cssModuleLocation = (filepath: string): {packageName: string; relativePath: string} => {\n const clean = filepath\n .replace(/\\?.*$/, '')\n .replace(/^file:\\/\\//, '');\n let resolved = path.resolve(decodeURIComponent(clean));\n try {\n resolved = fs.realpathSync(resolved);\n } catch {\n // A path that does not exist (tests, virtual modules) is used as given.\n }\n let dir = path.dirname(resolved);\n for (;;) {\n const manifest = path.join(dir, 'package.json');\n if (fs.existsSync(manifest)) {\n try {\n const name = JSON.parse(fs.readFileSync(manifest, 'utf8')).name;\n if (typeof name === 'string' && name) {\n const relativePath = path\n .relative(dir, resolved)\n .split(path.sep)\n .join('/')\n .replace(/^(?:src|lib\\/esm|lib\\/cjs|lib)\\//, '');\n return {packageName: name, relativePath};\n }\n } catch {\n // An unreadable package.json does not name the package; keep walking.\n }\n }\n const parent = path.dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n return {packageName: 'unknown', relativePath: path.basename(resolved)};\n};\n\n/**\n * The production CSS-module class name: `_<class>_<hash>`. The underscore keeps\n * it a valid CSS identifier even when the hash starts with a digit.\n */\nexport function generateScopedNameProduction(cssClassName: string, filepath: string, _css?: string) {\n const {packageName, relativePath} = cssModuleLocation(filepath);\n const hash = crypto\n .createHash('md5')\n .update(`${packageName}/${relativePath}:${cssClassName}`)\n .digest('hex')\n .substring(0, 6);\n return `_${cssClassName}_${hash}`;\n}\n\n/**\n * The local class names a stylesheet defines, as the Node loader reports them\n * to the module that imports it. Comments are removed first so a commented-out\n * rule does not produce a name.\n */\nexport const cssModuleClassNames = (source: string): string[] => {\n const withoutComments = source.replace(/\\/\\*[\\s\\S]*?\\*\\//g, '');\n const names = new Set<string>();\n for (const match of withoutComments.matchAll(/\\.(-?[_a-zA-Z][\\w-]*)/g)) {\n names.add(match[1]);\n }\n return [...names];\n};\n\n/**\n * What `import styles from './x.module.css'` evaluates to on the server: each\n * local class name mapped to its scoped name. `scope` is the naming function\n * of the current mode.\n */\nexport const cssModuleExports = (\n source: string,\n filepath: string,\n scope: (cssClassName: string, filepath: string) => string = generateScopedNameProduction,\n): Record<string, string> => {\n const output: Record<string, string> = {};\n for (const name of cssModuleClassNames(source)) {\n output[name] = scope(name, filepath);\n }\n return output;\n};\n"]}
|
package/lib/esm/index.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
export { default as tailwindConfig } from './tailwind.config';
|
|
2
|
-
export * from './utils';
|
|
3
|
-
export { defineConfig } from './defineConfig';
|
|
4
|
-
export type { LinkedConfig, LinkedServerConfig } from './interfaces';
|
|
5
|
-
export { buildPackageByPath } from './commands/build-package';
|
|
6
|
-
export { safeYarn } from './commands/safe-yarn';
|
|
7
|
-
export { setupPublish } from './commands/setup-publish';
|
|
8
|
-
export { resolveBuildTarget } from './app-release/resolve-build-target';
|
|
9
|
-
export { buildReleasePrefix, createReleaseManifest, getCacheControl, releaseBaseURL, releaseObjectKey, releaseStaticAccessURL, resolveReleaseIdentity, resolveSourceRevision, serializeReleaseManifest, writeReleaseManifest, DEFAULT_RELEASE_PREFIX, ENTRY_CACHE_CONTROL, IMMUTABLE_CACHE_CONTROL, MANIFEST_SOURCE_PATH, VITE_OUTPUT_DIR, } from './app-release/create-release-manifest';
|
|
10
|
-
export { resolveDeclaredStaticAssets } from './app-release/static-assets';
|
|
11
|
-
export { loadReleaseManifest, planReleasePublish, publishRelease, } from './app-release/publisher';
|
|
12
|
-
export { normalizeAccessURL, resolveAppAssetsStore, } from './app-release/app-assets-store';
|
|
13
|
-
export { buildViteApp, hasViteConfig } from './commands/build-app';
|
|
14
|
-
export { publishApp } from './commands/publish-app';
|
|
15
|
-
export { serveCompiledApp, validateCompiledAppArtifacts, } from './commands/serve-app';
|
|
16
|
-
export { joinObjectKey, joinStaticAssetUrl, normalizeReleasePath, resolveExistingPathWithinRoot, } from './app-release/paths';
|
|
17
|
-
export type { AppBuildTarget, AppPublishConfig, BuildAppOptions, LinkedAppReleaseDestination, LinkedAppReleaseFile, LinkedAppReleaseManifest, PublishPlan, PublishResult, } from './app-release/types';
|
|
18
|
-
export type { CreateReleaseManifestOptions, ReleaseFileOrigin, ReleaseIdentity, } from './app-release/create-release-manifest';
|
|
1
|
+
export { default as tailwindConfig } from './tailwind.config.js';
|
|
2
|
+
export * from './utils.js';
|
|
3
|
+
export { defineConfig } from './defineConfig.js';
|
|
4
|
+
export type { LinkedConfig, LinkedServerConfig } from './interfaces.js';
|
|
5
|
+
export { buildPackageByPath } from './commands/build-package.js';
|
|
6
|
+
export { safeYarn } from './commands/safe-yarn.js';
|
|
7
|
+
export { setupPublish } from './commands/setup-publish.js';
|
|
8
|
+
export { resolveBuildTarget } from './app-release/resolve-build-target.js';
|
|
9
|
+
export { buildReleasePrefix, createReleaseManifest, getCacheControl, releaseBaseURL, releaseObjectKey, releaseStaticAccessURL, resolveReleaseIdentity, resolveSourceRevision, serializeReleaseManifest, writeReleaseManifest, DEFAULT_RELEASE_PREFIX, ENTRY_CACHE_CONTROL, IMMUTABLE_CACHE_CONTROL, MANIFEST_SOURCE_PATH, VITE_OUTPUT_DIR, } from './app-release/create-release-manifest.js';
|
|
10
|
+
export { resolveDeclaredStaticAssets } from './app-release/static-assets.js';
|
|
11
|
+
export { loadReleaseManifest, planReleasePublish, publishRelease, } from './app-release/publisher.js';
|
|
12
|
+
export { normalizeAccessURL, resolveAppAssetsStore, } from './app-release/app-assets-store.js';
|
|
13
|
+
export { buildViteApp, hasViteConfig } from './commands/build-app.js';
|
|
14
|
+
export { publishApp } from './commands/publish-app.js';
|
|
15
|
+
export { serveCompiledApp, validateCompiledAppArtifacts, } from './commands/serve-app.js';
|
|
16
|
+
export { joinObjectKey, joinStaticAssetUrl, normalizeReleasePath, resolveExistingPathWithinRoot, } from './app-release/paths.js';
|
|
17
|
+
export type { AppBuildTarget, AppPublishConfig, BuildAppOptions, LinkedAppReleaseDestination, LinkedAppReleaseFile, LinkedAppReleaseManifest, PublishPlan, PublishResult, } from './app-release/types.js';
|
|
18
|
+
export type { CreateReleaseManifestOptions, ReleaseFileOrigin, ReleaseIdentity, } from './app-release/create-release-manifest.js';
|
|
19
19
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,cAAc,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,cAAc,EAAC,MAAM,sBAAsB,CAAC;AAE/D,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAC/C,YAAY,EAAC,YAAY,EAAE,kBAAkB,EAAC,MAAM,iBAAiB,CAAC;AAEtE,OAAO,EAAC,kBAAkB,EAAC,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAC,QAAQ,EAAC,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAC,YAAY,EAAC,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAC,kBAAkB,EAAC,MAAM,uCAAuC,CAAC;AACzE,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB,wBAAwB,EACxB,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,uBAAuB,EACvB,oBAAoB,EACpB,eAAe,GAChB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAC,2BAA2B,EAAC,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,GACf,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAC,YAAY,EAAE,aAAa,EAAC,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAC,UAAU,EAAC,MAAM,2BAA2B,CAAC;AACrD,OAAO,EACL,gBAAgB,EAChB,4BAA4B,GAC7B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,oBAAoB,EACpB,6BAA6B,GAC9B,MAAM,wBAAwB,CAAC;AAChC,YAAY,EACV,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,2BAA2B,EAC3B,oBAAoB,EACpB,wBAAwB,EACxB,WAAW,EACX,aAAa,GACd,MAAM,wBAAwB,CAAC;AAChC,YAAY,EACV,4BAA4B,EAC5B,iBAAiB,EACjB,eAAe,GAChB,MAAM,0CAA0C,CAAC"}
|
package/lib/esm/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
export { default as tailwindConfig } from './tailwind.config';
|
|
2
|
-
// export {buildMetadata} from './metadata';
|
|
3
|
-
export * from './utils';
|
|
4
|
-
export { defineConfig } from './defineConfig';
|
|
5
|
-
export { buildPackageByPath } from './commands/build-package';
|
|
6
|
-
export { safeYarn } from './commands/safe-yarn';
|
|
7
|
-
export { setupPublish } from './commands/setup-publish';
|
|
8
|
-
export { resolveBuildTarget } from './app-release/resolve-build-target';
|
|
9
|
-
export { buildReleasePrefix, createReleaseManifest, getCacheControl, releaseBaseURL, releaseObjectKey, releaseStaticAccessURL, resolveReleaseIdentity, resolveSourceRevision, serializeReleaseManifest, writeReleaseManifest, DEFAULT_RELEASE_PREFIX, ENTRY_CACHE_CONTROL, IMMUTABLE_CACHE_CONTROL, MANIFEST_SOURCE_PATH, VITE_OUTPUT_DIR, } from './app-release/create-release-manifest';
|
|
10
|
-
export { resolveDeclaredStaticAssets } from './app-release/static-assets';
|
|
11
|
-
export { loadReleaseManifest, planReleasePublish, publishRelease, } from './app-release/publisher';
|
|
12
|
-
export { normalizeAccessURL, resolveAppAssetsStore, } from './app-release/app-assets-store';
|
|
13
|
-
export { buildViteApp, hasViteConfig } from './commands/build-app';
|
|
14
|
-
export { publishApp } from './commands/publish-app';
|
|
15
|
-
export { serveCompiledApp, validateCompiledAppArtifacts, } from './commands/serve-app';
|
|
16
|
-
export { joinObjectKey, joinStaticAssetUrl, normalizeReleasePath, resolveExistingPathWithinRoot, } from './app-release/paths';
|
|
1
|
+
export { default as tailwindConfig } from './tailwind.config.js';
|
|
2
|
+
// export {buildMetadata} from './metadata.js';
|
|
3
|
+
export * from './utils.js';
|
|
4
|
+
export { defineConfig } from './defineConfig.js';
|
|
5
|
+
export { buildPackageByPath } from './commands/build-package.js';
|
|
6
|
+
export { safeYarn } from './commands/safe-yarn.js';
|
|
7
|
+
export { setupPublish } from './commands/setup-publish.js';
|
|
8
|
+
export { resolveBuildTarget } from './app-release/resolve-build-target.js';
|
|
9
|
+
export { buildReleasePrefix, createReleaseManifest, getCacheControl, releaseBaseURL, releaseObjectKey, releaseStaticAccessURL, resolveReleaseIdentity, resolveSourceRevision, serializeReleaseManifest, writeReleaseManifest, DEFAULT_RELEASE_PREFIX, ENTRY_CACHE_CONTROL, IMMUTABLE_CACHE_CONTROL, MANIFEST_SOURCE_PATH, VITE_OUTPUT_DIR, } from './app-release/create-release-manifest.js';
|
|
10
|
+
export { resolveDeclaredStaticAssets } from './app-release/static-assets.js';
|
|
11
|
+
export { loadReleaseManifest, planReleasePublish, publishRelease, } from './app-release/publisher.js';
|
|
12
|
+
export { normalizeAccessURL, resolveAppAssetsStore, } from './app-release/app-assets-store.js';
|
|
13
|
+
export { buildViteApp, hasViteConfig } from './commands/build-app.js';
|
|
14
|
+
export { publishApp } from './commands/publish-app.js';
|
|
15
|
+
export { serveCompiledApp, validateCompiledAppArtifacts, } from './commands/serve-app.js';
|
|
16
|
+
export { joinObjectKey, joinStaticAssetUrl, normalizeReleasePath, resolveExistingPathWithinRoot, } from './app-release/paths.js';
|
|
17
17
|
//# sourceMappingURL=index.js.map
|
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,cAAc,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,cAAc,EAAC,MAAM,sBAAsB,CAAC;AAC/D,+CAA+C;AAC/C,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAG/C,OAAO,EAAC,kBAAkB,EAAC,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAC,QAAQ,EAAC,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAC,YAAY,EAAC,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAC,kBAAkB,EAAC,MAAM,uCAAuC,CAAC;AACzE,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB,wBAAwB,EACxB,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,uBAAuB,EACvB,oBAAoB,EACpB,eAAe,GAChB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAC,2BAA2B,EAAC,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,GACf,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAC,YAAY,EAAE,aAAa,EAAC,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAC,UAAU,EAAC,MAAM,2BAA2B,CAAC;AACrD,OAAO,EACL,gBAAgB,EAChB,4BAA4B,GAC7B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,oBAAoB,EACpB,6BAA6B,GAC9B,MAAM,wBAAwB,CAAC","sourcesContent":["export {default as tailwindConfig} from './tailwind.config.js';\n// export {buildMetadata} from './metadata.js';\nexport * from './utils.js';\nexport {defineConfig} from './defineConfig.js';\nexport type {LinkedConfig, LinkedServerConfig} from './interfaces.js';\n\nexport {buildPackageByPath} from './commands/build-package.js';\nexport {safeYarn} from './commands/safe-yarn.js';\nexport {setupPublish} from './commands/setup-publish.js';\nexport {resolveBuildTarget} from './app-release/resolve-build-target.js';\nexport {\n buildReleasePrefix,\n createReleaseManifest,\n getCacheControl,\n releaseBaseURL,\n releaseObjectKey,\n releaseStaticAccessURL,\n resolveReleaseIdentity,\n resolveSourceRevision,\n serializeReleaseManifest,\n writeReleaseManifest,\n DEFAULT_RELEASE_PREFIX,\n ENTRY_CACHE_CONTROL,\n IMMUTABLE_CACHE_CONTROL,\n MANIFEST_SOURCE_PATH,\n VITE_OUTPUT_DIR,\n} from './app-release/create-release-manifest.js';\nexport {resolveDeclaredStaticAssets} from './app-release/static-assets.js';\nexport {\n loadReleaseManifest,\n planReleasePublish,\n publishRelease,\n} from './app-release/publisher.js';\nexport {\n normalizeAccessURL,\n resolveAppAssetsStore,\n} from './app-release/app-assets-store.js';\nexport {buildViteApp, hasViteConfig} from './commands/build-app.js';\nexport {publishApp} from './commands/publish-app.js';\nexport {\n serveCompiledApp,\n validateCompiledAppArtifacts,\n} from './commands/serve-app.js';\nexport {\n joinObjectKey,\n joinStaticAssetUrl,\n normalizeReleasePath,\n resolveExistingPathWithinRoot,\n} from './app-release/paths.js';\nexport type {\n AppBuildTarget,\n AppPublishConfig,\n BuildAppOptions,\n LinkedAppReleaseDestination,\n LinkedAppReleaseFile,\n LinkedAppReleaseManifest,\n PublishPlan,\n PublishResult,\n} from './app-release/types.js';\nexport type {\n CreateReleaseManifestOptions,\n ReleaseFileOrigin,\n ReleaseIdentity,\n} from './app-release/create-release-manifest.js';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"css-loader.d.mts","sourceRoot":"","sources":["../../../src/loaders/css-loader.mts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"css-loader.d.mts","sourceRoot":"","sources":["../../../src/loaders/css-loader.mts"],"names":[],"mappings":"AAmFA,eAAO,MAAO,OAAO,OAAE,IAAI,KAAiC,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import createLoader from 'create-esm-loader';
|
|
2
2
|
// import parseCSS from 'css-parse';
|
|
3
|
-
import { generateScopedName
|
|
3
|
+
import { generateScopedName } from '../utils.js';
|
|
4
|
+
import { cssModuleExports, generateScopedNameProduction } from '../css-module-names.js';
|
|
4
5
|
const cssLoader = {
|
|
5
6
|
resolve(specifier, opts) {
|
|
6
7
|
//check if the url is css
|
|
@@ -39,24 +40,12 @@ const cssLoader = {
|
|
|
39
40
|
},
|
|
40
41
|
};
|
|
41
42
|
function parseCssToObject(rawSource, filename) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
})
|
|
49
|
-
.forEach((selector) => {
|
|
50
|
-
let scopedClassName;
|
|
51
|
-
if (process.env.NODE_ENV === 'production') {
|
|
52
|
-
scopedClassName = generateScopedNameProduction(selector, filename);
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
scopedClassName = generateScopedName(selector, filename);
|
|
56
|
-
}
|
|
57
|
-
output[selector] = scopedClassName;
|
|
58
|
-
});
|
|
59
|
-
}
|
|
43
|
+
// Must produce the names the Vite builds produce for the same file — see
|
|
44
|
+
// css-module-names.ts. The server renders with these; the client's stylesheet
|
|
45
|
+
// is written with Vite's. Anything but a development run serves compiled
|
|
46
|
+
// output (see startServer), so only 'development' gets the dev names — a
|
|
47
|
+
// `staging` or unset NODE_ENV must still match the production stylesheet.
|
|
48
|
+
const output = cssModuleExports(rawSource, filename, process.env.NODE_ENV === 'development' ? generateScopedName : generateScopedNameProduction);
|
|
60
49
|
// console.log(myResults);
|
|
61
50
|
// for (const rule of parseCSS(rawSource).stylesheet.rules) {
|
|
62
51
|
// if(rule.selectors)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"css-loader.mjs","sourceRoot":"","sources":["../../../src/loaders/css-loader.mts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,mBAAmB,CAAC;AAC7C,oCAAoC;AACpC,OAAO,EAAC,kBAAkB,EAAE,4BAA4B,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"css-loader.mjs","sourceRoot":"","sources":["../../../src/loaders/css-loader.mts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,mBAAmB,CAAC;AAC7C,oCAAoC;AACpC,OAAO,EAAC,kBAAkB,EAAC,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAC,gBAAgB,EAAE,4BAA4B,EAAC,MAAM,wBAAwB,CAAC;AAEtF,MAAM,SAAS,GAAG;IAChB,OAAO,CAAC,SAAS,EAAE,IAAI;QACrB,yBAAyB;QACzB,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YAC/B,uDAAuD;YACvD,uEAAuE;YACvE,IAAI,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC9B,yGAAyG;gBACzG,IAAI,EAAC,SAAS,EAAC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;IAC7D,uBAAuB;IACvB,MAAM;IACN,mHAAmH;IACnH,iEAAiE;IACjE,EAAE;IACF,0BAA0B;IAC1B,8CAA8C;IAC9C,sFAAsF;IACtF,EAAE;IACF,0EAA0E;IAC1E,qBAAqB;IACrB,MAAM;IACN,IAAI;IAEJ,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,cAAc,CAAC,YAAY;IAClC,MAAM,MAAM,GAAG,EAAE,CAAC;IAElB,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;QACvC,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;IACzD,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AACD,YAAY;AACZ,MAAM,CAAC,MAAM,EAAC,OAAO,EAAE,IAAI,EAAC,GAAG,MAAM,YAAY,CAAC,SAAS,CAAC,CAAC","sourcesContent":["import createLoader from 'create-esm-loader';\n// import parseCSS from 'css-parse';\nimport {generateScopedName} from '../utils.js';\nimport {cssModuleExports, generateScopedNameProduction} from '../css-module-names.js';\n\nconst cssLoader = {\n resolve(specifier, opts) {\n //check if the url is css\n if (specifier.endsWith('.css')) {\n // console.log(`##LOADER option resolve ${specifier}`);\n //and not a node_module (because we don't need to process node_modules)\n if (specifier.startsWith('.')) {\n // console.log(`##LOADER resolve ${specifier} - ${specifier.startsWith('.') ? 'local' : 'node_module'}`);\n let {parentURL} = opts;\n let url = new URL(specifier, parentURL).href;\n return {url};\n } else {\n // console.log(`##LOADER NOT RESOLVING ${specifier}`);\n }\n }\n },\n format(url, opts) {\n //check if the url is css and not a node_module\n if (url.endsWith('.css')) {\n // console.log(`##LOADER format ${url} - ${url.startsWith('.') ? 'local' : 'node_module'}`);\n\n return {format: 'module'};\n }\n },\n transform(source, opts) {\n const {url} = opts;\n //check if the url is css and not a node_module\n if (url.endsWith('.css')) {\n // console.log(`##LOADER transform ${url} - ${url.startsWith('.') ? 'local' : 'node_module'}`);\n //if yes, convert the CSS source to a JSON object with original selectors as keys\n //and the converted class names as values\n let cssClassesObject = parseCssToObject(String(source), opts.url);\n let finalSource = JSON.stringify(cssClassesObject, null, 2);\n return {source: `export default ${finalSource};`};\n }\n },\n};\n\nfunction parseCssToObject(rawSource: string, filename) {\n // Must produce the names the Vite builds produce for the same file — see\n // css-module-names.ts. The server renders with these; the client's stylesheet\n // is written with Vite's. Anything but a development run serves compiled\n // output (see startServer), so only 'development' gets the dev names — a\n // `staging` or unset NODE_ENV must still match the production stylesheet.\n const output = cssModuleExports(\n rawSource,\n filename,\n process.env.NODE_ENV === 'development' ? generateScopedName : generateScopedNameProduction,\n );\n // console.log(myResults);\n // for (const rule of parseCSS(rawSource).stylesheet.rules) {\n // if(rule.selectors)\n // {\n // let selector = rule['selectors'].at(-1); // Get right-most in the selector rule: `.Bar` in `.Foo > .Bar {…}`\n // if (selector[0] !== '.') break; // only care about classes\n //\n // selector = selector\n // .substring(1) // Skip the initial `.`\n // .match(/(\\w+)/)[1]; // Get only the classname: `Qux` in `.Qux[type=\"number\"]`\n //\n // output[selector] = selector;//getClassStyles(rule['declarations']);\n // // : selector;\n // }\n // }\n\n return output;\n}\n\nfunction getClassStyles(declarations) {\n const styles = {};\n\n for (const declaration of declarations) {\n styles[declaration['property']] = declaration['value'];\n }\n\n return styles;\n}\n//@ts-ignore\nexport const {resolve, load} = await createLoader(cssLoader);\n"]}
|
package/lib/esm/utils.d.ts
CHANGED
|
@@ -58,7 +58,7 @@ export declare const getLastModifiedFile: (filePath: any, config?: {}) => {
|
|
|
58
58
|
export declare var getModulePackageJSON: (module_name: any, work_dir?: any) => any;
|
|
59
59
|
export declare function execp(cmd: any, log?: boolean, allowError?: boolean, options?: any): Promise<null>;
|
|
60
60
|
export declare function execPromise(command: any, log?: boolean, allowError?: boolean, options?: ExecOptions, pipeOutput?: boolean): Promise<string>;
|
|
61
|
-
export
|
|
61
|
+
export { generateScopedNameProduction } from './css-module-names.js';
|
|
62
62
|
export declare function generateScopedName(cssClassName: any, filepath: any, css?: any): string;
|
|
63
63
|
export declare const needsRebuilding: (pkg: PackageDetails, useGitForLastModified: boolean, log?: boolean) => Promise<boolean>;
|
|
64
64
|
export declare function log(...messages: any[]): void;
|
package/lib/esm/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAO,WAAW,EAAC,MAAM,eAAe,CAAC;AAKhD,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAO,WAAW,EAAC,MAAM,eAAe,CAAC;AAKhD,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,iBAAiB,CAAC;AAsBpD,eAAO,IAAI,cAAc,GAAmB,aAAQ,sBAwEnD,CAAC;AA4BF;;;;;;;;;;;;;GAaG;AACH,eAAO,IAAI,sBAAsB,GAAa,YAAY,MAAM,YAQ/D,CAAC;AACF;;;;;;;;GAQG;AACH,eAAO,IAAI,wBAAwB,GACjC,YAAY,MAAM,EAClB,cAAc,MAAM,YAerB,CAAC;AAEF,eAAO,IAAI,cAAc,GAAa,aAAoB,EAAE,eAAY,QAcvE,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,IAAI,oBAAoB,GAC7B,iBAAY,EACZ,kBAAiB,GAAG,CAAC,MAAM,CAAa,KACvC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,EA2I5B,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,gBAAW;;;;CAE3C,CAAC;AAEF,eAAO,MAAM,yBAAyB,GAAI,gBAAW;;;;CAUpD,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAC5B,gBAAW,KACV,OAAO,CAAC;IAAC,IAAI,EAAE,IAAI,CAAC;IAAC,OAA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B,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7C"}
|
package/lib/esm/utils.js
CHANGED
|
@@ -13,7 +13,6 @@ import * as fs from 'fs';
|
|
|
13
13
|
import { builtinModules } from 'module';
|
|
14
14
|
import * as path from 'path';
|
|
15
15
|
import ts from 'typescript';
|
|
16
|
-
import * as crypto from 'crypto';
|
|
17
16
|
import { findNearestPackageJsonSync } from 'find-nearest-package-json';
|
|
18
17
|
import * as glob from 'glob';
|
|
19
18
|
var gruntConfig;
|
|
@@ -446,17 +445,7 @@ export function execPromise(command, log = false, allowError = false, options, p
|
|
|
446
445
|
}
|
|
447
446
|
});
|
|
448
447
|
}
|
|
449
|
-
export
|
|
450
|
-
//for app development we can use short unique hashes
|
|
451
|
-
//but for bundles of lincd modules, we need to ensure unique class names across bundles of many packages
|
|
452
|
-
//generate a short unique hash based on cssClassName and filepath
|
|
453
|
-
let hash = crypto
|
|
454
|
-
.createHash('md5')
|
|
455
|
-
.update(cssClassName + filepath)
|
|
456
|
-
.digest('hex')
|
|
457
|
-
.substring(0, 6);
|
|
458
|
-
return hash;
|
|
459
|
-
}
|
|
448
|
+
export { generateScopedNameProduction } from './css-module-names.js';
|
|
460
449
|
export function generateScopedName(cssClassName, filepath, css) {
|
|
461
450
|
// Strip any Vite-style query suffix (?inline, ?raw, ?direct) before
|
|
462
451
|
// computing the filename. Without this, dev-mode SSR CSS collection
|
package/lib/esm/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,IAAI,EAAc,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAAC,cAAc,EAAC,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAA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AE,EAAE,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["import chalk from 'chalk';\nimport {exec, ExecOptions} from 'child_process';\nimport * as fs from 'fs';\nimport {builtinModules} from 'module';\nimport * as path from 'path';\nimport ts from 'typescript';\nimport type {PackageDetails} from './interfaces.js';\n\nimport * as crypto from 'crypto';\nimport {findNearestPackageJsonSync} from 'find-nearest-package-json';\nimport * as glob from 'glob';\n\nvar gruntConfig;\n\n// Credit: https://gist.github.com/tinovyatkin/727ddbf7e7e10831a1eca9e4ff2fc32e\nconst tsHost = ts.createCompilerHost(\n {\n allowJs: true,\n noEmit: true,\n isolatedModules: true,\n resolveJsonModule: false,\n moduleResolution: ts.ModuleResolutionKind.Classic, // we don't want node_modules\n incremental: true,\n noLib: true,\n noResolve: true,\n },\n true,\n);\n\nexport var getFileImports = async function (filePath) {\n try {\n const importing: string[] = [];\n\n const add = (literal: ts.Node) => {\n const moduleName = literal.getText().replace(/['\"`]/g, '');\n if (\n !moduleName.startsWith('node:') &&\n !builtinModules.includes(moduleName)\n ) {\n importing.push(moduleName);\n }\n };\n // Every form that names a module: `import ... from 'x'`, `import 'x'`,\n // `export ... from 'x'`, `import('x')` (value and type position) and\n // `import x = require('x')`. Children are always visited, so specifiers\n // nested inside functions or a `declare module` body are found too.\n const delintNode = (node: ts.Node) => {\n if (\n (ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) &&\n node.moduleSpecifier &&\n ts.isStringLiteralLike(node.moduleSpecifier)\n ) {\n add(node.moduleSpecifier);\n } else if (\n ts.isCallExpression(node) &&\n node.expression.kind === ts.SyntaxKind.ImportKeyword &&\n node.arguments.length >= 1 &&\n ts.isStringLiteralLike(node.arguments[0])\n ) {\n // `import('x')` with a literal argument. A computed specifier cannot be\n // checked statically and is skipped.\n add(node.arguments[0]);\n } else if (\n // `type A = import('x').B`, and the same inside `typeof import('x')`.\n ts.isImportTypeNode(node) &&\n ts.isLiteralTypeNode(node.argument) &&\n ts.isStringLiteral(node.argument.literal)\n ) {\n add(node.argument.literal);\n } else if (\n // `import x = require('x')`.\n ts.isExternalModuleReference(node) &&\n ts.isStringLiteralLike(node.expression)\n ) {\n add(node.expression);\n }\n ts.forEachChild(node, delintNode);\n };\n const sourceFile = tsHost.getSourceFile(\n filePath,\n ts.ScriptTarget.Latest,\n (msg) => {\n throw new Error(`Failed to parse ${filePath}: ${msg}`);\n },\n );\n //check if its a directory, then we wanr that we can't parse it\n let stat = fs.lstatSync(filePath);\n if (stat.isDirectory()) {\n return importing;\n }\n\n if (!sourceFile) {\n console.warn(`Failed to find file ${filePath}`);\n return importing;\n }\n delintNode(sourceFile);\n return importing;\n } catch (err) {\n console.warn(`Error parsing file ${filePath}: ${err}`);\n return [];\n }\n};\n\n// The package name part of a bare specifier: '@scope/name' for a scoped\n// package, the first segment otherwise. Returns null for anything that is not a\n// bare specifier (relative and absolute paths). The 'node:' case is redundant\n// for callers that use getFileImports (which drops builtins already), and is\n// kept so the helper is correct standalone.\nvar barePackageName = function (importPath: string): string | null {\n if (\n importPath.startsWith('.') ||\n importPath.startsWith('/') ||\n importPath.startsWith('node:')\n ) {\n return null;\n }\n const segments = importPath.split('/');\n const name = importPath.startsWith('@')\n ? segments.slice(0, 2).join('/')\n : segments[0];\n return name || null;\n};\n\nvar isLinkedPackageName = function (name: string) {\n // The current '@_linked/*' scope, and the legacy 'lincd'-prefixed names\n // ('lincd', 'lincd-foo', ...).\n return name.startsWith('@_linked/') || /^lincd(-|$)/.test(name);\n};\n\n/**\n * True when the import reaches into ANOTHER Linked package's internals — a\n * '/src/' or '/lib/' path inside '@_linked/<pkg>' or a 'lincd'-prefixed package\n * — instead of going through that package's public subpath. Such an import\n * breaks when the other package changes its build layout, and it bypasses the\n * exports map, so the two are not interchangeable.\n *\n * Relative specifiers are exempt on purpose: the rule is about other packages,\n * and a relative path can only reach files inside the current package, where a\n * './lib/helpers' folder is a perfectly ordinary local module. Escaping the\n * package with '../' is already caught by isImportOutsideOfPackage.\n *\n * @param importPath The import path to check\n */\nexport var isInternalLinkedImport = function (importPath: string) {\n const name = barePackageName(importPath);\n if (!name || !isLinkedPackageName(name)) {\n return false;\n }\n // Match whole path segments, so '@_linked/core/library/x' is not a hit.\n const subPath = importPath.slice(name.length).split('/').filter(Boolean);\n return subPath.includes('src') || subPath.includes('lib');\n};\n/**\n * True when a relative import escapes the package source root. Normalising\n * first is what makes this correct: only leading '..' segments that survive\n * normalisation actually climb out, so './a..b' is an ordinary file name and\n * '../a/../b' climbs one level, not two.\n *\n * @param importPath The import path to check\n * @param curFileDepth How many folders deep the current file is (0 = src, 1 = src/foo, etc.)\n */\nexport var isImportOutsideOfPackage = function (\n importPath: string,\n curFileDepth: number,\n) {\n if (!importPath.startsWith('.')) {\n return false;\n }\n const segments = path.posix\n .normalize(importPath.split('\\\\').join('/'))\n .split('/');\n // How many folders the specifier climbs: the leading '..' segments that\n // normalisation could not cancel out.\n let climbs = 0;\n while (segments[climbs] === '..') {\n climbs++;\n }\n return climbs > curFileDepth;\n};\n\nexport var getPackageJSON = function (root = process.cwd(), error = true) {\n // console.log('Getting package.json from ' + chalk.cyan(root));\n //log stack trace\n let packagePath = path.join(root, 'package.json');\n if (fs.existsSync(packagePath)) {\n return JSON.parse(fs.readFileSync(packagePath, 'utf8'));\n } else if (root === process.cwd()) {\n if (error) {\n console.warn(\n 'Could not find package.json. Make sure you run this command from the root of a linked package or a linked workspace',\n );\n process.exit();\n }\n }\n};\n\n/**\n * Scans package.json for dependencies that are LINCD packages\n * Also looks into dependencies of dependencies\n * If no packageJson is given, it will attempt to obtain it from the current working directory\n * Returns an array of lincd packages, with each entry containing an array with the package name and the local path to the package\n * @param packageJson\n */\nexport var getLINCDDependencies = function (\n packageJson?,\n checkedPackages: Set<string> = new Set(),\n): [string, string, string[]][] {\n if (!packageJson) {\n packageJson = getPackageJSON();\n }\n let dependencies = {\n ...packageJson.dependencies,\n ...packageJson.devDependencies,\n };\n let lincdPackagePaths: [string, string, string[]][] = [];\n let firstTime = checkedPackages.size === 0;\n\n for (var dependency of Object.keys(dependencies)) {\n try {\n if (!checkedPackages.has(dependency)) {\n let [modulePackageJson, modulePath] = getModulePackageJSON(dependency);\n checkedPackages.add(dependency);\n\n if (modulePackageJson?.lincd) {\n lincdPackagePaths.push([\n modulePackageJson.name,\n modulePath,\n [\n ...Object.keys({\n ...modulePackageJson.dependencies,\n ...modulePackageJson.devDependencies,\n }),\n ],\n ]);\n //also check if this package has any dependencies that are lincd packages\n lincdPackagePaths = lincdPackagePaths.concat(\n getLINCDDependencies(modulePackageJson, checkedPackages),\n );\n }\n if (!modulePackageJson) {\n //this seems to only happen with yarn workspaces for some grunt related dependencies of lincd-cli\n // console.log(`could not find package.json of ${dependency}`);\n }\n }\n } catch (err) {\n console.log(\n `could not check if ${dependency} is a lincd package: ${err}`,\n );\n }\n }\n\n if (firstTime) {\n // let dependencyMap:Map<string,Set<string>> = new Map();\n let lincdPackageNames = new Set(\n lincdPackagePaths.map(\n ([packageName, modulePath, pkgDependencies]) => packageName,\n ),\n );\n //remove lincd-cli from the list of lincd packages\n lincdPackageNames.delete('lincd-cli');\n\n lincdPackagePaths.forEach(\n ([packageName, modulePath, pkgDependencies], key) => {\n let lincdDependencies = pkgDependencies.filter((dependency) =>\n lincdPackageNames.has(dependency),\n );\n if (packageName === 'lincd-cli') {\n //remove lincd-modules from the dependencies of lincd-cli (it's not a hard dependency, and it messes things up)\n lincdDependencies.splice(\n lincdDependencies.indexOf('lincd-modules'),\n 1,\n );\n }\n // dependencyMap.set(packageName, new Set(lincdDependencies));\n //update dependencies to be the actual lincd package objects\n lincdPackagePaths[key][2] = lincdDependencies;\n },\n );\n\n // //add the nested dependencies for each lincd package\n // for (let [packageName,pkgDependencies] of dependencyMap) {\n // pkgDependencies.forEach((dependency) => {\n // if (dependencyMap.has(dependency)) {\n // dependencyMap.get(dependency).forEach((nestedDependency) => {\n // pkgDependencies.add(nestedDependency);\n // });\n // }\n // });\n // }\n //\n // dependencyMap.forEach((dependencies,packageName) => {\n // //check for circular dependencies\n // if([...dependencies].some(dependency => {\n // return dependencyMap.get(dependency).has(packageName);\n // }))\n // {\n // console.warn(`Circular dependency detected between ${packageName} and ${dependency}`);\n // }\n //\n // });\n\n // a simple sort with dependencyMap doesn't seem to work,so we start with LINCD (least dependencies) and from there add packages that have all their dependencies already added\n let sortedPackagePaths = [];\n let addedPackages = new Set();\n let lincdItself = lincdPackagePaths.find(([packageName]) => {\n return packageName === 'lincd';\n });\n if (lincdItself) {\n sortedPackagePaths.push(lincdItself);\n addedPackages = new Set(['lincd']);\n }\n\n while (addedPackages.size !== lincdPackagePaths.length) {\n let startSize = addedPackages.size;\n lincdPackagePaths.forEach(\n ([packageName, modulePath, pkgDependencies]) => {\n if (\n !addedPackages.has(packageName) &&\n pkgDependencies.every((dependency) => addedPackages.has(dependency))\n ) {\n sortedPackagePaths.push([packageName, modulePath, pkgDependencies]);\n addedPackages.add(packageName);\n }\n },\n );\n if (startSize === addedPackages.size) {\n console.warn('Could not sort lincd packages, circular dependencies?');\n break;\n }\n }\n\n //sort the lincd packages by least dependent first\n // lincdPackagePaths = lincdPackagePaths.sort(([packageNameA],[packageNameB]) => {\n // //if package A depends on package B, then package B should come first\n // if (dependencyMap.get(packageNameA).has(packageNameB)) {\n // console.log(packageNameA+' depends on '+packageNameB+ ' (below)')\n // return 1;\n // }\n // console.log(packageNameA+' above '+packageNameB)\n // return -1;\n // });\n return sortedPackagePaths;\n }\n\n return lincdPackagePaths;\n};\n\nexport const getLastBuildTime = (packagePath) => {\n return getLastModifiedFile(packagePath + '/@(builds|lib|dist)/**/*.js');\n};\n\nexport const getLastModifiedSourceTime = (packagePath) => {\n return getLastModifiedFile(packagePath + '/@(src|data|css|modules)/**/*', {\n ignore: [\n packagePath + '/**/*.css.json',\n packagePath + '/**/*.d.ts',\n packagePath + '/**/node_modules/**/*',\n packagePath + '/**/lib/**/*',\n packagePath + '/**/dist/**/*',\n ],\n });\n};\n\nexport const getLastCommitTime = (\n packagePath,\n): Promise<{date: Date; changes: string; commitId: string}> => {\n // console.log(`git log -1 --format=%ci -- ${packagePath}`);\n // process.exit();\n return execPromise(`cd ${packagePath} && git log -1 --format=\"%h %ci\" -- .`)\n .then(async (result) => {\n let commitId = result.substring(0, result.indexOf(' '));\n let date = result.substring(commitId.length + 1);\n let lastCommitDate = new Date(date);\n\n let changes = await execPromise(\n `cd ${packagePath} && git show --stat --oneline ${commitId} -- .`,\n );\n // log(packagePath, result, lastCommitDate);\n // log(changes);\n return {date: lastCommitDate, changes, commitId};\n })\n .catch(({error, stdout, stderr}) => {\n debugInfo(chalk.red('Git error: ') + error.message.toString());\n return null;\n });\n};\n\nexport const getLastModifiedFile = (filePath, config = {}) => {\n var files = glob.sync(filePath, config);\n\n // console.log(files.join(\" - \"));\n var lastModifiedName;\n var lastModified: Date;\n var lastModifiedTime = 0;\n files.forEach((fileName) => {\n if (fs.lstatSync(fileName).isDirectory()) {\n // console.log(\"skipping directory \"+fileName);\n return;\n }\n let mtime = fs.statSync(path.join(fileName)).mtime;\n let modifiedTime = mtime.getTime();\n if (modifiedTime > lastModifiedTime) {\n // console.log(fileName,mtime);\n lastModifiedName = fileName;\n lastModified = mtime;\n lastModifiedTime = modifiedTime;\n }\n });\n return {lastModified, lastModifiedName, lastModifiedTime};\n};\n\n//from https://github.com/haalcala/node-packagejson/blob/master/index.js\nexport var getModulePackageJSON = function (module_name, work_dir?) {\n if (!work_dir) {\n work_dir = process.cwd();\n } else {\n work_dir = path.resolve(work_dir);\n }\n\n var package_json;\n\n if (fs.existsSync(path.resolve(work_dir, './node_modules'))) {\n var module_dir = path.resolve(work_dir, './node_modules/' + module_name);\n\n if (\n fs.existsSync(module_dir) &&\n fs.existsSync(module_dir + '/package.json')\n ) {\n package_json = JSON.parse(\n fs.readFileSync(module_dir + '/package.json', 'utf-8'),\n );\n }\n }\n\n if (!package_json && work_dir != '/') {\n return getModulePackageJSON(module_name, path.resolve(work_dir, '..'));\n }\n\n return [package_json, module_dir];\n};\nexport function execp(\n cmd,\n log: boolean = false,\n allowError: boolean = false,\n options: any = {},\n): Promise<null> {\n // opts || (opts = {});\n if (log) console.log(chalk.cyan(cmd));\n\n return new Promise((resolve, reject) => {\n var child = exec(cmd, options);\n\n child.stdout.pipe(process.stdout);\n child.stderr.pipe(process.stderr);\n // process.stdin.pipe(child.stdin);\n\n child.on('close', function (code) {\n if (code === 0) {\n resolve(null);\n } else {\n reject();\n }\n // console.log('killing child');\n // child.kill('SIGHUP');\n // resolve(code);\n });\n // child.on('data', function (result) {\n // \t// if (log)\n // \t// {\n // \t// \tconsole.log(result);\n // \t// }\n // \tresolve(result);\n // \tconsole.log('resolve data');\n //\n // });\n\n child.on('error', function (err) {\n if (!allowError) {\n // console.log('reject err');\n reject(err);\n return;\n } else if (log) {\n console.warn(err);\n }\n // console.log('resolve err');\n resolve(null);\n });\n child.on('exit', function (code, signal) {\n if (code !== 0) {\n reject('Child process exited with error code ' + code);\n return;\n }\n // console.log('resolve exit');\n resolve(null);\n });\n });\n}\n\nexport function execPromise(\n command,\n log = false,\n allowError: boolean = false,\n options?: ExecOptions,\n pipeOutput: boolean = false,\n): Promise<string> {\n return new Promise(function (resolve, reject) {\n if (log) console.log(chalk.cyan(command));\n let child = exec(command, options, (error, stdout, stderr) => {\n if (error) {\n if (!allowError) {\n reject({error, stdout, stderr});\n return;\n } else if (log) {\n console.warn(error);\n }\n }\n //TODO: getting a typescript error for 'trim()', this worked before, is it still used? do we log anywhere?\n let result = stdout['trim']();\n if (log) {\n // console.log(chalk\"RESOLVING \"+command);\n console.log(result);\n // console.log('ERRORS:'+(result.indexOf('Aborted due to warnings') !== -1));\n // console.log('stderr:'+stderr);\n }\n resolve(result);\n });\n if (pipeOutput) {\n child.stdout.pipe(process.stdout);\n child.stderr.pipe(process.stderr);\n }\n });\n}\n\nexport function generateScopedNameProduction(cssClassName, filepath, css?) {\n //for app development we can use short unique hashes\n //but for bundles of lincd modules, we need to ensure unique class names across bundles of many packages\n //generate a short unique hash based on cssClassName and filepath\n let hash = crypto\n .createHash('md5')\n .update(cssClassName + filepath)\n .digest('hex')\n .substring(0, 6);\n return hash;\n}\nexport function generateScopedName(cssClassName, filepath, css?) {\n // Strip any Vite-style query suffix (?inline, ?raw, ?direct) before\n // computing the filename. Without this, dev-mode SSR CSS collection\n // via `?inline` produces selectors like\n // `._foo_SigninLayout.module.css?inline_leftSidebar` — the literal\n // `.module.css?inline` becomes part of the class name, which CSS\n // parsers split on `.` and `?`, breaking everything.\n const cleanFilepath = filepath.replace(/\\?.*$/, '');\n var filename = path\n .basename(cleanFilepath)\n .replace(/\\.module\\.css$/, '')\n .replace(/\\.css$/, '');\n let resolved = path.resolve(cleanFilepath).replace(/[\\w\\-_\\/]+\\/file\\:/, '');\n let nearestPackageJson = findNearestPackageJsonSync(resolved);\n let packageName = nearestPackageJson\n ? nearestPackageJson.data.name\n : 'unknown';\n return (\n packageName.replace(/[^a-zA-Z0-9_]+/g, '_') +\n '_' +\n filename +\n '_' +\n cssClassName\n );\n}\n\nexport const needsRebuilding = async function (\n pkg: PackageDetails,\n useGitForLastModified: boolean,\n log: boolean = false,\n) {\n let lastModifiedSourceDate: Date;\n let lastModifiedSourceName: string;\n\n if (useGitForLastModified) {\n const {changes, commitId, date} = await getLastCommitTime(pkg.path);\n\n lastModifiedSourceDate = date;\n lastModifiedSourceName = commitId;\n } else {\n const {lastModified, lastModifiedName, lastModifiedTime} =\n getLastModifiedSourceTime(pkg.path);\n lastModifiedSourceName = lastModifiedName;\n lastModifiedSourceDate = lastModified;\n }\n\n let lastModifiedBundle = getLastBuildTime(pkg.path);\n let result =\n lastModifiedSourceDate &&\n lastModifiedSourceDate.getTime() > lastModifiedBundle.lastModifiedTime;\n if (log) {\n console.log(\n chalk.cyan(\n 'Last modified source: ' +\n lastModifiedSourceName +\n ' on ' +\n lastModifiedSourceDate.toString(),\n ),\n );\n console.log(\n chalk.cyan(\n 'Last build: ' +\n (lastModifiedBundle &&\n typeof lastModifiedBundle.lastModified !== 'undefined'\n ? lastModifiedBundle.lastModified.toString()\n : 'never'),\n ),\n );\n }\n return result;\n};\n\nexport function log(...messages) {\n messages.forEach((message) => {\n console.log(chalk.cyan(message));\n });\n}\n\nexport function debug(config, ...messages) {\n if (config.debug) {\n log(...messages);\n }\n}\n\nexport function debugInfo(...messages) {\n // messages.forEach((message) => {\n // console.log(chalk.cyan('Info: ') + message);\n // });\n //@TODO: let packages also use linked.config.json? instead of gruntfile...\n // that way we can read \"analyse\" here and see if we need to log debug info\n // if(!gruntConfig)\n // {\n // gruntConfig = getGruntConfig();\n // console.log(gruntConfig);\n // process.exit();\n // }\n if (gruntConfig && gruntConfig.analyse === true) {\n messages.forEach((message) => {\n console.log(chalk.cyan('Info: ') + message);\n });\n }\n}\n\nexport function warn(...messages) {\n messages.forEach((message) => {\n console.log(chalk.red(message));\n });\n}\n\nexport function flatten(arr) {\n return arr.reduce(function (a, b) {\n return b ? a.concat(b) : a;\n }, []);\n}\n\nexport function getLinkedTailwindColors() {\n return {\n 'primary-color': 'var(--primary-color)',\n 'font-color': 'var(--font-color)',\n };\n}\n\n/**\n * Recursively get all files in a directory\n * https://stackoverflow.com/a/45130990/831465\n * @param dir The directory to get files from\n * @returns A promise that resolves to an array of file paths\n */\nexport async function getFiles(\n dir: string,\n filenameFilter?: string,\n): Promise<string[]> {\n const entries = await fs.promises.readdir(dir, {withFileTypes: true});\n let files = await Promise.all(\n entries.map((entry) => {\n const res = path.resolve(dir, entry.name);\n return entry.isDirectory() ? getFiles(res, filenameFilter) : res;\n }),\n );\n //flatten the array of arrays into a single array\n let flatFiles = flatten(files) as string[];\n if (filenameFilter) {\n //filter the files to only include those that match the filenameFilter\n flatFiles = flatFiles.filter((file) => file.includes(filenameFilter));\n }\n return flatFiles;\n}\n\n/**\n * Strip ANSI escape codes from a string\n * @param str The string to strip ANSI codes from\n * @returns The string with ANSI codes removed\n */\nexport function stripAnsi(str: string): string {\n return str.replace(/\\x1b\\[[0-9;]*m/g, '');\n}\n"]}
|
|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EAAE,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["import chalk from 'chalk';\nimport {exec, ExecOptions} from 'child_process';\nimport * as fs from 'fs';\nimport {builtinModules} from 'module';\nimport * as path from 'path';\nimport ts from 'typescript';\nimport type {PackageDetails} from './interfaces.js';\n\nimport {findNearestPackageJsonSync} from 'find-nearest-package-json';\nimport * as glob from 'glob';\n\nvar gruntConfig;\n\n// Credit: https://gist.github.com/tinovyatkin/727ddbf7e7e10831a1eca9e4ff2fc32e\nconst tsHost = ts.createCompilerHost(\n {\n allowJs: true,\n noEmit: true,\n isolatedModules: true,\n resolveJsonModule: false,\n moduleResolution: ts.ModuleResolutionKind.Classic, // we don't want node_modules\n incremental: true,\n noLib: true,\n noResolve: true,\n },\n true,\n);\n\nexport var getFileImports = async function (filePath) {\n try {\n const importing: string[] = [];\n\n const add = (literal: ts.Node) => {\n const moduleName = literal.getText().replace(/['\"`]/g, '');\n if (\n !moduleName.startsWith('node:') &&\n !builtinModules.includes(moduleName)\n ) {\n importing.push(moduleName);\n }\n };\n // Every form that names a module: `import ... from 'x'`, `import 'x'`,\n // `export ... from 'x'`, `import('x')` (value and type position) and\n // `import x = require('x')`. Children are always visited, so specifiers\n // nested inside functions or a `declare module` body are found too.\n const delintNode = (node: ts.Node) => {\n if (\n (ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) &&\n node.moduleSpecifier &&\n ts.isStringLiteralLike(node.moduleSpecifier)\n ) {\n add(node.moduleSpecifier);\n } else if (\n ts.isCallExpression(node) &&\n node.expression.kind === ts.SyntaxKind.ImportKeyword &&\n node.arguments.length >= 1 &&\n ts.isStringLiteralLike(node.arguments[0])\n ) {\n // `import('x')` with a literal argument. A computed specifier cannot be\n // checked statically and is skipped.\n add(node.arguments[0]);\n } else if (\n // `type A = import('x').B`, and the same inside `typeof import('x')`.\n ts.isImportTypeNode(node) &&\n ts.isLiteralTypeNode(node.argument) &&\n ts.isStringLiteral(node.argument.literal)\n ) {\n add(node.argument.literal);\n } else if (\n // `import x = require('x')`.\n ts.isExternalModuleReference(node) &&\n ts.isStringLiteralLike(node.expression)\n ) {\n add(node.expression);\n }\n ts.forEachChild(node, delintNode);\n };\n const sourceFile = tsHost.getSourceFile(\n filePath,\n ts.ScriptTarget.Latest,\n (msg) => {\n throw new Error(`Failed to parse ${filePath}: ${msg}`);\n },\n );\n //check if its a directory, then we wanr that we can't parse it\n let stat = fs.lstatSync(filePath);\n if (stat.isDirectory()) {\n return importing;\n }\n\n if (!sourceFile) {\n console.warn(`Failed to find file ${filePath}`);\n return importing;\n }\n delintNode(sourceFile);\n return importing;\n } catch (err) {\n console.warn(`Error parsing file ${filePath}: ${err}`);\n return [];\n }\n};\n\n// The package name part of a bare specifier: '@scope/name' for a scoped\n// package, the first segment otherwise. Returns null for anything that is not a\n// bare specifier (relative and absolute paths). The 'node:' case is redundant\n// for callers that use getFileImports (which drops builtins already), and is\n// kept so the helper is correct standalone.\nvar barePackageName = function (importPath: string): string | null {\n if (\n importPath.startsWith('.') ||\n importPath.startsWith('/') ||\n importPath.startsWith('node:')\n ) {\n return null;\n }\n const segments = importPath.split('/');\n const name = importPath.startsWith('@')\n ? segments.slice(0, 2).join('/')\n : segments[0];\n return name || null;\n};\n\nvar isLinkedPackageName = function (name: string) {\n // The current '@_linked/*' scope, and the legacy 'lincd'-prefixed names\n // ('lincd', 'lincd-foo', ...).\n return name.startsWith('@_linked/') || /^lincd(-|$)/.test(name);\n};\n\n/**\n * True when the import reaches into ANOTHER Linked package's internals — a\n * '/src/' or '/lib/' path inside '@_linked/<pkg>' or a 'lincd'-prefixed package\n * — instead of going through that package's public subpath. Such an import\n * breaks when the other package changes its build layout, and it bypasses the\n * exports map, so the two are not interchangeable.\n *\n * Relative specifiers are exempt on purpose: the rule is about other packages,\n * and a relative path can only reach files inside the current package, where a\n * './lib/helpers' folder is a perfectly ordinary local module. Escaping the\n * package with '../' is already caught by isImportOutsideOfPackage.\n *\n * @param importPath The import path to check\n */\nexport var isInternalLinkedImport = function (importPath: string) {\n const name = barePackageName(importPath);\n if (!name || !isLinkedPackageName(name)) {\n return false;\n }\n // Match whole path segments, so '@_linked/core/library/x' is not a hit.\n const subPath = importPath.slice(name.length).split('/').filter(Boolean);\n return subPath.includes('src') || subPath.includes('lib');\n};\n/**\n * True when a relative import escapes the package source root. Normalising\n * first is what makes this correct: only leading '..' segments that survive\n * normalisation actually climb out, so './a..b' is an ordinary file name and\n * '../a/../b' climbs one level, not two.\n *\n * @param importPath The import path to check\n * @param curFileDepth How many folders deep the current file is (0 = src, 1 = src/foo, etc.)\n */\nexport var isImportOutsideOfPackage = function (\n importPath: string,\n curFileDepth: number,\n) {\n if (!importPath.startsWith('.')) {\n return false;\n }\n const segments = path.posix\n .normalize(importPath.split('\\\\').join('/'))\n .split('/');\n // How many folders the specifier climbs: the leading '..' segments that\n // normalisation could not cancel out.\n let climbs = 0;\n while (segments[climbs] === '..') {\n climbs++;\n }\n return climbs > curFileDepth;\n};\n\nexport var getPackageJSON = function (root = process.cwd(), error = true) {\n // console.log('Getting package.json from ' + chalk.cyan(root));\n //log stack trace\n let packagePath = path.join(root, 'package.json');\n if (fs.existsSync(packagePath)) {\n return JSON.parse(fs.readFileSync(packagePath, 'utf8'));\n } else if (root === process.cwd()) {\n if (error) {\n console.warn(\n 'Could not find package.json. Make sure you run this command from the root of a linked package or a linked workspace',\n );\n process.exit();\n }\n }\n};\n\n/**\n * Scans package.json for dependencies that are LINCD packages\n * Also looks into dependencies of dependencies\n * If no packageJson is given, it will attempt to obtain it from the current working directory\n * Returns an array of lincd packages, with each entry containing an array with the package name and the local path to the package\n * @param packageJson\n */\nexport var getLINCDDependencies = function (\n packageJson?,\n checkedPackages: Set<string> = new Set(),\n): [string, string, string[]][] {\n if (!packageJson) {\n packageJson = getPackageJSON();\n }\n let dependencies = {\n ...packageJson.dependencies,\n ...packageJson.devDependencies,\n };\n let lincdPackagePaths: [string, string, string[]][] = [];\n let firstTime = checkedPackages.size === 0;\n\n for (var dependency of Object.keys(dependencies)) {\n try {\n if (!checkedPackages.has(dependency)) {\n let [modulePackageJson, modulePath] = getModulePackageJSON(dependency);\n checkedPackages.add(dependency);\n\n if (modulePackageJson?.lincd) {\n lincdPackagePaths.push([\n modulePackageJson.name,\n modulePath,\n [\n ...Object.keys({\n ...modulePackageJson.dependencies,\n ...modulePackageJson.devDependencies,\n }),\n ],\n ]);\n //also check if this package has any dependencies that are lincd packages\n lincdPackagePaths = lincdPackagePaths.concat(\n getLINCDDependencies(modulePackageJson, checkedPackages),\n );\n }\n if (!modulePackageJson) {\n //this seems to only happen with yarn workspaces for some grunt related dependencies of lincd-cli\n // console.log(`could not find package.json of ${dependency}`);\n }\n }\n } catch (err) {\n console.log(\n `could not check if ${dependency} is a lincd package: ${err}`,\n );\n }\n }\n\n if (firstTime) {\n // let dependencyMap:Map<string,Set<string>> = new Map();\n let lincdPackageNames = new Set(\n lincdPackagePaths.map(\n ([packageName, modulePath, pkgDependencies]) => packageName,\n ),\n );\n //remove lincd-cli from the list of lincd packages\n lincdPackageNames.delete('lincd-cli');\n\n lincdPackagePaths.forEach(\n ([packageName, modulePath, pkgDependencies], key) => {\n let lincdDependencies = pkgDependencies.filter((dependency) =>\n lincdPackageNames.has(dependency),\n );\n if (packageName === 'lincd-cli') {\n //remove lincd-modules from the dependencies of lincd-cli (it's not a hard dependency, and it messes things up)\n lincdDependencies.splice(\n lincdDependencies.indexOf('lincd-modules'),\n 1,\n );\n }\n // dependencyMap.set(packageName, new Set(lincdDependencies));\n //update dependencies to be the actual lincd package objects\n lincdPackagePaths[key][2] = lincdDependencies;\n },\n );\n\n // //add the nested dependencies for each lincd package\n // for (let [packageName,pkgDependencies] of dependencyMap) {\n // pkgDependencies.forEach((dependency) => {\n // if (dependencyMap.has(dependency)) {\n // dependencyMap.get(dependency).forEach((nestedDependency) => {\n // pkgDependencies.add(nestedDependency);\n // });\n // }\n // });\n // }\n //\n // dependencyMap.forEach((dependencies,packageName) => {\n // //check for circular dependencies\n // if([...dependencies].some(dependency => {\n // return dependencyMap.get(dependency).has(packageName);\n // }))\n // {\n // console.warn(`Circular dependency detected between ${packageName} and ${dependency}`);\n // }\n //\n // });\n\n // a simple sort with dependencyMap doesn't seem to work,so we start with LINCD (least dependencies) and from there add packages that have all their dependencies already added\n let sortedPackagePaths = [];\n let addedPackages = new Set();\n let lincdItself = lincdPackagePaths.find(([packageName]) => {\n return packageName === 'lincd';\n });\n if (lincdItself) {\n sortedPackagePaths.push(lincdItself);\n addedPackages = new Set(['lincd']);\n }\n\n while (addedPackages.size !== lincdPackagePaths.length) {\n let startSize = addedPackages.size;\n lincdPackagePaths.forEach(\n ([packageName, modulePath, pkgDependencies]) => {\n if (\n !addedPackages.has(packageName) &&\n pkgDependencies.every((dependency) => addedPackages.has(dependency))\n ) {\n sortedPackagePaths.push([packageName, modulePath, pkgDependencies]);\n addedPackages.add(packageName);\n }\n },\n );\n if (startSize === addedPackages.size) {\n console.warn('Could not sort lincd packages, circular dependencies?');\n break;\n }\n }\n\n //sort the lincd packages by least dependent first\n // lincdPackagePaths = lincdPackagePaths.sort(([packageNameA],[packageNameB]) => {\n // //if package A depends on package B, then package B should come first\n // if (dependencyMap.get(packageNameA).has(packageNameB)) {\n // console.log(packageNameA+' depends on '+packageNameB+ ' (below)')\n // return 1;\n // }\n // console.log(packageNameA+' above '+packageNameB)\n // return -1;\n // });\n return sortedPackagePaths;\n }\n\n return lincdPackagePaths;\n};\n\nexport const getLastBuildTime = (packagePath) => {\n return getLastModifiedFile(packagePath + '/@(builds|lib|dist)/**/*.js');\n};\n\nexport const getLastModifiedSourceTime = (packagePath) => {\n return getLastModifiedFile(packagePath + '/@(src|data|css|modules)/**/*', {\n ignore: [\n packagePath + '/**/*.css.json',\n packagePath + '/**/*.d.ts',\n packagePath + '/**/node_modules/**/*',\n packagePath + '/**/lib/**/*',\n packagePath + '/**/dist/**/*',\n ],\n });\n};\n\nexport const getLastCommitTime = (\n packagePath,\n): Promise<{date: Date; changes: string; commitId: string}> => {\n // console.log(`git log -1 --format=%ci -- ${packagePath}`);\n // process.exit();\n return execPromise(`cd ${packagePath} && git log -1 --format=\"%h %ci\" -- .`)\n .then(async (result) => {\n let commitId = result.substring(0, result.indexOf(' '));\n let date = result.substring(commitId.length + 1);\n let lastCommitDate = new Date(date);\n\n let changes = await execPromise(\n `cd ${packagePath} && git show --stat --oneline ${commitId} -- .`,\n );\n // log(packagePath, result, lastCommitDate);\n // log(changes);\n return {date: lastCommitDate, changes, commitId};\n })\n .catch(({error, stdout, stderr}) => {\n debugInfo(chalk.red('Git error: ') + error.message.toString());\n return null;\n });\n};\n\nexport const getLastModifiedFile = (filePath, config = {}) => {\n var files = glob.sync(filePath, config);\n\n // console.log(files.join(\" - \"));\n var lastModifiedName;\n var lastModified: Date;\n var lastModifiedTime = 0;\n files.forEach((fileName) => {\n if (fs.lstatSync(fileName).isDirectory()) {\n // console.log(\"skipping directory \"+fileName);\n return;\n }\n let mtime = fs.statSync(path.join(fileName)).mtime;\n let modifiedTime = mtime.getTime();\n if (modifiedTime > lastModifiedTime) {\n // console.log(fileName,mtime);\n lastModifiedName = fileName;\n lastModified = mtime;\n lastModifiedTime = modifiedTime;\n }\n });\n return {lastModified, lastModifiedName, lastModifiedTime};\n};\n\n//from https://github.com/haalcala/node-packagejson/blob/master/index.js\nexport var getModulePackageJSON = function (module_name, work_dir?) {\n if (!work_dir) {\n work_dir = process.cwd();\n } else {\n work_dir = path.resolve(work_dir);\n }\n\n var package_json;\n\n if (fs.existsSync(path.resolve(work_dir, './node_modules'))) {\n var module_dir = path.resolve(work_dir, './node_modules/' + module_name);\n\n if (\n fs.existsSync(module_dir) &&\n fs.existsSync(module_dir + '/package.json')\n ) {\n package_json = JSON.parse(\n fs.readFileSync(module_dir + '/package.json', 'utf-8'),\n );\n }\n }\n\n if (!package_json && work_dir != '/') {\n return getModulePackageJSON(module_name, path.resolve(work_dir, '..'));\n }\n\n return [package_json, module_dir];\n};\nexport function execp(\n cmd,\n log: boolean = false,\n allowError: boolean = false,\n options: any = {},\n): Promise<null> {\n // opts || (opts = {});\n if (log) console.log(chalk.cyan(cmd));\n\n return new Promise((resolve, reject) => {\n var child = exec(cmd, options);\n\n child.stdout.pipe(process.stdout);\n child.stderr.pipe(process.stderr);\n // process.stdin.pipe(child.stdin);\n\n child.on('close', function (code) {\n if (code === 0) {\n resolve(null);\n } else {\n reject();\n }\n // console.log('killing child');\n // child.kill('SIGHUP');\n // resolve(code);\n });\n // child.on('data', function (result) {\n // \t// if (log)\n // \t// {\n // \t// \tconsole.log(result);\n // \t// }\n // \tresolve(result);\n // \tconsole.log('resolve data');\n //\n // });\n\n child.on('error', function (err) {\n if (!allowError) {\n // console.log('reject err');\n reject(err);\n return;\n } else if (log) {\n console.warn(err);\n }\n // console.log('resolve err');\n resolve(null);\n });\n child.on('exit', function (code, signal) {\n if (code !== 0) {\n reject('Child process exited with error code ' + code);\n return;\n }\n // console.log('resolve exit');\n resolve(null);\n });\n });\n}\n\nexport function execPromise(\n command,\n log = false,\n allowError: boolean = false,\n options?: ExecOptions,\n pipeOutput: boolean = false,\n): Promise<string> {\n return new Promise(function (resolve, reject) {\n if (log) console.log(chalk.cyan(command));\n let child = exec(command, options, (error, stdout, stderr) => {\n if (error) {\n if (!allowError) {\n reject({error, stdout, stderr});\n return;\n } else if (log) {\n console.warn(error);\n }\n }\n //TODO: getting a typescript error for 'trim()', this worked before, is it still used? do we log anywhere?\n let result = stdout['trim']();\n if (log) {\n // console.log(chalk\"RESOLVING \"+command);\n console.log(result);\n // console.log('ERRORS:'+(result.indexOf('Aborted due to warnings') !== -1));\n // console.log('stderr:'+stderr);\n }\n resolve(result);\n });\n if (pipeOutput) {\n child.stdout.pipe(process.stdout);\n child.stderr.pipe(process.stderr);\n }\n });\n}\n\nexport {generateScopedNameProduction} from './css-module-names.js';\nexport function generateScopedName(cssClassName, filepath, css?) {\n // Strip any Vite-style query suffix (?inline, ?raw, ?direct) before\n // computing the filename. Without this, dev-mode SSR CSS collection\n // via `?inline` produces selectors like\n // `._foo_SigninLayout.module.css?inline_leftSidebar` — the literal\n // `.module.css?inline` becomes part of the class name, which CSS\n // parsers split on `.` and `?`, breaking everything.\n const cleanFilepath = filepath.replace(/\\?.*$/, '');\n var filename = path\n .basename(cleanFilepath)\n .replace(/\\.module\\.css$/, '')\n .replace(/\\.css$/, '');\n let resolved = path.resolve(cleanFilepath).replace(/[\\w\\-_\\/]+\\/file\\:/, '');\n let nearestPackageJson = findNearestPackageJsonSync(resolved);\n let packageName = nearestPackageJson\n ? nearestPackageJson.data.name\n : 'unknown';\n return (\n packageName.replace(/[^a-zA-Z0-9_]+/g, '_') +\n '_' +\n filename +\n '_' +\n cssClassName\n );\n}\n\nexport const needsRebuilding = async function (\n pkg: PackageDetails,\n useGitForLastModified: boolean,\n log: boolean = false,\n) {\n let lastModifiedSourceDate: Date;\n let lastModifiedSourceName: string;\n\n if (useGitForLastModified) {\n const {changes, commitId, date} = await getLastCommitTime(pkg.path);\n\n lastModifiedSourceDate = date;\n lastModifiedSourceName = commitId;\n } else {\n const {lastModified, lastModifiedName, lastModifiedTime} =\n getLastModifiedSourceTime(pkg.path);\n lastModifiedSourceName = lastModifiedName;\n lastModifiedSourceDate = lastModified;\n }\n\n let lastModifiedBundle = getLastBuildTime(pkg.path);\n let result =\n lastModifiedSourceDate &&\n lastModifiedSourceDate.getTime() > lastModifiedBundle.lastModifiedTime;\n if (log) {\n console.log(\n chalk.cyan(\n 'Last modified source: ' +\n lastModifiedSourceName +\n ' on ' +\n lastModifiedSourceDate.toString(),\n ),\n );\n console.log(\n chalk.cyan(\n 'Last build: ' +\n (lastModifiedBundle &&\n typeof lastModifiedBundle.lastModified !== 'undefined'\n ? lastModifiedBundle.lastModified.toString()\n : 'never'),\n ),\n );\n }\n return result;\n};\n\nexport function log(...messages) {\n messages.forEach((message) => {\n console.log(chalk.cyan(message));\n });\n}\n\nexport function debug(config, ...messages) {\n if (config.debug) {\n log(...messages);\n }\n}\n\nexport function debugInfo(...messages) {\n // messages.forEach((message) => {\n // console.log(chalk.cyan('Info: ') + message);\n // });\n //@TODO: let packages also use linked.config.json? instead of gruntfile...\n // that way we can read \"analyse\" here and see if we need to log debug info\n // if(!gruntConfig)\n // {\n // gruntConfig = getGruntConfig();\n // console.log(gruntConfig);\n // process.exit();\n // }\n if (gruntConfig && gruntConfig.analyse === true) {\n messages.forEach((message) => {\n console.log(chalk.cyan('Info: ') + message);\n });\n }\n}\n\nexport function warn(...messages) {\n messages.forEach((message) => {\n console.log(chalk.red(message));\n });\n}\n\nexport function flatten(arr) {\n return arr.reduce(function (a, b) {\n return b ? a.concat(b) : a;\n }, []);\n}\n\nexport function getLinkedTailwindColors() {\n return {\n 'primary-color': 'var(--primary-color)',\n 'font-color': 'var(--font-color)',\n };\n}\n\n/**\n * Recursively get all files in a directory\n * https://stackoverflow.com/a/45130990/831465\n * @param dir The directory to get files from\n * @returns A promise that resolves to an array of file paths\n */\nexport async function getFiles(\n dir: string,\n filenameFilter?: string,\n): Promise<string[]> {\n const entries = await fs.promises.readdir(dir, {withFileTypes: true});\n let files = await Promise.all(\n entries.map((entry) => {\n const res = path.resolve(dir, entry.name);\n return entry.isDirectory() ? getFiles(res, filenameFilter) : res;\n }),\n );\n //flatten the array of arrays into a single array\n let flatFiles = flatten(files) as string[];\n if (filenameFilter) {\n //filter the files to only include those that match the filenameFilter\n flatFiles = flatFiles.filter((file) => file.includes(filenameFilter));\n }\n return flatFiles;\n}\n\n/**\n * Strip ANSI escape codes from a string\n * @param str The string to strip ANSI codes from\n * @returns The string with ANSI codes removed\n */\nexport function stripAnsi(str: string): string {\n return str.replace(/\\x1b\\[[0-9;]*m/g, '');\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-config.d.ts","sourceRoot":"","sources":["../../src/vite-config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"vite-config.d.ts","sourceRoot":"","sources":["../../src/vite-config.ts"],"names":[],"mappings":"AAYA,O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AAM,CAAC,CAaxB;AAED,wBAAgB,gBAAgB,CAAC,IAAI,GAAE,uBAA4B,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAmYpG"}
|
package/lib/esm/vite-config.js
CHANGED
|
@@ -19,12 +19,14 @@ var _b, _c;
|
|
|
19
19
|
// The helper preserves the dev-mode `generateScopedName` (readable
|
|
20
20
|
// `_packageName_filename_className`) so CSS module class names match
|
|
21
21
|
// what the previous bundler chain produced for trace/debug. Production
|
|
22
|
-
// uses
|
|
22
|
+
// uses `generateScopedNameProduction`, which the Node CSS loader shares so the
|
|
23
|
+
// server renders the class names the client's stylesheet defines.
|
|
23
24
|
import { defineConfig } from 'vite';
|
|
24
25
|
import react from '@vitejs/plugin-react';
|
|
25
26
|
import fsExtra from 'fs-extra';
|
|
26
27
|
import path from 'node:path';
|
|
27
28
|
import { generateScopedName } from './utils.js';
|
|
29
|
+
import { generateScopedNameProduction } from './css-module-names.js';
|
|
28
30
|
import { parseWorkspacePatterns, isWorkspacePathNegated } from './workspace-globs.js';
|
|
29
31
|
import { pinCompiledClassNames } from './plugins/pin-compiled-class-names.js';
|
|
30
32
|
import { isFrameworkPkg, readInstalledPkg } from './installed-packages.js';
|
|
@@ -681,7 +683,7 @@ export function createViteConfig(opts = {}) {
|
|
|
681
683
|
...((_f = opts.plugins) !== null && _f !== void 0 ? _f : []),
|
|
682
684
|
].filter(Boolean), css: {
|
|
683
685
|
modules: {
|
|
684
|
-
generateScopedName: isDev ? generateScopedName :
|
|
686
|
+
generateScopedName: isDev ? generateScopedName : generateScopedNameProduction,
|
|
685
687
|
},
|
|
686
688
|
postcss: opts.postcssPlugins
|
|
687
689
|
? { plugins: opts.postcssPlugins }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-config.js","sourceRoot":"","sources":["../../src/vite-config.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,oEAAoE;AACpE,EAAE;AACF,+CAA+C;AAC/C,EAAE;AACF,wDAAwD;AACx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,gEAAgE;oBAChE,sDAAsD,CACzD,CAAC;YACJ,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC,CAAA,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Vite config helper for linked apps. The one dev + build pipeline.\n//\n// Apps use this from their own vite.config.ts:\n//\n// import {createViteConfig} from '@_linked/cli/vite';\n// export default createViteConfig({port: 4040, cssMode: 'tailwind'});\n//\n// The helper preserves the dev-mode `generateScopedName` (readable\n// `_packageName_filename_className`) so CSS module class names match\n// what the previous bundler chain produced for trace/debug. Production\n// uses Vite's default scoping (content-hash, equivalent uniqueness).\nimport {defineConfig} from 'vite';\nimport react from '@vitejs/plugin-react';\nimport fsExtra from 'fs-extra';\nimport path from 'node:path';\nimport {generateScopedName} from './utils.js';\nimport {parseWorkspacePatterns, isWorkspacePathNegated} from './workspace-globs.js';\nimport {pinCompiledClassNames} from './plugins/pin-compiled-class-names.js';\nimport {isFrameworkPkg, readInstalledPkg} from './installed-packages.js';\nimport {linkedClientDepIncludesPlugin} from './client-dep-includes.js';\nimport type {Plugin, UserConfig} from 'vite';\n\n/** Default dev server port, and Vite's default HMR websocket port. */\nconst DEFAULT_DEV_PORT = 4040;\nconst DEFAULT_HMR_PORT = 24678;\n/** Vite may not bind below 1024 without privileges; 65535 is the TCP ceiling. */\nconst MIN_HMR_PORT = 1024;\nconst MAX_HMR_PORT = 65535;\n\n/**\n * Derive an app's HMR websocket port from its dev port.\n *\n * Every `createViteConfig` app used to fall back to Vite's shared default\n * 24678, so any two dev servers running at once collided (\"Port 24678 is\n * already in use\") and HMR silently broke for the loser. Offsetting the HMR\n * port by the same amount the dev port is offset from its default keeps the\n * derivation trivial and means apps that already run on distinct dev ports get\n * distinct HMR ports for free.\n *\n * The input is untrusted (`process.env.PORT` is an arbitrary string), so\n * anything that is not a whole port number — `PORT=abc` yielding `NaN`, a\n * negative or out-of-range value — falls back to the dev port default. The\n * result is then clamped into the bindable range, since a far-out dev port\n * would otherwise derive an HMR port past 65535.\n */\n/**\n * Which manual chunk a module belongs in.\n *\n * Split large/common deps so route chunks don't all carry their own copy AND\n * the main entry doesn't end up at 5MB+. Each chunk becomes its own\n * `assets/<name>-<hash>.js` the browser caches independently — incremental\n * dev builds and cache wins on prod deploys both improve.\n *\n * Exported so the grouping can be asserted directly: getting it wrong does not\n * fail the build, it produces a bundle that throws on load in the browser.\n */\nexport const chunkForModuleId = (id: string): string | undefined => {\n if (!id.includes('node_modules')) {\n // Linked workspaces ship as @_linked/* / lincd-* — group all\n // linked-framework code into a single chunk.\n if (\n id.includes('/packages/core/') ||\n id.includes('/packages/react/') ||\n id.includes('/packages/server-utils/') ||\n id.includes('/packages/primitives/') ||\n id.includes('/packages/css/') ||\n /\\/packages\\/(auth|org|schema|fuseki|owl|xsd|dcat|dcmi|s3|sentry|ui)\\//.test(id)\n ) {\n return 'linked';\n }\n return undefined;\n }\n // Framework code installed from the registry rather than resolved to a\n // workspace. An app can hold both at once — a published `@_linked/server`\n // in node_modules next to workspace `@_linked/core` — and the two import\n // each other. Split across `linked` and `vendor` that is a cycle, and\n // Rollup's chosen order left a binding in its temporal dead zone:\n // `Cannot access 'Wo' before initialization` before the app rendered.\n // Same chunk, no cycle.\n if (/[\\\\/]node_modules[\\\\/](@_linked[\\\\/]|lincd-)/.test(id)) {\n return 'linked';\n }\n // React + React-DOM in their own chunk — every route uses them.\n //\n // react-router and @remix-run/router belong here too. Left in `vendor` they\n // made the two chunks import each other: react-router-dom re-exports\n // react-router, so react-vendor imported vendor, while vendor's own\n // top-level `React.createContext(...)` calls imported react-vendor. Rollup\n // has to pick an order for a cycle, and it ran vendor first — every\n // production build died on load with \"Cannot read properties of undefined\n // (reading 'createContext')\".\n if (\n /[\\\\/]node_modules[\\\\/](react|react-dom|react-router-dom|react-router|@remix-run[\\\\/]router|scheduler)[\\\\/]/.test(\n id\n )\n ) {\n return 'react-vendor';\n }\n // Heavy editor deps — only loaded on pages that need them, but worth\n // isolating so they don't get pulled into main.\n if (/[\\\\/]node_modules[\\\\/]@monaco-editor[\\\\/]/.test(id)) {\n return 'monaco';\n }\n // Charting/visualization\n if (/[\\\\/]node_modules[\\\\/](recharts|react-flow|@xyflow|d3-)[\\\\/]/.test(id)) {\n return 'viz';\n }\n // Animation\n if (/[\\\\/]node_modules[\\\\/]framer-motion[\\\\/]/.test(id)) {\n return 'motion';\n }\n // Catch-all for other node_modules in a vendor chunk\n return 'vendor';\n};\n\nexport function hmrPortFor(devPort: unknown): number {\n const parsed = Number(devPort);\n const validDevPort =\n Number.isFinite(parsed) && Number.isInteger(parsed) && parsed >= 1 && parsed <= 65535\n ? parsed\n : DEFAULT_DEV_PORT;\n const derived = DEFAULT_HMR_PORT + (validDevPort - DEFAULT_DEV_PORT);\n return Math.min(MAX_HMR_PORT, Math.max(MIN_HMR_PORT, derived));\n}\n\n/** How far past the derived port `resolveHmrPort` looks for a free one. */\nconst HMR_PORT_SEARCH_RANGE = 100;\n\n/**\n * Whether `port` can be listened on the way Vite's HMR websocket server\n * listens: every interface, since `createViteConfig` sets no `hmr.host`.\n */\nexport function isPortFree(port: number, host?: string): Promise<boolean> {\n return import('node:net').then(\n (net) =>\n new Promise<boolean>((resolve) => {\n const probe = net.createServer();\n probe.unref();\n probe.once('error', () => resolve(false));\n probe.listen({port, host, exclusive: true}, () => probe.close(() => resolve(true)));\n }),\n );\n}\n\n/**\n * Ports this process already chose, by derived port. Vite re-evaluates the\n * config when it restarts the server (a vite.config edit), and it does so while\n * the old server still holds the port — probing again would see our own socket\n * and move to the next port on every restart.\n */\nconst chosenHmrPorts: Map<number, number> = ((globalThis as any)[Symbol.for('@_linked/cli.hmrPorts')] ??=\n new Map<number, number>());\n\nexport interface ResolveHmrPortOptions {\n /** The dev port the HMR port is derived from (`process.env.PORT ?? opts.port`). */\n devPort: unknown;\n env?: NodeJS.ProcessEnv;\n isFree?: (port: number) => Promise<boolean>;\n log?: (message: string) => void;\n}\n\n/**\n * The HMR websocket port for this dev server.\n *\n * `LINKED_HMR_PORT` wins outright. Otherwise the port derived from the dev port\n * (`hmrPortFor`) is used if it is free, and the next free port above it if it\n * is not: the derivation keeps apps on distinct dev ports apart, but not an app\n * from an unrelated process (or a second checkout of the same app) that already\n * holds the derived port. Vite injects the configured `hmr.port` into the\n * client it serves, so the browser connects to whichever port was chosen.\n *\n * If nothing in range is free the derived port is returned and Vite reports the\n * conflict, as it did before.\n */\nexport async function resolveHmrPort({\n devPort,\n env = process.env,\n isFree = isPortFree,\n log = (m) => console.log(m),\n}: ResolveHmrPortOptions): Promise<number> {\n const override = env.LINKED_HMR_PORT;\n if (override !== undefined && override.trim() !== '') {\n const port = Number(override);\n if (Number.isInteger(port) && port >= 1 && port <= MAX_HMR_PORT) return port;\n log(`[linked] ignoring LINKED_HMR_PORT=${override}: not a port number`);\n }\n const derived = hmrPortFor(devPort);\n const remembered = chosenHmrPorts.get(derived);\n if (remembered !== undefined) return remembered;\n for (let port = derived; port <= Math.min(MAX_HMR_PORT, derived + HMR_PORT_SEARCH_RANGE); port++) {\n if (await isFree(port)) {\n chosenHmrPorts.set(derived, port);\n if (port !== derived) {\n log(`[linked] HMR port ${derived} is in use; using ${port} (set LINKED_HMR_PORT to choose one)`);\n }\n return port;\n }\n }\n return derived;\n}\n\nexport interface LinkedViteConfigOptions {\n /** Dev server port. Default 4040. */\n port?: number;\n /** Output dir for `vite build`. Default `public/bundles`. */\n outDir?: string;\n /** CSS pipeline mode. */\n cssMode?: 'tailwind' | 'css-modules-only';\n /** Entry file for the client bundle. Default `src/index.tsx`. */\n entry?: string;\n /** Extra Vite plugins. */\n plugins?: Plugin[];\n /** Extra PostCSS plugins (e.g. `postcss-media-to-container`). */\n postcssPlugins?: unknown[];\n /**\n * Extra `define` entries for the CLIENT environment only (used to bridge\n * `process.env.X` refs into the browser). Never applied server-side.\n */\n define?: Record<string, string>;\n /**\n * Extra workspace globs (trailing `/*`, or a direct package dir) resolved\n * RELATIVE TO the app's cwd, in ADDITION to the app's own `workspaces` field.\n *\n * For apps whose linked-package sources live OUTSIDE their own workspace tree\n * — e.g. an app consumes `packages/lincd.org/modules/*`, which sit one level\n * up (`../lincd.org/modules/*`) when the app runs inside the CN monorepo, and under\n * `packages/lincd.org/modules/*` when the app runs from its own root. Pass BOTH\n * candidate layouts; only globs whose parent dir actually exists are scanned,\n * so the same config works in either checkout. Each glob's packages are\n * registered as source workspaces (resolved to `src/` for HMR + single-instance),\n * exactly like the app's own `workspaces` field.\n */\n workspaceGlobs?: string[];\n /**\n * Add the third-party client dependencies of the excluded framework packages\n * to `optimizeDeps.include` in dev (see ./client-dep-includes.ts). Default on;\n * `false` (or `LINKED_CLIENT_DEP_INCLUDES=0`) turns it off, and `deny` keeps\n * entries out — matched against the entry (`'@_linked/primitives > vaul'`),\n * the specifier (`'vaul'`) or the package name. Run with `DEBUG=linked` to see\n * what was added.\n */\n clientDepIncludes?: boolean | {deny?: (string | RegExp)[]};\n}\n\ninterface WorkspaceEntry {\n name: string;\n srcDir: string;\n}\n\n/**\n * Names of installed packages that depend, directly or transitively (via\n * `dependencies` / `peerDependencies`), on a discovered source workspace. Such a\n * package must also go through Vite SSR: if Node loaded it natively, it would\n * import its own Node-loaded copy of the workspace (e.g. published\n * `@_linked/fuseki` importing a workspace `@_linked/core`), splitting module\n * state. Vite rewrites the dynamic `import()` in code it transforms, so bundling\n * the dependents keeps one instance.\n *\n * Only the dependency closure of the app's `package.json` (dependencies +\n * devDependencies) and of the workspaces themselves is scanned. Packages are\n * resolved Node-style, keyed by real path, and unresolvable ones are ignored.\n * Workspace names are not included in the result.\n */\nexport async function workspaceDependents(\n workspaces: {name: string; srcDir?: string}[],\n cwd: string = process.cwd(),\n): Promise<string[]> {\n if (workspaces.length === 0) return [];\n const fs = await import('node:fs/promises');\n const wsNames = new Set(workspaces.map((w) => w.name));\n // realRoot -> {name, deps (realRoots)}\n const nodes = new Map<string, {name: string; deps: Set<string>}>();\n const realpath = async (p: string): Promise<string> => {\n try {\n return await fs.realpath(p);\n } catch {\n return path.resolve(p);\n }\n };\n\n const visit = async (root: string, json: any): Promise<string> => {\n const real = await realpath(root);\n if (nodes.has(real)) return real;\n const node = {name: json.name as string, deps: new Set<string>()};\n nodes.set(real, node);\n const names = new Set([\n ...Object.keys(json.dependencies ?? {}),\n ...Object.keys(json.peerDependencies ?? {}),\n ]);\n for (const dep of names) {\n const resolved = await readInstalledPkg(dep, real);\n if (resolved) node.deps.add(await visit(resolved.root, resolved.json));\n }\n return real;\n };\n\n // Seed: the app's direct deps, plus each workspace package's own deps.\n try {\n const appPkg = await fsExtra.readJson(path.join(cwd, 'package.json'));\n for (const dep of Object.keys({...appPkg.dependencies, ...appPkg.devDependencies})) {\n const resolved = await readInstalledPkg(dep, cwd);\n if (resolved) await visit(resolved.root, resolved.json);\n }\n } catch {}\n for (const ws of workspaces) {\n if (!ws.srcDir) continue;\n const root = path.dirname(ws.srcDir);\n try {\n await visit(root, await fsExtra.readJson(path.join(root, 'package.json')));\n } catch {}\n }\n\n // Walk reverse edges from every workspace node: everything reached depends on one.\n const dependentsOf = new Map<string, string[]>();\n for (const [key, node] of nodes) {\n for (const dep of node.deps) {\n if (!dependentsOf.has(dep)) dependentsOf.set(dep, []);\n dependentsOf.get(dep)!.push(key);\n }\n }\n const queue = [...nodes].filter(([, n]) => wsNames.has(n.name)).map(([k]) => k);\n const marked = new Set(queue);\n while (queue.length) {\n for (const parent of dependentsOf.get(queue.pop()!) ?? []) {\n if (!marked.has(parent)) {\n marked.add(parent);\n queue.push(parent);\n }\n }\n }\n const out = new Set<string>();\n for (const key of marked) {\n const name = nodes.get(key)!.name;\n if (name && !wsNames.has(name)) out.add(name);\n }\n return [...out].sort();\n}\n\n/**\n * Read a package root as a SOURCE install: `{name, srcDir}` iff it has a\n * package.json with a name and ships a `src/` dir. Published packages have only\n * `lib/` and are skipped — they resolve via their exports.\n */\nasync function readSourcePackage(root: string): Promise<WorkspaceEntry | null> {\n const pkgPath = path.join(root, 'package.json');\n if (!(await fsExtra.pathExists(pkgPath))) return null;\n const srcDir = path.join(root, 'src');\n if (!(await fsExtra.pathExists(srcDir))) return null;\n try {\n const json = await fsExtra.readJson(pkgPath);\n return json.name ? {name: json.name, srcDir} : null;\n } catch {\n return null;\n }\n}\n\n/**\n * Linked packages installed as SOURCE, found by walking the app's\n * `dependencies` + `devDependencies` (and recursing through the `dependencies`\n * of each linked package found), keeping those marked `\"linkedPackage\": true`\n * — the same marker the CLI keys on (see cli-methods.ts) — and registering the\n * ones that ship `src/`.\n *\n * A dep ships `src/` when it is a symlinked workspace clone, a `link:`/`portal:`\n * dev install, or a LOCALIZED checkout (`packages-local/<pkg>`, in no workspace\n * glob). That's what lets a STANDALONE app (not itself a workspace root — e.g. a\n * per-branch clone under /apps) resolve a linked package's `.tsx` sources with\n * extension probing, instead of falling through to the package's\n * `development → ./src/*.ts` export (which misses `.tsx` like LinkedServer). A\n * prod/ejected app installs PUBLISHED packages (no `src/`) → not registered,\n * resolved via each package's `lib`.\n *\n * The marker — NOT the npm scope — drives discovery, so a user's own\n * custom-scope published linked package (e.g. `@acme/foo` with\n * `linkedPackage:true`) is picked up too, and linked packages present in\n * node_modules but not depended upon are ignored.\n *\n * Every root is REALPATHED before it is registered: `readInstalledPkg` returns\n * the `node_modules/<name>` symlink spelling, and Vite's resolver realpaths\n * every id it produces, so registering the symlink would give one file two\n * module ids — two instances of the same module.\n *\n * Shared by the Vite resolver table (`discoverWorkspaces`) and the `linked start`\n * HMR watch set, so the two cannot disagree about what is source.\n */\nexport async function discoverLinkedSourceDependencies(\n cwd: string = process.cwd(),\n): Promise<WorkspaceEntry[]> {\n const pkgPath = path.join(cwd, 'package.json');\n if (!(await fsExtra.pathExists(pkgPath))) return [];\n const fs = await import('node:fs/promises');\n const out: WorkspaceEntry[] = [];\n const seen = new Set<string>();\n const visited = new Set<string>();\n const walk = async (\n deps: Record<string, string> | undefined,\n fromDir: string,\n ): Promise<void> => {\n for (const name of Object.keys(deps ?? {})) {\n if (visited.has(name)) continue;\n visited.add(name);\n const resolved = await readInstalledPkg(name, fromDir);\n if (!resolved) continue;\n if (resolved.json.linkedPackage !== true) continue;\n let realRoot = resolved.root;\n try {\n realRoot = await fs.realpath(resolved.root);\n } catch {}\n const entry = await readSourcePackage(realRoot);\n if (entry && !seen.has(entry.name)) {\n seen.add(entry.name);\n out.push(entry);\n }\n // Recurse from the real location, so a symlinked clone resolves its own\n // dependencies from its source dir.\n await walk(resolved.json.dependencies, realRoot);\n }\n };\n const appPkg = await fsExtra.readJson(pkgPath);\n await walk(appPkg.dependencies, cwd);\n await walk(appPkg.devDependencies, cwd);\n return out;\n}\n\n/**\n * Walk the app's package.json `workspaces` field to build a lookup table\n * from npm name → absolute src/ directory. Used by the resolver plugin\n * to map bare specifiers like `@_linked/foo/bar` directly to source.\n *\n * Positive patterns are expanded by directory listing, so only a trailing `/*`\n * is honoured. NEGATED patterns (`\"!packages/core\"`) are honoured in full, with\n * npm's semantics — see ./workspace-globs.js. Skipping them would resolve a\n * package to an excluded directory that the package manager never installed\n * dependencies for.\n */\nexport async function discoverWorkspaces(\n extraGlobs: string[] = [],\n cwd: string = process.cwd(),\n): Promise<WorkspaceEntry[]> {\n const fs = await import('node:fs/promises');\n const out: WorkspaceEntry[] = [];\n const seen = new Set<string>();\n // Register a package root iff it ships a `src/` dir (source install).\n const addFromRoot = async (root: string): Promise<void> => {\n const entry = await readSourcePackage(root);\n if (!entry || seen.has(entry.name)) return;\n seen.add(entry.name);\n out.push(entry);\n };\n\n // 1. The app's own `workspaces` globs — the monorepo-root case (CN, or any app\n // that is itself a workspace root). Only trailing `/*` patterns.\n const pkgPath = path.join(cwd, 'package.json');\n if (await fsExtra.pathExists(pkgPath)) {\n const pkg = await fsExtra.readJson(pkgPath);\n // Merge the app's own `workspaces` globs with any caller-supplied\n // `workspaceGlobs` (e.g. `../lincd.org/modules/*`). Non-existent parents\n // are skipped below, so passing both nested + standalone layouts is safe.\n // Either list may carry negations, so they are parsed together.\n const {patterns, negatedPatterns} = parseWorkspacePatterns([\n ...(Array.isArray(pkg.workspaces) ? pkg.workspaces : pkg.workspaces?.packages ?? []),\n ...extraGlobs,\n ]);\n const addUnlessNegated = async (root: string): Promise<void> => {\n const rel = path.relative(cwd, root).split(path.sep).join('/');\n if (isWorkspacePathNegated(rel, negatedPatterns)) return;\n await addFromRoot(root);\n };\n for (const pattern of patterns) {\n const m = pattern.match(/^(.+?)\\/\\*$/);\n if (m) {\n const parent = path.join(cwd, m[1]);\n if (await fsExtra.pathExists(parent)) {\n for (const ent of await fs.readdir(parent, {withFileTypes: true})) {\n if (ent.isDirectory() || ent.isSymbolicLink()) {\n await addUnlessNegated(path.join(parent, ent.name));\n }\n }\n }\n } else {\n await addUnlessNegated(path.join(cwd, pattern));\n }\n }\n }\n\n // 2. Linked deps installed as source — including a localized checkout that is\n // in no workspace glob. Shared with the `linked start` watch set; see\n // discoverLinkedSourceDependencies above. Glob entries win on a name clash.\n for (const entry of await discoverLinkedSourceDependencies(cwd)) {\n if (seen.has(entry.name)) continue;\n seen.add(entry.name);\n out.push(entry);\n }\n\n return out;\n}\n\n/**\n * Resolve a bare specifier like `@_linked/foo/bar`, `lincd-rdfs/Foo`, or\n * `pkg/utils/Bar.js` against the workspace lookup. Tries extensions in\n * order: .ts, .tsx, then the literal id (for files that already include\n * an extension or for non-TS assets). Returns null when the specifier\n * doesn't match any workspace package or no candidate exists on disk.\n */\nasync function resolveWorkspaceSpecifier(\n specifier: string,\n workspaces: WorkspaceEntry[],\n): Promise<string | null> {\n for (const ws of workspaces) {\n if (specifier === ws.name) {\n for (const ext of ['index.ts', 'index.tsx']) {\n const p = path.join(ws.srcDir, ext);\n if (await fsExtra.pathExists(p)) return p;\n }\n return null;\n }\n if (specifier.startsWith(ws.name + '/')) {\n const subpath = specifier.slice(ws.name.length + 1);\n // Strip .js/.jsx suffix — workspace src uses TS published-output\n // convention (./Sibling.js) but we want the TS source.\n const base = subpath.replace(/\\.jsx?$/, '');\n for (const ext of ['.tsx', '.ts']) {\n const p = path.join(ws.srcDir, base + ext);\n if (await fsExtra.pathExists(p)) return p;\n }\n // Files that already include an extension Vite handles (.css, .json,\n // .svg, etc.) — return the literal path under src.\n const literal = path.join(ws.srcDir, subpath);\n if (await fsExtra.pathExists(literal)) return literal;\n return null;\n }\n }\n return null;\n}\n\n/**\n * Packages whose entry `linked start` hands to `vite.ssrLoadModule` by name\n * (`@_linked/server/shapes/LinkedServer`, see `commands/start.ts`).\n *\n * Vite transforms an explicitly requested entry, and every file it reaches by\n * RELATIVE import, whether or not the package is external. The same package's\n * bare-specifier imports from anywhere else (the app's `src`, the storage\n * config) are externalized to Node. Left external, the package is split across\n * two loaders, and which copy a file ends up in depends on import order: a file\n * the module runner has already evaluated is reused, one it has not is loaded\n * by Node, and Node then loads that file's relative imports itself. Measured in\n * CN: `package.js` and `ontologies/lincd-server.js` evaluated once by each\n * loader, and `LocalFileStore.js` too once the package's `backend` was loaded.\n * Bundling the package makes Vite the only loader for it.\n */\nexport const SSR_ENTRY_PACKAGES = ['@_linked/server'];\n\n/**\n * `ssr.noExternal` for the dev SSR runner. With source workspaces, only those\n * package names are bundled by Vite; everything else in node_modules (including\n * published `@_linked/*`) is externalized to Node. Vite matches these entries\n * against the bare package name, so subpath imports (`pkg/shapes/Foo`) match too.\n * Installed packages that depend on a workspace (`dependents`, from\n * `workspaceDependents`) are bundled too, so they share the Vite-loaded workspace.\n * Standalone (no workspaces): the context-holding framework packages are bundled.\n * In both modes, `SSR_ENTRY_PACKAGES` are bundled.\n */\nexport function ssrNoExternal(\n workspaces: {name: string}[],\n dependents: string[] = [],\n): (string | RegExp)[] {\n if (workspaces.length === 0) {\n return [/^@_linked\\/server-utils$/, /^@_linked\\/react$/, ...SSR_ENTRY_PACKAGES];\n }\n return [...new Set([...workspaces.map((w) => w.name), ...dependents, ...SSR_ENTRY_PACKAGES])];\n}\n\n/**\n * The `process.env.*` values inlined into the browser bundle — and only there.\n * See the `environments.client.define` note in `createViteConfig` for why the\n * server environment must not receive them.\n */\nexport function clientDefine(\n opts: Pick<LinkedViteConfigOptions, 'define' | 'port'> = {},\n): Record<string, string> {\n return {\n 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV ?? 'production'),\n 'process.env.SITE_ROOT': JSON.stringify(\n process.env.SITE_ROOT ?? `http://localhost:${process.env.PORT ?? opts.port ?? 4040}`,\n ),\n // The app's display name, so client components (e.g. the header) can read it\n // like the SSR <title> does (server-utils Html reads process.env.APP_NAME). The\n // browser has no `process`, so inline it; falls back to a generic label when\n // unset so a bare checkout never renders `undefined`.\n 'process.env.APP_NAME': JSON.stringify(process.env.APP_NAME ?? 'Linked App'),\n ...(opts.define ?? {}),\n };\n}\n\nexport function createViteConfig(opts: LinkedViteConfigOptions = {}): ReturnType<typeof defineConfig> {\n return defineConfig(async ({mode}) => {\n const isDev = mode === 'development';\n const workspaces = isDev ? await discoverWorkspaces(opts.workspaceGlobs) : [];\n // STANDALONE = dev mode with no source-shipping workspaces discovered\n // (an app installed from npm outside the monorepo — its `@_linked/*` /\n // `lincd-*` deps are lib-only). discoverWorkspaces() only registers\n // packages that ship `src/` on disk, so `length === 0` is the exact\n // standalone signal used elsewhere in this file. In WORKSPACE mode\n // (CN monorepo or its workspace-member clones) this is false and none\n // of the standalone-gated branches below apply.\n const isStandalone = isDev && workspaces.length === 0;\n\n // The app's published framework deps — excluded from Vite's dep-optimizer below\n // (`optimizeDeps.exclude`) so the browser's native ESM graph loads ONE copy of each.\n // Without the exclude, esbuild inlines a duplicate `@_linked/core` into each\n // per-subpath chunk (`@_linked_schema_shapes_Person.js`,\n // `@_linked_core_utils_LinkedStorage.js`, …), duplicating framework classes\n // (`Person` → `Person2`/`3`), so their shapes register under mangled URIs that no\n // longer match the backend's (one clean copy via Node). These packages are ESM with\n // no bare CJS runtime deps (e.g. `classnames` is inlined in `@_linked/react`), so\n // native-ESM serving needs no interop shim.\n const linkedDeps: string[] = [];\n if (isStandalone) {\n try {\n const appPkg = await fsExtra.readJson(path.join(process.cwd(), 'package.json'));\n const allDeps = {...appPkg.dependencies, ...appPkg.devDependencies};\n for (const name of Object.keys(allDeps)) {\n if (isFrameworkPkg(name)) linkedDeps.push(name);\n }\n } catch {\n /* best-effort — no package.json is fine */\n }\n }\n const devPort = process.env.PORT ?? opts.port;\n const clientDepIncludes =\n isDev && opts.clientDepIncludes !== false && process.env.LINKED_CLIENT_DEP_INCLUDES !== '0';\n const config: UserConfig = {\n server: {\n port: opts.port ?? 4040,\n middlewareMode: true,\n // Unique HMR websocket port per app/worktree, derived from the dev port\n // and moved to a free one when taken — see `resolveHmrPort`. Apps can\n // still override this with their own `server.hmr` in mergeConfig.\n hmr: {port: isDev ? await resolveHmrPort({devPort}) : hmrPortFor(devPort)},\n },\n build: {\n outDir: opts.outDir ?? 'public/bundles',\n manifest: true,\n // Bump chunk-size warning so it doesn't fire on every build for\n // the linked vendor bundle. Real chunking happens via\n // manualChunks below.\n chunkSizeWarningLimit: 1000,\n rollupOptions: {\n input: opts.entry ?? 'src/index.tsx',\n output: {\n entryFileNames: 'assets/[name]-[hash].js',\n chunkFileNames: 'assets/[name]-[hash].js',\n assetFileNames: 'assets/[name]-[hash][extname]',\n manualChunks: chunkForModuleId,\n },\n },\n sourcemap: true,\n },\n plugins: [\n // Direct workspace specifier resolver.\n //\n // The package.json `\"./*\": { \"development\": \"./src/*.ts\" }` wildcard\n // can't express \"try .ts, fall back to .tsx\" (Node's exports spec\n // resolves to a single literal path). For React-heavy packages like\n // @_linked/primitives, @_linked/server-utils, and @_linked/auth,\n // most files are .tsx — the wildcard fails before any Vite plugin\n // gets a chance to fix it up.\n //\n // This plugin intercepts BARE workspace specifiers like\n // `@_linked/foo/bar` and `pkg-name/utils/Baz.js` BEFORE Vite's\n // package.json resolver runs, mapping them straight to source with\n // proper extension fallback (.tsx → .ts → literal). It also covers\n // the `./Sibling.js` published-output convention for imports made\n // from within workspace `src/` trees.\n isDev\n ? ({\n name: 'linked:resolve-workspace-ts',\n enforce: 'pre',\n async resolveId(id, importer) {\n if (id.startsWith('\\0')) return null;\n\n // Workspace-internal `./Sibling.js` → `.tsx` / `.ts` rewrite.\n if (\n importer &&\n importer.includes(`${path.sep}packages${path.sep}`) &&\n /\\.(jsx?)$/.test(id) &&\n (id.startsWith('.') || id.startsWith('/'))\n ) {\n const importerDir = path.dirname(importer);\n const base = path.resolve(importerDir, id);\n for (const ext of ['.tsx', '.ts']) {\n const candidate = base.replace(/\\.jsx?$/, ext);\n if (await fsExtra.pathExists(candidate)) return candidate;\n }\n }\n\n // Bare workspace specifier — resolve directly to src/.\n if (\n !id.startsWith('.') &&\n !id.startsWith('/') &&\n workspaces.length > 0\n ) {\n const resolved = await resolveWorkspaceSpecifier(id, workspaces);\n if (resolved) return resolved;\n }\n\n // STANDALONE (no workspaces): the linked packages are installed\n // from npm as lib-only (no `src`). We DON'T intercept them here —\n // instead the standalone `resolve.conditions` / `ssr.resolve.conditions`\n // (set on the config below, dropping Vite's `development` token)\n // let Vite's normal resolver pick each package's `import → lib/esm`\n // export. Bundling those lib files through the SSR runner works\n // (they're plain ESM); marking them external instead would leave a\n // bare specifier that `vite.ssrLoadModule` can't load\n // (\"Failed to load url @_linked/server/shapes/LinkedServer\").\n\n return null;\n },\n } as Plugin)\n : null,\n // Published lib JS: keep decorated shape classes named `Foo`, not the\n // `Foo2` Vite's esbuild re-prints would give them — see the plugin.\n pinCompiledClassNames(),\n react({\n babel: {\n parserOpts: {\n plugins: ['decorators-legacy', 'classProperties'],\n },\n },\n }),\n // Dev-only: log every file the watcher sees change. Without this,\n // backend edits look silent (no JS rebuild step, no Node restart)\n // and it's hard to tell whether\n // Vite picked up the change at all.\n isDev\n ? ({\n name: 'linked:reload-log',\n configureServer(server) {\n server.watcher.on('change', (file) => {\n const rel = file.replace(process.cwd() + '/', '');\n console.log(`[linked] reloaded ${rel}`);\n });\n },\n } as Plugin)\n : null,\n clientDepIncludes\n ? linkedClientDepIncludesPlugin({\n sourceWorkspaces: workspaces,\n deny: typeof opts.clientDepIncludes === 'object' ? opts.clientDepIncludes.deny : undefined,\n })\n : null,\n ...(opts.plugins ?? []),\n ].filter(Boolean) as Plugin[],\n css: {\n modules: {\n generateScopedName: isDev ? generateScopedName : undefined,\n },\n postcss: opts.postcssPlugins\n ? {plugins: opts.postcssPlugins as any}\n : undefined,\n },\n esbuild: {\n tsconfigRaw: {\n compilerOptions: {\n experimentalDecorators: true,\n },\n },\n jsx: 'automatic',\n // A shape's IRI is built from its class name —\n // `getNodeShapeUri(packageName, constructor.name)` — so a minifier that\n // renames the class changes the shape's identity. In a production build\n // the client would ask the server for\n // `https://linked.cm/shape/server/za` while the server had registered\n // `.../BackendAPIStore`, and every Server.call on that shape 501'd.\n // The same mangling made registration report `Shape undefined does not\n // extend base class`.\n //\n // Vite honours this in the minifier only: its per-file TypeScript\n // transform and its define pass both run esbuild with keepNames off.\n // `pinCompiledClassNames` above covers what those passes rename.\n keepNames: true,\n },\n // STANDALONE resolve conditions.\n //\n // The published `@_linked/*` / `lincd-*` packages export\n // \"development\": \"./src/*.ts\", \"import\": \"./lib/esm/*.js\"\n // In dev, Vite expands its special `development|production` condition\n // token to `development`, so it resolves these to `./src/*.ts` — which\n // doesn't exist in a lib-only npm install → boot crash\n // (\"Failed to load @_linked/server/shapes/LinkedServer\").\n //\n // Dropping the dev/prod token from the condition list means Vite never\n // adds `development`; `import` (always appended last by Vite) wins, so\n // these packages resolve to `./lib/esm/*.js`. We start from Vite's\n // default SERVER conditions (`module`, `node`, `development|production`)\n // minus the dev/prod token. This governs BOTH the plugin pipeline\n // (`resolve.conditions`) and the SSR module runner used by\n // `ssrLoadModule('@_linked/server/shapes/LinkedServer')` in\n // commands/start.ts (`ssr.resolve.conditions`).\n //\n // WORKSPACE-GATED: only applied standalone. In monorepo dev the packages\n // ship `src`, and we WANT `development → src` for HMR — so we leave\n // conditions at Vite's defaults there (undefined = untouched), keeping\n // CN dev byte-for-byte unchanged.\n ...(isStandalone\n ? {\n resolve: {\n conditions: ['module', 'node'],\n // Dedupe the context-holding packages so the two `ssrLoadModule` loads\n // (LinkedServer + the app graph) resolve to ONE `server-utils`/`react`\n // instance — otherwise their `AppContext` objects differ and\n // `useAppContext()` returns null. Pairs with `ssr.noExternal` below.\n dedupe: ['@_linked/server-utils', '@_linked/react'],\n },\n }\n : {}),\n // `ssr.external` is a minimal allowlist of\n // npm deps that genuinely can't (or shouldn't) go through Vite's\n // SSR transform. Workspace packages (`@_linked/*`, `lincd-*`) are\n // DELIBERATELY removed so Vite resolves them via each package's\n // `development → ./src/*.ts` conditional export and HMR works on\n // source changes.\n //\n // \"Multiple LINCD\" warnings may resurface during the interim until\n // LINCD eradication completes (accepted).\n ssr: {\n // NOTE: Vite's `ssr.external` only accepts exact package-name strings\n // (not regex). Standalone `@_linked/*` / `lincd-*` are NOT force-listed\n // here — they auto-externalize (or bundle) and resolve via the\n // standalone `import → lib/esm` conditions set below.\n external: [\n 'react',\n 'react-dom',\n 'react-dom/server',\n 'react-router-dom',\n 'scheduler',\n 'express',\n ],\n // Vite 7 auto-externalizes node_modules packages for SSR (loading them\n // via Node → the `import`→`lib/esm` condition), which would bypass the\n // `linked:resolve-workspace-ts` resolver and create a SECOND module\n // instance of each workspace package (breaking the single-`src`-instance\n // invariant — `LinkedStorage` state set on one instance, read on the\n // other → \"No query dispatch configured\"). Force the workspace packages\n // to be BUNDLED so they resolve via each package's `development → src`.\n //\n // WORKSPACE-GATED: only force-bundle when workspaces are actually\n // present (the monorepo / CN + CN's workspace-member clones, where the\n // `@_linked/*` packages have `src` on disk). A STANDALONE app (CLI-\n // created, no workspaces) installs `@_linked/*` from npm as lib-only —\n // those have NO `src`, so bundling them via the `development → src`\n // condition fails (\"Failed to load @_linked/server/shapes/LinkedServer\").\n // Leaving them EXTERNAL lets Node resolve `import → lib/esm`. Single-\n // instance is not a concern standalone (one node_modules copy each) and\n // core's query dispatch is global-backed regardless.\n // STANDALONE: force-bundle the framework packages that hold React context /\n // shared singletons the SSR tree must agree on — `server-utils` (`AppContext`,\n // read by `AppRoot`) and `react`. If left external, LinkedServer's\n // `AppContextProvider` and the app's `AppRoot` (`useAppContext`) can resolve to\n // DIFFERENT module instances → two `AppContext` objects → `useAppContext()` sees\n // no provider (null) → \"Cannot destructure 'isNativeApp'\" and a blank \"SSR timed\n // out\". Bundling makes them one instance in Vite's SSR module graph (matching how\n // workspace mode bundles everything). `fuseki` stays external; `server` is bundled\n // because `start` loads its entry through Vite (`SSR_ENTRY_PACKAGES`). Their native\n // dependencies (e.g. `sharp`) are separate packages and stay external either way.\n //\n // WORKSPACE: bundle ONLY the discovered source workspaces (they resolve to `src/`\n // for HMR). Published framework packages installed under node_modules (lib-only)\n // stay EXTERNAL, so Vite-loaded source and Node-native `import()` share Node's\n // single instance of them. Force-bundling every `@_linked/*` here made Vite\n // evaluate its own `@_linked/core` while `loadStores` (core) loaded a store such\n // as `@_linked/fuseki/shapes/FusekiStore` through native `import()`, which pulled\n // a SECOND Node-loaded core and split the shape registry. Installed packages\n // that depend on a workspace (e.g. published fuseki when core itself is a\n // workspace) are bundled too, so they import the Vite-loaded workspace. The one\n // published exception is `SSR_ENTRY_PACKAGES`, which Vite loads regardless.\n //\n // NOT DEV (a release build of the backend): nothing is force-bundled. The\n // compiled backend is loaded by Node next to the installed\n // `@_linked/server`, so every framework package has to stay a bare import\n // that resolves to that same node_modules copy. `workspaces` is always\n // empty here, and handing that to `ssrNoExternal` used to select the\n // standalone list — which compiled a private `server-utils` into `lib/`,\n // so no app provider was `instanceof` the server's `ShapeProvider` and\n // `LinkedServer` dropped them all (\"exports two generic backend providers\").\n noExternal: isDev ? ssrNoExternal(workspaces, await workspaceDependents(workspaces)) : [],\n // STANDALONE: the SSR module runner (`vite.ssrLoadModule`, used to\n // load LinkedServer + the app graph in commands/start.ts) has its OWN\n // condition list, defaulting to `resolve.conditions`. Set it\n // explicitly so `development` is excluded there too and the lib-only\n // packages resolve via `import → lib/esm`. Omitted (defaults kept) in\n // workspace mode so monorepo SSR still resolves `development → src`.\n ...(isStandalone\n ? {resolve: {conditions: ['module', 'node']}}\n : {}),\n },\n // Client-only, deliberately: these go on the `client` environment, not the\n // top-level `define`, because a top-level `define` is inherited by the SSR\n // environment too.\n //\n // The browser needs them. `@_linked/server-utils`'s `Server.ts` reads\n // `process.env.SITE_ROOT` to target the backend; the browser has no\n // `process`, and Vite (unlike a bundler's EnvironmentPlugin) doesn't\n // auto-inline `process.env.X`, so SITE_ROOT is defined here — always the\n // app's own origin, defaulted to `http://localhost:<port>` (an explicit\n // `SITE_ROOT` env, e.g. from `.env-cmdrc`, still wins). NODE_ENV is a\n // common client guard, so it is defined too.\n //\n // The server must NOT get them, for two reasons:\n // - it reads `process.env` at runtime, so an inlined build-time value is\n // wrong there (a release backend would carry the build machine's\n // SITE_ROOT rather than the deployment's);\n // - worse, every `define` key is a trigger. Vite's `vite:define` plugin\n // runs `esbuild.transform` — without `keepNames` — over any SSR module\n // whose text contains a key. esbuild renames the inner binding of a\n // tsc-emitted decorated class (`let LinkedServer = class LinkedServer`\n // becomes `class LinkedServer2`), and a shape's IRI is built from its\n // class name, so `@_linked/server`'s `LinkedServer` and `LincdAPI`\n // registered as `LinkedServer2` / `LincdAPI2` in dev. Without user keys\n // the SSR environment has none of its own (`keepProcessEnv` is on for\n // it), so nothing server-side is rewritten.\n //\n // Only these SPECIFIC tokens, never a whole-object `process.env`\n // replacement: in a client build Vite already maps any other\n // `process.env.X` to `{}.X` (undefined), which is what client code expects.\n //\n // Apps expose their OWN frontend env vars through the `define` option,\n // which lands here too:\n // createViteConfig({ define: {\n // 'process.env.MY_PUBLIC_KEY': JSON.stringify(process.env.MY_PUBLIC_KEY),\n // }})\n // (only reference PUBLIC vars in client code — a defined secret would be\n // inlined into the browser bundle). An app that puts a top-level `define`\n // in its own config reintroduces both problems for the server; use\n // `environments.client.define` there as well.\n environments: {\n client: {\n define: clientDefine(opts),\n },\n },\n // WORKSPACE mode: exclude the source-shipping workspace packages (@_linked/*,\n // lincd-*) from esbuild's dep pre-bundler. They resolve to `src/` via the\n // `linked:resolve-workspace-ts` plugin; in a workspace-member CLONE they'd\n // otherwise resolve via `node_modules` SYMLINKS and esbuild fails on their\n // subpath `exports` (\"No known conditions for ./shapes/SHACL …\").\n // STANDALONE mode: exclude the published `@_linked/*` / `lincd-*` deps from\n // esbuild's pre-bundler so the browser's native ESM graph loads ONE copy of\n // `@_linked/core` (no per-subpath duplication → stable class names → shape URIs\n // match the backend — see `linkedDeps` above). These packages are ESM with no\n // bare CJS runtime deps (e.g. `classnames` is inlined in `@_linked/react`), so\n // serving them as native ESM needs no interop shim.\n // An excluded package is not crawled, so its OWN third-party imports (Radix,\n // vaul, js-cookie…) are listed in `optimizeDeps.include` by the\n // `linked:client-dep-includes` plugin above, once the app's excludes are final.\n ...(workspaces.length > 0\n ? {optimizeDeps: {exclude: workspaces.map((w) => w.name)}}\n : isStandalone && linkedDeps.length > 0\n ? {optimizeDeps: {exclude: linkedDeps}}\n : {}),\n };\n\n // Tailwind plugin (only if explicitly enabled — adds a heavy plugin).\n if (opts.cssMode === 'tailwind') {\n // Try ESM dynamic import first (works when @tailwindcss/vite is\n // installed in the app or hoisted). Surface a CLEAR warning when\n // it's not — the app needs the dep for theme variables to load.\n try {\n const tailwind: any = await import('@tailwindcss/vite' as any);\n const tailwindPlugin = tailwind.default ?? tailwind;\n (config.plugins as Plugin[]).push(tailwindPlugin());\n } catch (err) {\n console.warn(\n '[createViteConfig] cssMode=tailwind but @tailwindcss/vite ' +\n 'could not be loaded. Theme variables won\\'t apply at runtime. ' +\n 'Add `@tailwindcss/vite` to your app\\'s package.json.',\n );\n }\n }\n\n return config;\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"vite-config.js","sourceRoot":"","sources":["../../src/vite-config.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,oEAAoE;AACpE,EAAE;AACF,+CAA+C;AAC/C,EAAE;AACF,wDAAwD;AACxD,wEAAwE;AACxE,EAAE;AACF,mEAAmE;AACnE,qEAAqE;AACrE,uEAAu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;oBAC1D,gEAAgE;oBAChE,sDAAsD,CACzD,CAAC;YACJ,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC,CAAA,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Vite config helper for linked apps. The one dev + build pipeline.\n//\n// Apps use this from their own vite.config.ts:\n//\n// import {createViteConfig} from '@_linked/cli/vite';\n// export default createViteConfig({port: 4040, cssMode: 'tailwind'});\n//\n// The helper preserves the dev-mode `generateScopedName` (readable\n// `_packageName_filename_className`) so CSS module class names match\n// what the previous bundler chain produced for trace/debug. Production\n// uses `generateScopedNameProduction`, which the Node CSS loader shares so the\n// server renders the class names the client's stylesheet defines.\nimport {defineConfig} from 'vite';\nimport react from '@vitejs/plugin-react';\nimport fsExtra from 'fs-extra';\nimport path from 'node:path';\nimport {generateScopedName} from './utils.js';\nimport {generateScopedNameProduction} from './css-module-names.js';\nimport {parseWorkspacePatterns, isWorkspacePathNegated} from './workspace-globs.js';\nimport {pinCompiledClassNames} from './plugins/pin-compiled-class-names.js';\nimport {isFrameworkPkg, readInstalledPkg} from './installed-packages.js';\nimport {linkedClientDepIncludesPlugin} from './client-dep-includes.js';\nimport type {Plugin, UserConfig} from 'vite';\n\n/** Default dev server port, and Vite's default HMR websocket port. */\nconst DEFAULT_DEV_PORT = 4040;\nconst DEFAULT_HMR_PORT = 24678;\n/** Vite may not bind below 1024 without privileges; 65535 is the TCP ceiling. */\nconst MIN_HMR_PORT = 1024;\nconst MAX_HMR_PORT = 65535;\n\n/**\n * Derive an app's HMR websocket port from its dev port.\n *\n * Every `createViteConfig` app used to fall back to Vite's shared default\n * 24678, so any two dev servers running at once collided (\"Port 24678 is\n * already in use\") and HMR silently broke for the loser. Offsetting the HMR\n * port by the same amount the dev port is offset from its default keeps the\n * derivation trivial and means apps that already run on distinct dev ports get\n * distinct HMR ports for free.\n *\n * The input is untrusted (`process.env.PORT` is an arbitrary string), so\n * anything that is not a whole port number — `PORT=abc` yielding `NaN`, a\n * negative or out-of-range value — falls back to the dev port default. The\n * result is then clamped into the bindable range, since a far-out dev port\n * would otherwise derive an HMR port past 65535.\n */\n/**\n * Which manual chunk a module belongs in.\n *\n * Split large/common deps so route chunks don't all carry their own copy AND\n * the main entry doesn't end up at 5MB+. Each chunk becomes its own\n * `assets/<name>-<hash>.js` the browser caches independently — incremental\n * dev builds and cache wins on prod deploys both improve.\n *\n * Exported so the grouping can be asserted directly: getting it wrong does not\n * fail the build, it produces a bundle that throws on load in the browser.\n */\nexport const chunkForModuleId = (id: string): string | undefined => {\n if (!id.includes('node_modules')) {\n // Linked workspaces ship as @_linked/* / lincd-* — group all\n // linked-framework code into a single chunk.\n if (\n id.includes('/packages/core/') ||\n id.includes('/packages/react/') ||\n id.includes('/packages/server-utils/') ||\n id.includes('/packages/primitives/') ||\n id.includes('/packages/css/') ||\n /\\/packages\\/(auth|org|schema|fuseki|owl|xsd|dcat|dcmi|s3|sentry|ui)\\//.test(id)\n ) {\n return 'linked';\n }\n return undefined;\n }\n // Framework code installed from the registry rather than resolved to a\n // workspace. An app can hold both at once — a published `@_linked/server`\n // in node_modules next to workspace `@_linked/core` — and the two import\n // each other. Split across `linked` and `vendor` that is a cycle, and\n // Rollup's chosen order left a binding in its temporal dead zone:\n // `Cannot access 'Wo' before initialization` before the app rendered.\n // Same chunk, no cycle.\n if (/[\\\\/]node_modules[\\\\/](@_linked[\\\\/]|lincd-)/.test(id)) {\n return 'linked';\n }\n // React + React-DOM in their own chunk — every route uses them.\n //\n // react-router and @remix-run/router belong here too. Left in `vendor` they\n // made the two chunks import each other: react-router-dom re-exports\n // react-router, so react-vendor imported vendor, while vendor's own\n // top-level `React.createContext(...)` calls imported react-vendor. Rollup\n // has to pick an order for a cycle, and it ran vendor first — every\n // production build died on load with \"Cannot read properties of undefined\n // (reading 'createContext')\".\n if (\n /[\\\\/]node_modules[\\\\/](react|react-dom|react-router-dom|react-router|@remix-run[\\\\/]router|scheduler)[\\\\/]/.test(\n id\n )\n ) {\n return 'react-vendor';\n }\n // Heavy editor deps — only loaded on pages that need them, but worth\n // isolating so they don't get pulled into main.\n if (/[\\\\/]node_modules[\\\\/]@monaco-editor[\\\\/]/.test(id)) {\n return 'monaco';\n }\n // Charting/visualization\n if (/[\\\\/]node_modules[\\\\/](recharts|react-flow|@xyflow|d3-)[\\\\/]/.test(id)) {\n return 'viz';\n }\n // Animation\n if (/[\\\\/]node_modules[\\\\/]framer-motion[\\\\/]/.test(id)) {\n return 'motion';\n }\n // Catch-all for other node_modules in a vendor chunk\n return 'vendor';\n};\n\nexport function hmrPortFor(devPort: unknown): number {\n const parsed = Number(devPort);\n const validDevPort =\n Number.isFinite(parsed) && Number.isInteger(parsed) && parsed >= 1 && parsed <= 65535\n ? parsed\n : DEFAULT_DEV_PORT;\n const derived = DEFAULT_HMR_PORT + (validDevPort - DEFAULT_DEV_PORT);\n return Math.min(MAX_HMR_PORT, Math.max(MIN_HMR_PORT, derived));\n}\n\n/** How far past the derived port `resolveHmrPort` looks for a free one. */\nconst HMR_PORT_SEARCH_RANGE = 100;\n\n/**\n * Whether `port` can be listened on the way Vite's HMR websocket server\n * listens: every interface, since `createViteConfig` sets no `hmr.host`.\n */\nexport function isPortFree(port: number, host?: string): Promise<boolean> {\n return import('node:net').then(\n (net) =>\n new Promise<boolean>((resolve) => {\n const probe = net.createServer();\n probe.unref();\n probe.once('error', () => resolve(false));\n probe.listen({port, host, exclusive: true}, () => probe.close(() => resolve(true)));\n }),\n );\n}\n\n/**\n * Ports this process already chose, by derived port. Vite re-evaluates the\n * config when it restarts the server (a vite.config edit), and it does so while\n * the old server still holds the port — probing again would see our own socket\n * and move to the next port on every restart.\n */\nconst chosenHmrPorts: Map<number, number> = ((globalThis as any)[Symbol.for('@_linked/cli.hmrPorts')] ??=\n new Map<number, number>());\n\nexport interface ResolveHmrPortOptions {\n /** The dev port the HMR port is derived from (`process.env.PORT ?? opts.port`). */\n devPort: unknown;\n env?: NodeJS.ProcessEnv;\n isFree?: (port: number) => Promise<boolean>;\n log?: (message: string) => void;\n}\n\n/**\n * The HMR websocket port for this dev server.\n *\n * `LINKED_HMR_PORT` wins outright. Otherwise the port derived from the dev port\n * (`hmrPortFor`) is used if it is free, and the next free port above it if it\n * is not: the derivation keeps apps on distinct dev ports apart, but not an app\n * from an unrelated process (or a second checkout of the same app) that already\n * holds the derived port. Vite injects the configured `hmr.port` into the\n * client it serves, so the browser connects to whichever port was chosen.\n *\n * If nothing in range is free the derived port is returned and Vite reports the\n * conflict, as it did before.\n */\nexport async function resolveHmrPort({\n devPort,\n env = process.env,\n isFree = isPortFree,\n log = (m) => console.log(m),\n}: ResolveHmrPortOptions): Promise<number> {\n const override = env.LINKED_HMR_PORT;\n if (override !== undefined && override.trim() !== '') {\n const port = Number(override);\n if (Number.isInteger(port) && port >= 1 && port <= MAX_HMR_PORT) return port;\n log(`[linked] ignoring LINKED_HMR_PORT=${override}: not a port number`);\n }\n const derived = hmrPortFor(devPort);\n const remembered = chosenHmrPorts.get(derived);\n if (remembered !== undefined) return remembered;\n for (let port = derived; port <= Math.min(MAX_HMR_PORT, derived + HMR_PORT_SEARCH_RANGE); port++) {\n if (await isFree(port)) {\n chosenHmrPorts.set(derived, port);\n if (port !== derived) {\n log(`[linked] HMR port ${derived} is in use; using ${port} (set LINKED_HMR_PORT to choose one)`);\n }\n return port;\n }\n }\n return derived;\n}\n\nexport interface LinkedViteConfigOptions {\n /** Dev server port. Default 4040. */\n port?: number;\n /** Output dir for `vite build`. Default `public/bundles`. */\n outDir?: string;\n /** CSS pipeline mode. */\n cssMode?: 'tailwind' | 'css-modules-only';\n /** Entry file for the client bundle. Default `src/index.tsx`. */\n entry?: string;\n /** Extra Vite plugins. */\n plugins?: Plugin[];\n /** Extra PostCSS plugins (e.g. `postcss-media-to-container`). */\n postcssPlugins?: unknown[];\n /**\n * Extra `define` entries for the CLIENT environment only (used to bridge\n * `process.env.X` refs into the browser). Never applied server-side.\n */\n define?: Record<string, string>;\n /**\n * Extra workspace globs (trailing `/*`, or a direct package dir) resolved\n * RELATIVE TO the app's cwd, in ADDITION to the app's own `workspaces` field.\n *\n * For apps whose linked-package sources live OUTSIDE their own workspace tree\n * — e.g. an app consumes `packages/lincd.org/modules/*`, which sit one level\n * up (`../lincd.org/modules/*`) when the app runs inside the CN monorepo, and under\n * `packages/lincd.org/modules/*` when the app runs from its own root. Pass BOTH\n * candidate layouts; only globs whose parent dir actually exists are scanned,\n * so the same config works in either checkout. Each glob's packages are\n * registered as source workspaces (resolved to `src/` for HMR + single-instance),\n * exactly like the app's own `workspaces` field.\n */\n workspaceGlobs?: string[];\n /**\n * Add the third-party client dependencies of the excluded framework packages\n * to `optimizeDeps.include` in dev (see ./client-dep-includes.ts). Default on;\n * `false` (or `LINKED_CLIENT_DEP_INCLUDES=0`) turns it off, and `deny` keeps\n * entries out — matched against the entry (`'@_linked/primitives > vaul'`),\n * the specifier (`'vaul'`) or the package name. Run with `DEBUG=linked` to see\n * what was added.\n */\n clientDepIncludes?: boolean | {deny?: (string | RegExp)[]};\n}\n\ninterface WorkspaceEntry {\n name: string;\n srcDir: string;\n}\n\n/**\n * Names of installed packages that depend, directly or transitively (via\n * `dependencies` / `peerDependencies`), on a discovered source workspace. Such a\n * package must also go through Vite SSR: if Node loaded it natively, it would\n * import its own Node-loaded copy of the workspace (e.g. published\n * `@_linked/fuseki` importing a workspace `@_linked/core`), splitting module\n * state. Vite rewrites the dynamic `import()` in code it transforms, so bundling\n * the dependents keeps one instance.\n *\n * Only the dependency closure of the app's `package.json` (dependencies +\n * devDependencies) and of the workspaces themselves is scanned. Packages are\n * resolved Node-style, keyed by real path, and unresolvable ones are ignored.\n * Workspace names are not included in the result.\n */\nexport async function workspaceDependents(\n workspaces: {name: string; srcDir?: string}[],\n cwd: string = process.cwd(),\n): Promise<string[]> {\n if (workspaces.length === 0) return [];\n const fs = await import('node:fs/promises');\n const wsNames = new Set(workspaces.map((w) => w.name));\n // realRoot -> {name, deps (realRoots)}\n const nodes = new Map<string, {name: string; deps: Set<string>}>();\n const realpath = async (p: string): Promise<string> => {\n try {\n return await fs.realpath(p);\n } catch {\n return path.resolve(p);\n }\n };\n\n const visit = async (root: string, json: any): Promise<string> => {\n const real = await realpath(root);\n if (nodes.has(real)) return real;\n const node = {name: json.name as string, deps: new Set<string>()};\n nodes.set(real, node);\n const names = new Set([\n ...Object.keys(json.dependencies ?? {}),\n ...Object.keys(json.peerDependencies ?? {}),\n ]);\n for (const dep of names) {\n const resolved = await readInstalledPkg(dep, real);\n if (resolved) node.deps.add(await visit(resolved.root, resolved.json));\n }\n return real;\n };\n\n // Seed: the app's direct deps, plus each workspace package's own deps.\n try {\n const appPkg = await fsExtra.readJson(path.join(cwd, 'package.json'));\n for (const dep of Object.keys({...appPkg.dependencies, ...appPkg.devDependencies})) {\n const resolved = await readInstalledPkg(dep, cwd);\n if (resolved) await visit(resolved.root, resolved.json);\n }\n } catch {}\n for (const ws of workspaces) {\n if (!ws.srcDir) continue;\n const root = path.dirname(ws.srcDir);\n try {\n await visit(root, await fsExtra.readJson(path.join(root, 'package.json')));\n } catch {}\n }\n\n // Walk reverse edges from every workspace node: everything reached depends on one.\n const dependentsOf = new Map<string, string[]>();\n for (const [key, node] of nodes) {\n for (const dep of node.deps) {\n if (!dependentsOf.has(dep)) dependentsOf.set(dep, []);\n dependentsOf.get(dep)!.push(key);\n }\n }\n const queue = [...nodes].filter(([, n]) => wsNames.has(n.name)).map(([k]) => k);\n const marked = new Set(queue);\n while (queue.length) {\n for (const parent of dependentsOf.get(queue.pop()!) ?? []) {\n if (!marked.has(parent)) {\n marked.add(parent);\n queue.push(parent);\n }\n }\n }\n const out = new Set<string>();\n for (const key of marked) {\n const name = nodes.get(key)!.name;\n if (name && !wsNames.has(name)) out.add(name);\n }\n return [...out].sort();\n}\n\n/**\n * Read a package root as a SOURCE install: `{name, srcDir}` iff it has a\n * package.json with a name and ships a `src/` dir. Published packages have only\n * `lib/` and are skipped — they resolve via their exports.\n */\nasync function readSourcePackage(root: string): Promise<WorkspaceEntry | null> {\n const pkgPath = path.join(root, 'package.json');\n if (!(await fsExtra.pathExists(pkgPath))) return null;\n const srcDir = path.join(root, 'src');\n if (!(await fsExtra.pathExists(srcDir))) return null;\n try {\n const json = await fsExtra.readJson(pkgPath);\n return json.name ? {name: json.name, srcDir} : null;\n } catch {\n return null;\n }\n}\n\n/**\n * Linked packages installed as SOURCE, found by walking the app's\n * `dependencies` + `devDependencies` (and recursing through the `dependencies`\n * of each linked package found), keeping those marked `\"linkedPackage\": true`\n * — the same marker the CLI keys on (see cli-methods.ts) — and registering the\n * ones that ship `src/`.\n *\n * A dep ships `src/` when it is a symlinked workspace clone, a `link:`/`portal:`\n * dev install, or a LOCALIZED checkout (`packages-local/<pkg>`, in no workspace\n * glob). That's what lets a STANDALONE app (not itself a workspace root — e.g. a\n * per-branch clone under /apps) resolve a linked package's `.tsx` sources with\n * extension probing, instead of falling through to the package's\n * `development → ./src/*.ts` export (which misses `.tsx` like LinkedServer). A\n * prod/ejected app installs PUBLISHED packages (no `src/`) → not registered,\n * resolved via each package's `lib`.\n *\n * The marker — NOT the npm scope — drives discovery, so a user's own\n * custom-scope published linked package (e.g. `@acme/foo` with\n * `linkedPackage:true`) is picked up too, and linked packages present in\n * node_modules but not depended upon are ignored.\n *\n * Every root is REALPATHED before it is registered: `readInstalledPkg` returns\n * the `node_modules/<name>` symlink spelling, and Vite's resolver realpaths\n * every id it produces, so registering the symlink would give one file two\n * module ids — two instances of the same module.\n *\n * Shared by the Vite resolver table (`discoverWorkspaces`) and the `linked start`\n * HMR watch set, so the two cannot disagree about what is source.\n */\nexport async function discoverLinkedSourceDependencies(\n cwd: string = process.cwd(),\n): Promise<WorkspaceEntry[]> {\n const pkgPath = path.join(cwd, 'package.json');\n if (!(await fsExtra.pathExists(pkgPath))) return [];\n const fs = await import('node:fs/promises');\n const out: WorkspaceEntry[] = [];\n const seen = new Set<string>();\n const visited = new Set<string>();\n const walk = async (\n deps: Record<string, string> | undefined,\n fromDir: string,\n ): Promise<void> => {\n for (const name of Object.keys(deps ?? {})) {\n if (visited.has(name)) continue;\n visited.add(name);\n const resolved = await readInstalledPkg(name, fromDir);\n if (!resolved) continue;\n if (resolved.json.linkedPackage !== true) continue;\n let realRoot = resolved.root;\n try {\n realRoot = await fs.realpath(resolved.root);\n } catch {}\n const entry = await readSourcePackage(realRoot);\n if (entry && !seen.has(entry.name)) {\n seen.add(entry.name);\n out.push(entry);\n }\n // Recurse from the real location, so a symlinked clone resolves its own\n // dependencies from its source dir.\n await walk(resolved.json.dependencies, realRoot);\n }\n };\n const appPkg = await fsExtra.readJson(pkgPath);\n await walk(appPkg.dependencies, cwd);\n await walk(appPkg.devDependencies, cwd);\n return out;\n}\n\n/**\n * Walk the app's package.json `workspaces` field to build a lookup table\n * from npm name → absolute src/ directory. Used by the resolver plugin\n * to map bare specifiers like `@_linked/foo/bar` directly to source.\n *\n * Positive patterns are expanded by directory listing, so only a trailing `/*`\n * is honoured. NEGATED patterns (`\"!packages/core\"`) are honoured in full, with\n * npm's semantics — see ./workspace-globs.js. Skipping them would resolve a\n * package to an excluded directory that the package manager never installed\n * dependencies for.\n */\nexport async function discoverWorkspaces(\n extraGlobs: string[] = [],\n cwd: string = process.cwd(),\n): Promise<WorkspaceEntry[]> {\n const fs = await import('node:fs/promises');\n const out: WorkspaceEntry[] = [];\n const seen = new Set<string>();\n // Register a package root iff it ships a `src/` dir (source install).\n const addFromRoot = async (root: string): Promise<void> => {\n const entry = await readSourcePackage(root);\n if (!entry || seen.has(entry.name)) return;\n seen.add(entry.name);\n out.push(entry);\n };\n\n // 1. The app's own `workspaces` globs — the monorepo-root case (CN, or any app\n // that is itself a workspace root). Only trailing `/*` patterns.\n const pkgPath = path.join(cwd, 'package.json');\n if (await fsExtra.pathExists(pkgPath)) {\n const pkg = await fsExtra.readJson(pkgPath);\n // Merge the app's own `workspaces` globs with any caller-supplied\n // `workspaceGlobs` (e.g. `../lincd.org/modules/*`). Non-existent parents\n // are skipped below, so passing both nested + standalone layouts is safe.\n // Either list may carry negations, so they are parsed together.\n const {patterns, negatedPatterns} = parseWorkspacePatterns([\n ...(Array.isArray(pkg.workspaces) ? pkg.workspaces : pkg.workspaces?.packages ?? []),\n ...extraGlobs,\n ]);\n const addUnlessNegated = async (root: string): Promise<void> => {\n const rel = path.relative(cwd, root).split(path.sep).join('/');\n if (isWorkspacePathNegated(rel, negatedPatterns)) return;\n await addFromRoot(root);\n };\n for (const pattern of patterns) {\n const m = pattern.match(/^(.+?)\\/\\*$/);\n if (m) {\n const parent = path.join(cwd, m[1]);\n if (await fsExtra.pathExists(parent)) {\n for (const ent of await fs.readdir(parent, {withFileTypes: true})) {\n if (ent.isDirectory() || ent.isSymbolicLink()) {\n await addUnlessNegated(path.join(parent, ent.name));\n }\n }\n }\n } else {\n await addUnlessNegated(path.join(cwd, pattern));\n }\n }\n }\n\n // 2. Linked deps installed as source — including a localized checkout that is\n // in no workspace glob. Shared with the `linked start` watch set; see\n // discoverLinkedSourceDependencies above. Glob entries win on a name clash.\n for (const entry of await discoverLinkedSourceDependencies(cwd)) {\n if (seen.has(entry.name)) continue;\n seen.add(entry.name);\n out.push(entry);\n }\n\n return out;\n}\n\n/**\n * Resolve a bare specifier like `@_linked/foo/bar`, `lincd-rdfs/Foo`, or\n * `pkg/utils/Bar.js` against the workspace lookup. Tries extensions in\n * order: .ts, .tsx, then the literal id (for files that already include\n * an extension or for non-TS assets). Returns null when the specifier\n * doesn't match any workspace package or no candidate exists on disk.\n */\nasync function resolveWorkspaceSpecifier(\n specifier: string,\n workspaces: WorkspaceEntry[],\n): Promise<string | null> {\n for (const ws of workspaces) {\n if (specifier === ws.name) {\n for (const ext of ['index.ts', 'index.tsx']) {\n const p = path.join(ws.srcDir, ext);\n if (await fsExtra.pathExists(p)) return p;\n }\n return null;\n }\n if (specifier.startsWith(ws.name + '/')) {\n const subpath = specifier.slice(ws.name.length + 1);\n // Strip .js/.jsx suffix — workspace src uses TS published-output\n // convention (./Sibling.js) but we want the TS source.\n const base = subpath.replace(/\\.jsx?$/, '');\n for (const ext of ['.tsx', '.ts']) {\n const p = path.join(ws.srcDir, base + ext);\n if (await fsExtra.pathExists(p)) return p;\n }\n // Files that already include an extension Vite handles (.css, .json,\n // .svg, etc.) — return the literal path under src.\n const literal = path.join(ws.srcDir, subpath);\n if (await fsExtra.pathExists(literal)) return literal;\n return null;\n }\n }\n return null;\n}\n\n/**\n * Packages whose entry `linked start` hands to `vite.ssrLoadModule` by name\n * (`@_linked/server/shapes/LinkedServer`, see `commands/start.ts`).\n *\n * Vite transforms an explicitly requested entry, and every file it reaches by\n * RELATIVE import, whether or not the package is external. The same package's\n * bare-specifier imports from anywhere else (the app's `src`, the storage\n * config) are externalized to Node. Left external, the package is split across\n * two loaders, and which copy a file ends up in depends on import order: a file\n * the module runner has already evaluated is reused, one it has not is loaded\n * by Node, and Node then loads that file's relative imports itself. Measured in\n * CN: `package.js` and `ontologies/lincd-server.js` evaluated once by each\n * loader, and `LocalFileStore.js` too once the package's `backend` was loaded.\n * Bundling the package makes Vite the only loader for it.\n */\nexport const SSR_ENTRY_PACKAGES = ['@_linked/server'];\n\n/**\n * `ssr.noExternal` for the dev SSR runner. With source workspaces, only those\n * package names are bundled by Vite; everything else in node_modules (including\n * published `@_linked/*`) is externalized to Node. Vite matches these entries\n * against the bare package name, so subpath imports (`pkg/shapes/Foo`) match too.\n * Installed packages that depend on a workspace (`dependents`, from\n * `workspaceDependents`) are bundled too, so they share the Vite-loaded workspace.\n * Standalone (no workspaces): the context-holding framework packages are bundled.\n * In both modes, `SSR_ENTRY_PACKAGES` are bundled.\n */\nexport function ssrNoExternal(\n workspaces: {name: string}[],\n dependents: string[] = [],\n): (string | RegExp)[] {\n if (workspaces.length === 0) {\n return [/^@_linked\\/server-utils$/, /^@_linked\\/react$/, ...SSR_ENTRY_PACKAGES];\n }\n return [...new Set([...workspaces.map((w) => w.name), ...dependents, ...SSR_ENTRY_PACKAGES])];\n}\n\n/**\n * The `process.env.*` values inlined into the browser bundle — and only there.\n * See the `environments.client.define` note in `createViteConfig` for why the\n * server environment must not receive them.\n */\nexport function clientDefine(\n opts: Pick<LinkedViteConfigOptions, 'define' | 'port'> = {},\n): Record<string, string> {\n return {\n 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV ?? 'production'),\n 'process.env.SITE_ROOT': JSON.stringify(\n process.env.SITE_ROOT ?? `http://localhost:${process.env.PORT ?? opts.port ?? 4040}`,\n ),\n // The app's display name, so client components (e.g. the header) can read it\n // like the SSR <title> does (server-utils Html reads process.env.APP_NAME). The\n // browser has no `process`, so inline it; falls back to a generic label when\n // unset so a bare checkout never renders `undefined`.\n 'process.env.APP_NAME': JSON.stringify(process.env.APP_NAME ?? 'Linked App'),\n ...(opts.define ?? {}),\n };\n}\n\nexport function createViteConfig(opts: LinkedViteConfigOptions = {}): ReturnType<typeof defineConfig> {\n return defineConfig(async ({mode}) => {\n const isDev = mode === 'development';\n const workspaces = isDev ? await discoverWorkspaces(opts.workspaceGlobs) : [];\n // STANDALONE = dev mode with no source-shipping workspaces discovered\n // (an app installed from npm outside the monorepo — its `@_linked/*` /\n // `lincd-*` deps are lib-only). discoverWorkspaces() only registers\n // packages that ship `src/` on disk, so `length === 0` is the exact\n // standalone signal used elsewhere in this file. In WORKSPACE mode\n // (CN monorepo or its workspace-member clones) this is false and none\n // of the standalone-gated branches below apply.\n const isStandalone = isDev && workspaces.length === 0;\n\n // The app's published framework deps — excluded from Vite's dep-optimizer below\n // (`optimizeDeps.exclude`) so the browser's native ESM graph loads ONE copy of each.\n // Without the exclude, esbuild inlines a duplicate `@_linked/core` into each\n // per-subpath chunk (`@_linked_schema_shapes_Person.js`,\n // `@_linked_core_utils_LinkedStorage.js`, …), duplicating framework classes\n // (`Person` → `Person2`/`3`), so their shapes register under mangled URIs that no\n // longer match the backend's (one clean copy via Node). These packages are ESM with\n // no bare CJS runtime deps (e.g. `classnames` is inlined in `@_linked/react`), so\n // native-ESM serving needs no interop shim.\n const linkedDeps: string[] = [];\n if (isStandalone) {\n try {\n const appPkg = await fsExtra.readJson(path.join(process.cwd(), 'package.json'));\n const allDeps = {...appPkg.dependencies, ...appPkg.devDependencies};\n for (const name of Object.keys(allDeps)) {\n if (isFrameworkPkg(name)) linkedDeps.push(name);\n }\n } catch {\n /* best-effort — no package.json is fine */\n }\n }\n const devPort = process.env.PORT ?? opts.port;\n const clientDepIncludes =\n isDev && opts.clientDepIncludes !== false && process.env.LINKED_CLIENT_DEP_INCLUDES !== '0';\n const config: UserConfig = {\n server: {\n port: opts.port ?? 4040,\n middlewareMode: true,\n // Unique HMR websocket port per app/worktree, derived from the dev port\n // and moved to a free one when taken — see `resolveHmrPort`. Apps can\n // still override this with their own `server.hmr` in mergeConfig.\n hmr: {port: isDev ? await resolveHmrPort({devPort}) : hmrPortFor(devPort)},\n },\n build: {\n outDir: opts.outDir ?? 'public/bundles',\n manifest: true,\n // Bump chunk-size warning so it doesn't fire on every build for\n // the linked vendor bundle. Real chunking happens via\n // manualChunks below.\n chunkSizeWarningLimit: 1000,\n rollupOptions: {\n input: opts.entry ?? 'src/index.tsx',\n output: {\n entryFileNames: 'assets/[name]-[hash].js',\n chunkFileNames: 'assets/[name]-[hash].js',\n assetFileNames: 'assets/[name]-[hash][extname]',\n manualChunks: chunkForModuleId,\n },\n },\n sourcemap: true,\n },\n plugins: [\n // Direct workspace specifier resolver.\n //\n // The package.json `\"./*\": { \"development\": \"./src/*.ts\" }` wildcard\n // can't express \"try .ts, fall back to .tsx\" (Node's exports spec\n // resolves to a single literal path). For React-heavy packages like\n // @_linked/primitives, @_linked/server-utils, and @_linked/auth,\n // most files are .tsx — the wildcard fails before any Vite plugin\n // gets a chance to fix it up.\n //\n // This plugin intercepts BARE workspace specifiers like\n // `@_linked/foo/bar` and `pkg-name/utils/Baz.js` BEFORE Vite's\n // package.json resolver runs, mapping them straight to source with\n // proper extension fallback (.tsx → .ts → literal). It also covers\n // the `./Sibling.js` published-output convention for imports made\n // from within workspace `src/` trees.\n isDev\n ? ({\n name: 'linked:resolve-workspace-ts',\n enforce: 'pre',\n async resolveId(id, importer) {\n if (id.startsWith('\\0')) return null;\n\n // Workspace-internal `./Sibling.js` → `.tsx` / `.ts` rewrite.\n if (\n importer &&\n importer.includes(`${path.sep}packages${path.sep}`) &&\n /\\.(jsx?)$/.test(id) &&\n (id.startsWith('.') || id.startsWith('/'))\n ) {\n const importerDir = path.dirname(importer);\n const base = path.resolve(importerDir, id);\n for (const ext of ['.tsx', '.ts']) {\n const candidate = base.replace(/\\.jsx?$/, ext);\n if (await fsExtra.pathExists(candidate)) return candidate;\n }\n }\n\n // Bare workspace specifier — resolve directly to src/.\n if (\n !id.startsWith('.') &&\n !id.startsWith('/') &&\n workspaces.length > 0\n ) {\n const resolved = await resolveWorkspaceSpecifier(id, workspaces);\n if (resolved) return resolved;\n }\n\n // STANDALONE (no workspaces): the linked packages are installed\n // from npm as lib-only (no `src`). We DON'T intercept them here —\n // instead the standalone `resolve.conditions` / `ssr.resolve.conditions`\n // (set on the config below, dropping Vite's `development` token)\n // let Vite's normal resolver pick each package's `import → lib/esm`\n // export. Bundling those lib files through the SSR runner works\n // (they're plain ESM); marking them external instead would leave a\n // bare specifier that `vite.ssrLoadModule` can't load\n // (\"Failed to load url @_linked/server/shapes/LinkedServer\").\n\n return null;\n },\n } as Plugin)\n : null,\n // Published lib JS: keep decorated shape classes named `Foo`, not the\n // `Foo2` Vite's esbuild re-prints would give them — see the plugin.\n pinCompiledClassNames(),\n react({\n babel: {\n parserOpts: {\n plugins: ['decorators-legacy', 'classProperties'],\n },\n },\n }),\n // Dev-only: log every file the watcher sees change. Without this,\n // backend edits look silent (no JS rebuild step, no Node restart)\n // and it's hard to tell whether\n // Vite picked up the change at all.\n isDev\n ? ({\n name: 'linked:reload-log',\n configureServer(server) {\n server.watcher.on('change', (file) => {\n const rel = file.replace(process.cwd() + '/', '');\n console.log(`[linked] reloaded ${rel}`);\n });\n },\n } as Plugin)\n : null,\n clientDepIncludes\n ? linkedClientDepIncludesPlugin({\n sourceWorkspaces: workspaces,\n deny: typeof opts.clientDepIncludes === 'object' ? opts.clientDepIncludes.deny : undefined,\n })\n : null,\n ...(opts.plugins ?? []),\n ].filter(Boolean) as Plugin[],\n css: {\n modules: {\n generateScopedName: isDev ? generateScopedName : generateScopedNameProduction,\n },\n postcss: opts.postcssPlugins\n ? {plugins: opts.postcssPlugins as any}\n : undefined,\n },\n esbuild: {\n tsconfigRaw: {\n compilerOptions: {\n experimentalDecorators: true,\n },\n },\n jsx: 'automatic',\n // A shape's IRI is built from its class name —\n // `getNodeShapeUri(packageName, constructor.name)` — so a minifier that\n // renames the class changes the shape's identity. In a production build\n // the client would ask the server for\n // `https://linked.cm/shape/server/za` while the server had registered\n // `.../BackendAPIStore`, and every Server.call on that shape 501'd.\n // The same mangling made registration report `Shape undefined does not\n // extend base class`.\n //\n // Vite honours this in the minifier only: its per-file TypeScript\n // transform and its define pass both run esbuild with keepNames off.\n // `pinCompiledClassNames` above covers what those passes rename.\n keepNames: true,\n },\n // STANDALONE resolve conditions.\n //\n // The published `@_linked/*` / `lincd-*` packages export\n // \"development\": \"./src/*.ts\", \"import\": \"./lib/esm/*.js\"\n // In dev, Vite expands its special `development|production` condition\n // token to `development`, so it resolves these to `./src/*.ts` — which\n // doesn't exist in a lib-only npm install → boot crash\n // (\"Failed to load @_linked/server/shapes/LinkedServer\").\n //\n // Dropping the dev/prod token from the condition list means Vite never\n // adds `development`; `import` (always appended last by Vite) wins, so\n // these packages resolve to `./lib/esm/*.js`. We start from Vite's\n // default SERVER conditions (`module`, `node`, `development|production`)\n // minus the dev/prod token. This governs BOTH the plugin pipeline\n // (`resolve.conditions`) and the SSR module runner used by\n // `ssrLoadModule('@_linked/server/shapes/LinkedServer')` in\n // commands/start.ts (`ssr.resolve.conditions`).\n //\n // WORKSPACE-GATED: only applied standalone. In monorepo dev the packages\n // ship `src`, and we WANT `development → src` for HMR — so we leave\n // conditions at Vite's defaults there (undefined = untouched), keeping\n // CN dev byte-for-byte unchanged.\n ...(isStandalone\n ? {\n resolve: {\n conditions: ['module', 'node'],\n // Dedupe the context-holding packages so the two `ssrLoadModule` loads\n // (LinkedServer + the app graph) resolve to ONE `server-utils`/`react`\n // instance — otherwise their `AppContext` objects differ and\n // `useAppContext()` returns null. Pairs with `ssr.noExternal` below.\n dedupe: ['@_linked/server-utils', '@_linked/react'],\n },\n }\n : {}),\n // `ssr.external` is a minimal allowlist of\n // npm deps that genuinely can't (or shouldn't) go through Vite's\n // SSR transform. Workspace packages (`@_linked/*`, `lincd-*`) are\n // DELIBERATELY removed so Vite resolves them via each package's\n // `development → ./src/*.ts` conditional export and HMR works on\n // source changes.\n //\n // \"Multiple LINCD\" warnings may resurface during the interim until\n // LINCD eradication completes (accepted).\n ssr: {\n // NOTE: Vite's `ssr.external` only accepts exact package-name strings\n // (not regex). Standalone `@_linked/*` / `lincd-*` are NOT force-listed\n // here — they auto-externalize (or bundle) and resolve via the\n // standalone `import → lib/esm` conditions set below.\n external: [\n 'react',\n 'react-dom',\n 'react-dom/server',\n 'react-router-dom',\n 'scheduler',\n 'express',\n ],\n // Vite 7 auto-externalizes node_modules packages for SSR (loading them\n // via Node → the `import`→`lib/esm` condition), which would bypass the\n // `linked:resolve-workspace-ts` resolver and create a SECOND module\n // instance of each workspace package (breaking the single-`src`-instance\n // invariant — `LinkedStorage` state set on one instance, read on the\n // other → \"No query dispatch configured\"). Force the workspace packages\n // to be BUNDLED so they resolve via each package's `development → src`.\n //\n // WORKSPACE-GATED: only force-bundle when workspaces are actually\n // present (the monorepo / CN + CN's workspace-member clones, where the\n // `@_linked/*` packages have `src` on disk). A STANDALONE app (CLI-\n // created, no workspaces) installs `@_linked/*` from npm as lib-only —\n // those have NO `src`, so bundling them via the `development → src`\n // condition fails (\"Failed to load @_linked/server/shapes/LinkedServer\").\n // Leaving them EXTERNAL lets Node resolve `import → lib/esm`. Single-\n // instance is not a concern standalone (one node_modules copy each) and\n // core's query dispatch is global-backed regardless.\n // STANDALONE: force-bundle the framework packages that hold React context /\n // shared singletons the SSR tree must agree on — `server-utils` (`AppContext`,\n // read by `AppRoot`) and `react`. If left external, LinkedServer's\n // `AppContextProvider` and the app's `AppRoot` (`useAppContext`) can resolve to\n // DIFFERENT module instances → two `AppContext` objects → `useAppContext()` sees\n // no provider (null) → \"Cannot destructure 'isNativeApp'\" and a blank \"SSR timed\n // out\". Bundling makes them one instance in Vite's SSR module graph (matching how\n // workspace mode bundles everything). `fuseki` stays external; `server` is bundled\n // because `start` loads its entry through Vite (`SSR_ENTRY_PACKAGES`). Their native\n // dependencies (e.g. `sharp`) are separate packages and stay external either way.\n //\n // WORKSPACE: bundle ONLY the discovered source workspaces (they resolve to `src/`\n // for HMR). Published framework packages installed under node_modules (lib-only)\n // stay EXTERNAL, so Vite-loaded source and Node-native `import()` share Node's\n // single instance of them. Force-bundling every `@_linked/*` here made Vite\n // evaluate its own `@_linked/core` while `loadStores` (core) loaded a store such\n // as `@_linked/fuseki/shapes/FusekiStore` through native `import()`, which pulled\n // a SECOND Node-loaded core and split the shape registry. Installed packages\n // that depend on a workspace (e.g. published fuseki when core itself is a\n // workspace) are bundled too, so they import the Vite-loaded workspace. The one\n // published exception is `SSR_ENTRY_PACKAGES`, which Vite loads regardless.\n //\n // NOT DEV (a release build of the backend): nothing is force-bundled. The\n // compiled backend is loaded by Node next to the installed\n // `@_linked/server`, so every framework package has to stay a bare import\n // that resolves to that same node_modules copy. `workspaces` is always\n // empty here, and handing that to `ssrNoExternal` used to select the\n // standalone list — which compiled a private `server-utils` into `lib/`,\n // so no app provider was `instanceof` the server's `ShapeProvider` and\n // `LinkedServer` dropped them all (\"exports two generic backend providers\").\n noExternal: isDev ? ssrNoExternal(workspaces, await workspaceDependents(workspaces)) : [],\n // STANDALONE: the SSR module runner (`vite.ssrLoadModule`, used to\n // load LinkedServer + the app graph in commands/start.ts) has its OWN\n // condition list, defaulting to `resolve.conditions`. Set it\n // explicitly so `development` is excluded there too and the lib-only\n // packages resolve via `import → lib/esm`. Omitted (defaults kept) in\n // workspace mode so monorepo SSR still resolves `development → src`.\n ...(isStandalone\n ? {resolve: {conditions: ['module', 'node']}}\n : {}),\n },\n // Client-only, deliberately: these go on the `client` environment, not the\n // top-level `define`, because a top-level `define` is inherited by the SSR\n // environment too.\n //\n // The browser needs them. `@_linked/server-utils`'s `Server.ts` reads\n // `process.env.SITE_ROOT` to target the backend; the browser has no\n // `process`, and Vite (unlike a bundler's EnvironmentPlugin) doesn't\n // auto-inline `process.env.X`, so SITE_ROOT is defined here — always the\n // app's own origin, defaulted to `http://localhost:<port>` (an explicit\n // `SITE_ROOT` env, e.g. from `.env-cmdrc`, still wins). NODE_ENV is a\n // common client guard, so it is defined too.\n //\n // The server must NOT get them, for two reasons:\n // - it reads `process.env` at runtime, so an inlined build-time value is\n // wrong there (a release backend would carry the build machine's\n // SITE_ROOT rather than the deployment's);\n // - worse, every `define` key is a trigger. Vite's `vite:define` plugin\n // runs `esbuild.transform` — without `keepNames` — over any SSR module\n // whose text contains a key. esbuild renames the inner binding of a\n // tsc-emitted decorated class (`let LinkedServer = class LinkedServer`\n // becomes `class LinkedServer2`), and a shape's IRI is built from its\n // class name, so `@_linked/server`'s `LinkedServer` and `LincdAPI`\n // registered as `LinkedServer2` / `LincdAPI2` in dev. Without user keys\n // the SSR environment has none of its own (`keepProcessEnv` is on for\n // it), so nothing server-side is rewritten.\n //\n // Only these SPECIFIC tokens, never a whole-object `process.env`\n // replacement: in a client build Vite already maps any other\n // `process.env.X` to `{}.X` (undefined), which is what client code expects.\n //\n // Apps expose their OWN frontend env vars through the `define` option,\n // which lands here too:\n // createViteConfig({ define: {\n // 'process.env.MY_PUBLIC_KEY': JSON.stringify(process.env.MY_PUBLIC_KEY),\n // }})\n // (only reference PUBLIC vars in client code — a defined secret would be\n // inlined into the browser bundle). An app that puts a top-level `define`\n // in its own config reintroduces both problems for the server; use\n // `environments.client.define` there as well.\n environments: {\n client: {\n define: clientDefine(opts),\n },\n },\n // WORKSPACE mode: exclude the source-shipping workspace packages (@_linked/*,\n // lincd-*) from esbuild's dep pre-bundler. They resolve to `src/` via the\n // `linked:resolve-workspace-ts` plugin; in a workspace-member CLONE they'd\n // otherwise resolve via `node_modules` SYMLINKS and esbuild fails on their\n // subpath `exports` (\"No known conditions for ./shapes/SHACL …\").\n // STANDALONE mode: exclude the published `@_linked/*` / `lincd-*` deps from\n // esbuild's pre-bundler so the browser's native ESM graph loads ONE copy of\n // `@_linked/core` (no per-subpath duplication → stable class names → shape URIs\n // match the backend — see `linkedDeps` above). These packages are ESM with no\n // bare CJS runtime deps (e.g. `classnames` is inlined in `@_linked/react`), so\n // serving them as native ESM needs no interop shim.\n // An excluded package is not crawled, so its OWN third-party imports (Radix,\n // vaul, js-cookie…) are listed in `optimizeDeps.include` by the\n // `linked:client-dep-includes` plugin above, once the app's excludes are final.\n ...(workspaces.length > 0\n ? {optimizeDeps: {exclude: workspaces.map((w) => w.name)}}\n : isStandalone && linkedDeps.length > 0\n ? {optimizeDeps: {exclude: linkedDeps}}\n : {}),\n };\n\n // Tailwind plugin (only if explicitly enabled — adds a heavy plugin).\n if (opts.cssMode === 'tailwind') {\n // Try ESM dynamic import first (works when @tailwindcss/vite is\n // installed in the app or hoisted). Surface a CLEAR warning when\n // it's not — the app needs the dep for theme variables to load.\n try {\n const tailwind: any = await import('@tailwindcss/vite' as any);\n const tailwindPlugin = tailwind.default ?? tailwind;\n (config.plugins as Plugin[]).push(tailwindPlugin());\n } catch (err) {\n console.warn(\n '[createViteConfig] cssMode=tailwind but @tailwindcss/vite ' +\n 'could not be loaded. Theme variables won\\'t apply at runtime. ' +\n 'Add `@tailwindcss/vite` to your app\\'s package.json.',\n );\n }\n }\n\n return config;\n });\n}\n"]}
|