@trackunit/iris-app-sdk-vite 1.1.26-alpha-288640a1f26.0 → 1.1.26
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 +8 -0
- package/package.json +10 -10
- package/src/executors/build/executor.js +2 -2
- package/src/executors/serve/executor.js +2 -2
- package/src/executors/utils/defaultViteConfig.js +5 -7
- package/src/executors/utils/getTrackunitIrisAppVitePlugins.js +5 -9
- package/src/executors/utils/loadCssInjectedByJsPlugin.js +0 -142
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/iris-app-sdk-vite",
|
|
3
|
-
"version": "1.1.26
|
|
3
|
+
"version": "1.1.26",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"repository": "https://github.com/Trackunit/manager",
|
|
6
6
|
"executors": "./executors.json",
|
|
@@ -10,19 +10,19 @@
|
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"rxjs": "7.8.1",
|
|
12
12
|
"win-ca": "^3.5.1",
|
|
13
|
-
"@trackunit/iris-app-build-utilities": "2.1.25
|
|
14
|
-
"@trackunit/iris-app-api": "2.1.24
|
|
13
|
+
"@trackunit/iris-app-build-utilities": "2.1.25",
|
|
14
|
+
"@trackunit/iris-app-api": "2.1.24",
|
|
15
15
|
"tslib": "^2.6.2",
|
|
16
|
-
"vite": "
|
|
17
|
-
"@module-federation/vite": "1.
|
|
18
|
-
"@nx/vite": "
|
|
16
|
+
"vite": "7.3.1",
|
|
17
|
+
"@module-federation/vite": "1.11.0",
|
|
18
|
+
"@nx/vite": "22.7.5",
|
|
19
19
|
"vite-plugin-checker": "^0.12.0",
|
|
20
|
-
"vite-plugin-css-injected-by-js": "5.
|
|
20
|
+
"vite-plugin-css-injected-by-js": "^3.5.2",
|
|
21
21
|
"rollup-plugin-visualizer": "5.12.0",
|
|
22
22
|
"@tailwindcss/postcss": "^4.1.18",
|
|
23
|
-
"@vitejs/plugin-react-swc": "^4.3
|
|
24
|
-
"@nx/devkit": "
|
|
25
|
-
"@trackunit/iris-app": "2.2.26
|
|
23
|
+
"@vitejs/plugin-react-swc": "^4.2.3",
|
|
24
|
+
"@nx/devkit": "22.7.5",
|
|
25
|
+
"@trackunit/iris-app": "2.2.26",
|
|
26
26
|
"cross-keychain": "^1.1.0",
|
|
27
27
|
"jwt-decode": "^3.1.2"
|
|
28
28
|
},
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = buildExecutor;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
5
|
+
const rxjs_for_await_1 = require("@nx/devkit/src/utils/rxjs-for-await");
|
|
6
6
|
const iris_app_build_utilities_1 = require("@trackunit/iris-app-build-utilities");
|
|
7
7
|
const fs_1 = require("fs");
|
|
8
8
|
const path_1 = require("path");
|
|
@@ -101,6 +101,6 @@ async function* buildExecutor(options, context) {
|
|
|
101
101
|
console.error(`\n ❌ Iris App build failed\n`);
|
|
102
102
|
}
|
|
103
103
|
}));
|
|
104
|
-
return yield* (0,
|
|
104
|
+
return yield* (0, rxjs_for_await_1.eachValueFrom)(observable);
|
|
105
105
|
}
|
|
106
106
|
//# sourceMappingURL=executor.js.map
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = serveExecutor;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
5
|
+
const rxjs_for_await_1 = require("@nx/devkit/src/utils/rxjs-for-await");
|
|
6
6
|
const iris_app_1 = require("@trackunit/iris-app");
|
|
7
7
|
const iris_app_build_utilities_1 = require("@trackunit/iris-app-build-utilities");
|
|
8
8
|
const fs_1 = require("fs");
|
|
@@ -118,7 +118,7 @@ async function* serveExecutor(options, context) {
|
|
|
118
118
|
})), op.finalize(() => {
|
|
119
119
|
serversideResult.cleanup();
|
|
120
120
|
}));
|
|
121
|
-
return yield* (0,
|
|
121
|
+
return yield* (0, rxjs_for_await_1.eachValueFrom)(observable);
|
|
122
122
|
}
|
|
123
123
|
catch (error) {
|
|
124
124
|
serversideResult.cleanup();
|
|
@@ -55,10 +55,9 @@ const getDefaultViteConfig = async (mode, nxRootDir, appDir, _irisAppManifest, c
|
|
|
55
55
|
optimizeDeps: {
|
|
56
56
|
// Force include common dependencies to speed up dev server startup
|
|
57
57
|
include: ["react", "react-dom", "react/jsx-runtime"],
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
},
|
|
58
|
+
// Use esbuild for faster dependency scanning
|
|
59
|
+
esbuildOptions: {
|
|
60
|
+
target: "esnext",
|
|
62
61
|
},
|
|
63
62
|
},
|
|
64
63
|
build: {
|
|
@@ -66,9 +65,8 @@ const getDefaultViteConfig = async (mode, nxRootDir, appDir, _irisAppManifest, c
|
|
|
66
65
|
emptyOutDir: true,
|
|
67
66
|
// Target modern browsers - faster builds, no legacy transforms
|
|
68
67
|
target: "esnext",
|
|
69
|
-
//
|
|
70
|
-
|
|
71
|
-
minify: "oxc",
|
|
68
|
+
// Use esbuild for minification (MUCH faster than terser)
|
|
69
|
+
minify: "esbuild",
|
|
72
70
|
// Disable source maps in production for faster builds
|
|
73
71
|
sourcemap: false,
|
|
74
72
|
// Increase chunk size warning limit
|
|
@@ -10,10 +10,10 @@ const fs = tslib_1.__importStar(require("node:fs"));
|
|
|
10
10
|
const path = tslib_1.__importStar(require("node:path"));
|
|
11
11
|
const vite_2 = require("vite");
|
|
12
12
|
const vite_plugin_checker_1 = tslib_1.__importDefault(require("vite-plugin-checker"));
|
|
13
|
-
const
|
|
13
|
+
const vite_plugin_css_injected_by_js_1 = tslib_1.__importDefault(require("vite-plugin-css-injected-by-js"));
|
|
14
14
|
const devServerTiming_1 = require("./devServerTiming");
|
|
15
|
+
const customFieldsDegradedReminderPlugin_1 = require("./customFieldsDegradedReminderPlugin");
|
|
15
16
|
const extensionLoaderCache_1 = require("./extensionLoaderCache");
|
|
16
|
-
const loadCssInjectedByJsPlugin_1 = require("./loadCssInjectedByJsPlugin");
|
|
17
17
|
const manifestCache_1 = require("./manifestCache");
|
|
18
18
|
const manifestLoader_1 = require("./manifestLoader");
|
|
19
19
|
// Only import enableTsConfigPath statically - other utilities are dynamically imported
|
|
@@ -148,9 +148,6 @@ async function getTrackunitIrisAppVitePlugins(options) {
|
|
|
148
148
|
(0, devServerTiming_1.logEvent)("plugin construction: started");
|
|
149
149
|
const resolvedAppDir = path.resolve(options.appDir);
|
|
150
150
|
const workspaceRoot = options.workspaceRoot ?? path.resolve(options.appDir, "../..");
|
|
151
|
-
// ESM-only since v5 (Vite 8). Load via file URL — Nx CJS executor hooks cannot
|
|
152
|
-
// resolve the package's import-only exports map.
|
|
153
|
-
const cssInjectedByJsPlugin = await (0, loadCssInjectedByJsPlugin_1.loadCssInjectedByJsPlugin)(workspaceRoot);
|
|
154
151
|
// Load manifest upfront for federation config
|
|
155
152
|
const initialManifest = (0, manifestLoader_1.loadManifest)(workspaceRoot, resolvedAppDir);
|
|
156
153
|
// Get build utilities (tsconfig paths now registered via loadManifest)
|
|
@@ -321,9 +318,8 @@ async function getTrackunitIrisAppVitePlugins(options) {
|
|
|
321
318
|
},
|
|
322
319
|
// Production build optimization
|
|
323
320
|
build: {
|
|
324
|
-
//
|
|
325
|
-
|
|
326
|
-
minify: "oxc",
|
|
321
|
+
// Use esbuild for fast minification (Vite's default)
|
|
322
|
+
minify: "esbuild",
|
|
327
323
|
// CSS code splitting is required for relativeCSSInjection to work
|
|
328
324
|
// (cssInjectedByJsPlugin enforces cssCodeSplit: true when relativeCSSInjection is enabled)
|
|
329
325
|
// Each chunk's CSS is injected when that chunk loads - ideal for Module Federation
|
|
@@ -644,7 +640,7 @@ async function getTrackunitIrisAppVitePlugins(options) {
|
|
|
644
640
|
// topExecutionPriority ensures CSS is injected before other code runs,
|
|
645
641
|
// relativeCSSInjection: true ensures CSS is injected per chunk (requires cssCodeSplit: true)
|
|
646
642
|
// This is ideal for Module Federation - CSS loads with each remote chunk
|
|
647
|
-
|
|
643
|
+
(0, vite_plugin_css_injected_by_js_1.default)({
|
|
648
644
|
topExecutionPriority: true,
|
|
649
645
|
relativeCSSInjection: true,
|
|
650
646
|
}),
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.defaultSearchRoots = void 0;
|
|
4
|
-
exports.resolveCssInjectedByJsPluginEntry = resolveCssInjectedByJsPluginEntry;
|
|
5
|
-
exports.loadCssInjectedByJsPlugin = loadCssInjectedByJsPlugin;
|
|
6
|
-
const tslib_1 = require("tslib");
|
|
7
|
-
/**
|
|
8
|
-
* Indirect loader for `vite-plugin-css-injected-by-js` (ESM-only since v5).
|
|
9
|
-
*
|
|
10
|
-
* ## Why this file exists
|
|
11
|
-
*
|
|
12
|
-
* 1. Iris remotes must inject CSS into the JS bundle. The host iframe's CSP
|
|
13
|
-
* blocks external stylesheets, so a separate `.css` file leaves the app
|
|
14
|
-
* unstyled. Vite 8/Rolldown stopped emitting CSS the way Rollup did, so we
|
|
15
|
-
* need this plugin (v5+) to inline it.
|
|
16
|
-
* 2. The plugin only publishes an `import` export condition. A plain
|
|
17
|
-
* `import … from "vite-plugin-css-injected-by-js"` (or a static `require`)
|
|
18
|
-
* fails under Nx's CJS executor hooks, which rewrite dynamic `import()` into
|
|
19
|
-
* `require()` and hit `ERR_PACKAGE_PATH_NOT_EXPORTED`.
|
|
20
|
-
*
|
|
21
|
-
* This module therefore resolves the package's ESM entry from its manifest and
|
|
22
|
-
* loads it via an indirect `new Function("return import(...)")` so Node really
|
|
23
|
-
* does an ESM import.
|
|
24
|
-
*
|
|
25
|
-
* ## When to delete this file
|
|
26
|
-
*
|
|
27
|
-
* Replace the call site in `getTrackunitIrisAppVitePlugins.ts` with a normal
|
|
28
|
-
* `import cssInjectedByJsPlugin from "vite-plugin-css-injected-by-js"` and
|
|
29
|
-
* delete this module once **all** of the following are true:
|
|
30
|
-
*
|
|
31
|
-
* - Nx executors for this package run as native ESM (no CJS rewrite of
|
|
32
|
-
* `import()`), **or** the plugin ships a CJS/`require` export again; and
|
|
33
|
-
* - A plain static import of the plugin works inside
|
|
34
|
-
* `yarn nx build <any-iris-app>` (Iris apps still load with styles).
|
|
35
|
-
*
|
|
36
|
-
* Until then, do not "simplify" this back to a static import — that is the
|
|
37
|
-
* regression that left Iris apps blank after the Vite 8 upgrade.
|
|
38
|
-
*/
|
|
39
|
-
const fs = tslib_1.__importStar(require("node:fs"));
|
|
40
|
-
const path = tslib_1.__importStar(require("node:path"));
|
|
41
|
-
const node_url_1 = require("node:url");
|
|
42
|
-
const PACKAGE_NAME = "vite-plugin-css-injected-by-js";
|
|
43
|
-
const PREFERRED_CONDITIONS = ["import", "module"];
|
|
44
|
-
// "require" would resolve to a CJS build that the ESM import below cannot use.
|
|
45
|
-
const IGNORED_CONDITIONS = new Set(["require", "types"]);
|
|
46
|
-
const isRecord = (value) => typeof value === "object" && value !== null;
|
|
47
|
-
/**
|
|
48
|
-
* Find the installed package directory by walking node_modules upwards.
|
|
49
|
-
*
|
|
50
|
-
* require.resolve() cannot be used here: the package only publishes an
|
|
51
|
-
* "import" export condition, so CJS resolution fails with
|
|
52
|
-
* ERR_PACKAGE_PATH_NOT_EXPORTED.
|
|
53
|
-
*/
|
|
54
|
-
function findPackageDirFrom(startDir) {
|
|
55
|
-
let dir = path.resolve(startDir);
|
|
56
|
-
for (;;) {
|
|
57
|
-
const candidate = path.join(dir, "node_modules", PACKAGE_NAME);
|
|
58
|
-
if (fs.existsSync(path.join(candidate, "package.json"))) {
|
|
59
|
-
return candidate;
|
|
60
|
-
}
|
|
61
|
-
const parent = path.dirname(dir);
|
|
62
|
-
if (parent === dir) {
|
|
63
|
-
return undefined;
|
|
64
|
-
}
|
|
65
|
-
dir = parent;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Search this module's own tree before the consumer's workspace root.
|
|
70
|
-
*
|
|
71
|
-
* Under isolated node_modules layouts (pnpm, Yarn's `nodeLinker: pnpm`) this
|
|
72
|
-
* package is installed beside the SDK and never appears at the consumer root,
|
|
73
|
-
* so a root-only walk would fail for published consumers.
|
|
74
|
-
*/
|
|
75
|
-
const defaultSearchRoots = (workspaceRoot) => [__dirname, workspaceRoot];
|
|
76
|
-
exports.defaultSearchRoots = defaultSearchRoots;
|
|
77
|
-
function findPackageDir(searchRoots) {
|
|
78
|
-
for (const root of searchRoots) {
|
|
79
|
-
const found = findPackageDirFrom(root);
|
|
80
|
-
if (found) {
|
|
81
|
-
return found;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
return undefined;
|
|
85
|
-
}
|
|
86
|
-
/** Walk nested export conditions, preferring the ESM ones. */
|
|
87
|
-
function pickEsmEntry(target) {
|
|
88
|
-
if (typeof target === "string") {
|
|
89
|
-
return target;
|
|
90
|
-
}
|
|
91
|
-
if (!isRecord(target)) {
|
|
92
|
-
return undefined;
|
|
93
|
-
}
|
|
94
|
-
const remaining = Object.keys(target).filter(condition => !PREFERRED_CONDITIONS.includes(condition) && !IGNORED_CONDITIONS.has(condition));
|
|
95
|
-
for (const condition of [...PREFERRED_CONDITIONS, ...remaining]) {
|
|
96
|
-
const entry = pickEsmEntry(target[condition]);
|
|
97
|
-
if (entry) {
|
|
98
|
-
return entry;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return undefined;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Resolve the absolute ESM entry point of the installed package.
|
|
105
|
-
*
|
|
106
|
-
* The entry is read from the package manifest so that a renamed or relocated
|
|
107
|
-
* published entry point does not break the build.
|
|
108
|
-
*/
|
|
109
|
-
function resolveCssInjectedByJsPluginEntry(workspaceRoot, searchRoots = (0, exports.defaultSearchRoots)(workspaceRoot)) {
|
|
110
|
-
const packageDir = findPackageDir(searchRoots);
|
|
111
|
-
if (!packageDir) {
|
|
112
|
-
throw new Error(`${PACKAGE_NAME} not found in node_modules under ${searchRoots.join(", ")}. Run yarn install.`);
|
|
113
|
-
}
|
|
114
|
-
const manifest = JSON.parse(fs.readFileSync(path.join(packageDir, "package.json"), "utf-8"));
|
|
115
|
-
if (!isRecord(manifest)) {
|
|
116
|
-
throw new Error(`${PACKAGE_NAME} has an unreadable package.json in ${packageDir}.`);
|
|
117
|
-
}
|
|
118
|
-
// "exports" is either a bare entry or a subpath map holding the root entry.
|
|
119
|
-
const exportsField = manifest.exports;
|
|
120
|
-
const rootExport = isRecord(exportsField) ? exportsField["."] : exportsField;
|
|
121
|
-
const entry = pickEsmEntry(rootExport) ?? pickEsmEntry(manifest.module) ?? pickEsmEntry(manifest.main) ?? "dist/index.js";
|
|
122
|
-
const entryPath = path.join(packageDir, entry);
|
|
123
|
-
if (!fs.existsSync(entryPath)) {
|
|
124
|
-
throw new Error(`${PACKAGE_NAME} entry point not found at ${entryPath}. Run yarn install.`);
|
|
125
|
-
}
|
|
126
|
-
return entryPath;
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Load the CSS-injection plugin factory. See the file-level comment for why
|
|
130
|
-
* this cannot be a static import, and what has to change before it can be.
|
|
131
|
-
*/
|
|
132
|
-
async function loadCssInjectedByJsPlugin(workspaceRoot) {
|
|
133
|
-
const entryPath = resolveCssInjectedByJsPluginEntry(workspaceRoot);
|
|
134
|
-
const importEsm = new Function("specifier", "return import(specifier)");
|
|
135
|
-
const mod = await importEsm((0, node_url_1.pathToFileURL)(entryPath).href);
|
|
136
|
-
const factory = isRecord(mod) ? mod.default : undefined;
|
|
137
|
-
if (typeof factory !== "function") {
|
|
138
|
-
throw new Error(`${PACKAGE_NAME} at ${entryPath} did not export a plugin factory as its default export.`);
|
|
139
|
-
}
|
|
140
|
-
return options => factory(options);
|
|
141
|
-
}
|
|
142
|
-
//# sourceMappingURL=loadCssInjectedByJsPlugin.js.map
|