@trackunit/iris-app-sdk-vite 1.11.70 → 1.12.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 +32 -0
- package/README.md +16 -0
- package/package.json +4 -4
- package/src/executors/utils/defaultViteConfig.js +9 -0
- package/src/executors/utils/duplicateTrackunitPackagesPlugin/duplicateTrackunitPackagesPlugin.js +87 -0
- package/src/executors/utils/findDuplicateTrackunitPackages/findDuplicateTrackunitPackages.js +89 -0
- package/src/executors/utils/getTrackunitIrisAppVitePlugins.js +9 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
|
+
## 1.12.2 (2026-11-19)
|
|
2
|
+
|
|
3
|
+
### 🧱 Updated Dependencies
|
|
4
|
+
|
|
5
|
+
- Updated iris-app to 2.16.39
|
|
6
|
+
|
|
7
|
+
## 1.12.1 (2026-11-19)
|
|
8
|
+
|
|
9
|
+
### 🧱 Updated Dependencies
|
|
10
|
+
|
|
11
|
+
- Updated iris-app to 2.16.38
|
|
12
|
+
|
|
13
|
+
## 1.12.0 (2026-11-19)
|
|
14
|
+
|
|
15
|
+
### 🚀 Features
|
|
16
|
+
|
|
17
|
+
- **iris-app-sdk-vite:** report duplicated @trackunit packages in serve and build [GLU-2856] ([#27308](https://github.com/Trackunit/manager/pull/27308))
|
|
18
|
+
|
|
19
|
+
### 🩹 Fixes
|
|
20
|
+
|
|
21
|
+
- **versioning:** publish internal @trackunit dependencies with caret ranges [GLU-2856] ([#27302](https://github.com/Trackunit/manager/pull/27302))
|
|
22
|
+
|
|
23
|
+
### 🧱 Updated Dependencies
|
|
24
|
+
|
|
25
|
+
- Updated iris-app-build-utilities to 3.0.41
|
|
26
|
+
- Updated iris-app-api to 2.13.29
|
|
27
|
+
- Updated iris-app to 2.16.37
|
|
28
|
+
|
|
29
|
+
### ❤️ Thank You
|
|
30
|
+
|
|
31
|
+
- Brian Christensen @bchTrackunit
|
|
32
|
+
|
|
1
33
|
## 1.11.70 (2026-11-19)
|
|
2
34
|
|
|
3
35
|
### 🧱 Updated Dependencies
|
package/README.md
CHANGED
|
@@ -228,6 +228,22 @@ Things to know:
|
|
|
228
228
|
|
|
229
229
|
These warnings during development are typically harmless and occur during Vite's dependency pre-bundling. If your app loads correctly, they can be ignored.
|
|
230
230
|
|
|
231
|
+
**"Multiple copies of @trackunit packages are bundled"**
|
|
232
|
+
|
|
233
|
+
Your app mixes `@trackunit/*` packages from different releases, so the package manager installed some of them more than once. Upgrade them together so each package is installed once (install `@trackunit/migrations` as a dev dependency first if you don't have it; the report prints the exact command):
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
npx nx g @trackunit/migrations:migrate
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
The report lists every duplicated package with each copy's version and location. `serve` only warns. `build` fails when the duplicate is a package that must exist once per app, because the app then breaks at runtime:
|
|
240
|
+
|
|
241
|
+
- `@trackunit/react-core-contexts-api`: providers and hooks from different copies do not see each other (for example `useCurrentUser must be used within the CurrentUserProvider`).
|
|
242
|
+
- `@trackunit/iris-app-runtime-core`: each copy opens its own connection to the Manager host.
|
|
243
|
+
- `@trackunit/i18n-library-translation`: translations registered in one copy are missing in the other.
|
|
244
|
+
|
|
245
|
+
Other duplicates only make the bundle larger, so `build` only warns about them.
|
|
246
|
+
|
|
231
247
|
## Trackunit
|
|
232
248
|
|
|
233
249
|
This package was developed by Trackunit ApS.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/iris-app-sdk-vite",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.2",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"repository": "https://github.com/Trackunit/manager",
|
|
6
6
|
"executors": "./executors.json",
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"rxjs": "7.8.2",
|
|
12
12
|
"win-ca": "^3.5.1",
|
|
13
13
|
"node-forge": "^1.4.3",
|
|
14
|
-
"@trackunit/iris-app-build-utilities": "3.0.
|
|
15
|
-
"@trackunit/iris-app-api": "2.13.
|
|
14
|
+
"@trackunit/iris-app-build-utilities": "^3.0.41",
|
|
15
|
+
"@trackunit/iris-app-api": "^2.13.29",
|
|
16
16
|
"tslib": "^2.6.2",
|
|
17
17
|
"typescript": "6.0.2",
|
|
18
18
|
"vite": "8.3.4",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"@tailwindcss/postcss": "^4.1.18",
|
|
25
25
|
"@vitejs/plugin-react-swc": "^4.3.3",
|
|
26
26
|
"@nx/devkit": "23.3.0",
|
|
27
|
-
"@trackunit/iris-app": "2.16.
|
|
27
|
+
"@trackunit/iris-app": "^2.16.39",
|
|
28
28
|
"cross-keychain": "^1.1.0",
|
|
29
29
|
"jwt-decode": "^3.1.2"
|
|
30
30
|
},
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getDefaultViteConfig = void 0;
|
|
4
|
+
const iris_app_build_utilities_1 = require("@trackunit/iris-app-build-utilities");
|
|
4
5
|
const svgSpriteInline_1 = require("../../svgSpriteInline");
|
|
6
|
+
const duplicateTrackunitPackagesPlugin_1 = require("./duplicateTrackunitPackagesPlugin/duplicateTrackunitPackagesPlugin");
|
|
5
7
|
const getTrackunitIrisAppVitePlugins_1 = require("./getTrackunitIrisAppVitePlugins");
|
|
6
8
|
const workspaceTsconfigPaths_1 = require("./workspaceTsconfigPaths");
|
|
7
9
|
const VIRTUAL_ENTRY_ID = "virtual:iris-app-entry";
|
|
@@ -67,6 +69,13 @@ const getDefaultViteConfig = async (mode, nxRootDir, appDir, irisAppManifest, co
|
|
|
67
69
|
// pre-bundling would move the script away from the binary and break the lookup in dev.
|
|
68
70
|
exclude: ["clipper2-wasm"],
|
|
69
71
|
rolldownOptions: {
|
|
72
|
+
// The build fails on these duplicates; serve only warns so development is never blocked.
|
|
73
|
+
plugins: [
|
|
74
|
+
(0, duplicateTrackunitPackagesPlugin_1.createDuplicateTrackunitPackagesPlugin)({
|
|
75
|
+
failOnSingleInstanceDuplicates: false,
|
|
76
|
+
suggest: (0, iris_app_build_utilities_1.createMigrateSuggestion)(nxRootDir),
|
|
77
|
+
}),
|
|
78
|
+
],
|
|
70
79
|
transform: {
|
|
71
80
|
target: "esnext",
|
|
72
81
|
// Pre-bundled React picks its runtime from this define. Vite also hashes it into the
|
package/src/executors/utils/duplicateTrackunitPackagesPlugin/duplicateTrackunitPackagesPlugin.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createDuplicateTrackunitPackagesPlugin = exports.formatDuplicatePackagesReport = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const iris_app_build_utilities_1 = require("@trackunit/iris-app-build-utilities");
|
|
6
|
+
const fs = tslib_1.__importStar(require("node:fs"));
|
|
7
|
+
const path = tslib_1.__importStar(require("node:path"));
|
|
8
|
+
const findDuplicateTrackunitPackages_1 = require("../findDuplicateTrackunitPackages/findDuplicateTrackunitPackages");
|
|
9
|
+
/**
|
|
10
|
+
* Packages holding module-level state that must exist once per app. A second copy does not
|
|
11
|
+
* just cost bundle size: code reaching the other copy sees empty state and fails at runtime.
|
|
12
|
+
*/
|
|
13
|
+
const SINGLE_INSTANCE_PACKAGES = {
|
|
14
|
+
"@trackunit/react-core-contexts-api": 'each copy creates its own React contexts, so providers and hooks from different copies do not see each other (e.g. "useCurrentUser must be used within the CurrentUserProvider")',
|
|
15
|
+
"@trackunit/iris-app-runtime-core": "each copy opens its own connection to the Manager host",
|
|
16
|
+
"@trackunit/i18n-library-translation": "each copy keeps its own translation registry, so translations registered in one copy are missing in the other",
|
|
17
|
+
};
|
|
18
|
+
/** Bundlers report real paths, so a symlinked cwd (e.g. macOS `/var` -> `/private/var`) must be resolved too. */
|
|
19
|
+
const toRealPath = (dir) => {
|
|
20
|
+
try {
|
|
21
|
+
return fs.realpathSync(dir);
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return dir;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
const describeCopies = ({ name, copies }, cwd) => ` ${name}: ${copies.map(copy => `${copy.version} (${path.relative(cwd, copy.packageDir)})`).join(", ")}`;
|
|
28
|
+
/**
|
|
29
|
+
* Phrases one report for every duplicated package, listing why single-instance packages break.
|
|
30
|
+
*
|
|
31
|
+
* @param duplicates - the duplicated packages, as returned by `findDuplicateTrackunitPackages`
|
|
32
|
+
* @param suggest - returns the command that aligns every `@trackunit/*` version
|
|
33
|
+
* @param cwd - directory the package locations are made relative to
|
|
34
|
+
* @returns {string} the multi-line report
|
|
35
|
+
*/
|
|
36
|
+
const formatDuplicatePackagesReport = (duplicates, suggest, cwd) => {
|
|
37
|
+
const singleInstanceReasons = duplicates.flatMap(({ name }) => {
|
|
38
|
+
const reason = SINGLE_INSTANCE_PACKAGES[name];
|
|
39
|
+
return reason === undefined ? [] : [`${name} must be installed once: ${reason}.`];
|
|
40
|
+
});
|
|
41
|
+
return [
|
|
42
|
+
"Multiple copies of @trackunit packages are bundled:",
|
|
43
|
+
...duplicates.map(duplicate => describeCopies(duplicate, cwd)),
|
|
44
|
+
...singleInstanceReasons,
|
|
45
|
+
`Align your @trackunit/* versions so each package is installed once. Run: ${suggest()}`,
|
|
46
|
+
].join("\n");
|
|
47
|
+
};
|
|
48
|
+
exports.formatDuplicatePackagesReport = formatDuplicatePackagesReport;
|
|
49
|
+
/**
|
|
50
|
+
* Vite/Rolldown plugin that inspects the finished bundle for `@trackunit/*` packages bundled from
|
|
51
|
+
* more than one install location, which happens when an app mixes packages from different releases.
|
|
52
|
+
*
|
|
53
|
+
* Registered in the build to fail before a broken app is deployed, and in dependency pre-bundling
|
|
54
|
+
* during serve to warn while developing. A report already printed is not repeated, since serve
|
|
55
|
+
* re-optimizes whenever it discovers a new dependency.
|
|
56
|
+
*
|
|
57
|
+
* @param options - whether single-instance duplicates fail, and how to phrase the fix
|
|
58
|
+
* @param options.failOnSingleInstanceDuplicates - fail when a package that must exist once is duplicated
|
|
59
|
+
* @param options.suggest - returns the command that aligns every `@trackunit/*` version
|
|
60
|
+
* @param options.cwd - directory the reported package locations are made relative to
|
|
61
|
+
* @returns {DuplicatePackagesPlugin} the plugin
|
|
62
|
+
*/
|
|
63
|
+
const createDuplicateTrackunitPackagesPlugin = ({ failOnSingleInstanceDuplicates, suggest, cwd = process.cwd(), }) => {
|
|
64
|
+
let lastReport;
|
|
65
|
+
const reportRoot = toRealPath(cwd);
|
|
66
|
+
return {
|
|
67
|
+
name: "trackunit-iris-app-duplicate-packages",
|
|
68
|
+
generateBundle(_outputOptions, bundle) {
|
|
69
|
+
const moduleIds = Object.values(bundle).flatMap(entry => (entry.type === "chunk" ? (entry.moduleIds ?? []) : []));
|
|
70
|
+
const duplicates = (0, findDuplicateTrackunitPackages_1.findDuplicateTrackunitPackages)(moduleIds);
|
|
71
|
+
if (duplicates.length === 0) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const report = (0, exports.formatDuplicatePackagesReport)(duplicates, suggest, reportRoot);
|
|
75
|
+
const hasSingleInstanceDuplicate = duplicates.some(({ name }) => SINGLE_INSTANCE_PACKAGES[name] !== undefined);
|
|
76
|
+
if (failOnSingleInstanceDuplicates && hasSingleInstanceDuplicate) {
|
|
77
|
+
this.error(report);
|
|
78
|
+
}
|
|
79
|
+
if (report !== lastReport) {
|
|
80
|
+
lastReport = report;
|
|
81
|
+
(0, iris_app_build_utilities_1.logWarning)(`⚠️ ${report}`);
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
exports.createDuplicateTrackunitPackagesPlugin = createDuplicateTrackunitPackagesPlugin;
|
|
87
|
+
//# sourceMappingURL=duplicateTrackunitPackagesPlugin.js.map
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findDuplicateTrackunitPackages = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const fs = tslib_1.__importStar(require("node:fs"));
|
|
6
|
+
const path = tslib_1.__importStar(require("node:path"));
|
|
7
|
+
const TRACKUNIT_SCOPE = "@trackunit/";
|
|
8
|
+
const readNamedPackageJson = (dir) => {
|
|
9
|
+
try {
|
|
10
|
+
const packageJson = JSON.parse(fs.readFileSync(path.join(dir, "package.json"), "utf-8"));
|
|
11
|
+
if (typeof packageJson === "object" &&
|
|
12
|
+
packageJson !== null &&
|
|
13
|
+
"name" in packageJson &&
|
|
14
|
+
typeof packageJson.name === "string" &&
|
|
15
|
+
"version" in packageJson &&
|
|
16
|
+
typeof packageJson.version === "string") {
|
|
17
|
+
return { name: packageJson.name, version: packageJson.version, packageDir: dir };
|
|
18
|
+
}
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Bundler module ids carry virtual prefixes (`\0`) and query suffixes (`?commonjs-proxy`);
|
|
27
|
+
* only real files on disk can be attributed to an installed package. A virtual id is never
|
|
28
|
+
* an absolute path, so it is dropped along with relative ids.
|
|
29
|
+
*/
|
|
30
|
+
const toFilePath = (moduleId) => {
|
|
31
|
+
const filePath = moduleId.split("?")[0] ?? moduleId;
|
|
32
|
+
return path.isAbsolute(filePath) ? filePath : undefined;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Finds `@trackunit/*` packages that are bundled from more than one install location.
|
|
36
|
+
*
|
|
37
|
+
* Each module is attributed to the nearest `package.json` that has a name and version,
|
|
38
|
+
* which works for hoisted npm installs as well as pnpm and Yarn's isolated layouts.
|
|
39
|
+
* Nested `package.json` files without a name (e.g. `{ "type": "module" }`) are skipped.
|
|
40
|
+
*
|
|
41
|
+
* @param moduleIds - absolute module ids of everything that ended up in the bundle
|
|
42
|
+
* @returns {Array<DuplicatePackage>} one entry per duplicated package, sorted by name with its copies sorted by location; empty when every package has a single copy
|
|
43
|
+
*/
|
|
44
|
+
const findDuplicateTrackunitPackages = (moduleIds) => {
|
|
45
|
+
const owningPackageByDir = new Map();
|
|
46
|
+
const findOwningPackage = (fileDir) => {
|
|
47
|
+
const visited = [];
|
|
48
|
+
let dir = fileDir;
|
|
49
|
+
let owner;
|
|
50
|
+
for (;;) {
|
|
51
|
+
if (owningPackageByDir.has(dir)) {
|
|
52
|
+
owner = owningPackageByDir.get(dir);
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
visited.push(dir);
|
|
56
|
+
owner = readNamedPackageJson(dir);
|
|
57
|
+
if (owner !== undefined) {
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
const parent = path.dirname(dir);
|
|
61
|
+
if (parent === dir) {
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
dir = parent;
|
|
65
|
+
}
|
|
66
|
+
visited.forEach(visitedDir => owningPackageByDir.set(visitedDir, owner));
|
|
67
|
+
return owner;
|
|
68
|
+
};
|
|
69
|
+
const copiesByName = new Map();
|
|
70
|
+
for (const moduleId of moduleIds) {
|
|
71
|
+
const filePath = toFilePath(moduleId);
|
|
72
|
+
const owner = filePath === undefined ? undefined : findOwningPackage(path.dirname(filePath));
|
|
73
|
+
if (owner === undefined || !owner.name.startsWith(TRACKUNIT_SCOPE)) {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
const copies = copiesByName.get(owner.name) ?? new Map();
|
|
77
|
+
copies.set(owner.packageDir, { version: owner.version, packageDir: owner.packageDir });
|
|
78
|
+
copiesByName.set(owner.name, copies);
|
|
79
|
+
}
|
|
80
|
+
return [...copiesByName.entries()]
|
|
81
|
+
.filter(([, copies]) => copies.size > 1)
|
|
82
|
+
.map(([name, copies]) => ({
|
|
83
|
+
name,
|
|
84
|
+
copies: [...copies.values()].toSorted((a, b) => a.packageDir.localeCompare(b.packageDir)),
|
|
85
|
+
}))
|
|
86
|
+
.toSorted((a, b) => a.name.localeCompare(b.name));
|
|
87
|
+
};
|
|
88
|
+
exports.findDuplicateTrackunitPackages = findDuplicateTrackunitPackages;
|
|
89
|
+
//# sourceMappingURL=findDuplicateTrackunitPackages.js.map
|
|
@@ -11,6 +11,7 @@ const vite_2 = require("vite");
|
|
|
11
11
|
const vite_plugin_checker_1 = tslib_1.__importDefault(require("vite-plugin-checker"));
|
|
12
12
|
const customFieldsDegradedReminderPlugin_1 = require("./customFieldsDegradedReminderPlugin");
|
|
13
13
|
const devServerTiming_1 = require("./devServerTiming");
|
|
14
|
+
const duplicateTrackunitPackagesPlugin_1 = require("./duplicateTrackunitPackagesPlugin/duplicateTrackunitPackagesPlugin");
|
|
14
15
|
const extensionLoaderCache_1 = require("./extensionLoaderCache");
|
|
15
16
|
const loadCssInjectedByJsPlugin_1 = require("./loadCssInjectedByJsPlugin");
|
|
16
17
|
const manifestCache_1 = require("./manifestCache");
|
|
@@ -695,6 +696,14 @@ async function getTrackunitIrisAppVitePlugins(options) {
|
|
|
695
696
|
relativeCSSInjection: true,
|
|
696
697
|
}),
|
|
697
698
|
bundleAnalyzerPlugin,
|
|
699
|
+
// Serve checks pre-bundled dependencies instead, see `optimizeDeps` in getDefaultViteConfig.
|
|
700
|
+
{
|
|
701
|
+
...(0, duplicateTrackunitPackagesPlugin_1.createDuplicateTrackunitPackagesPlugin)({
|
|
702
|
+
failOnSingleInstanceDuplicates: true,
|
|
703
|
+
suggest: (0, iris_app_build_utilities_1.createMigrateSuggestion)(workspaceRoot),
|
|
704
|
+
}),
|
|
705
|
+
apply: "build",
|
|
706
|
+
},
|
|
698
707
|
// When the custom-field in-sync check could not be completed, keep reminding
|
|
699
708
|
// the developer on every rebuild that their custom fields were not validated.
|
|
700
709
|
options.degraded && (0, customFieldsDegradedReminderPlugin_1.createCustomFieldsDegradedReminderPlugin)(true),
|