| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
In a worker serve, imports into node_modules become `/ns/m/node_modules/<pkg>?ns_worker=1`, but re-exports were left to rewriteImports, which hands a package's own `export * from './sub'` to the import map as a bare specifier. The import map routes that to the deps-bundle shim, so the worker evaluated the whole bundle as well and held a second copy of a package it had already loaded per module. Worker imports and re-exports now both name the file Vite resolved, so each module has one URL in the worker realm. The main realm is unchanged.
|
View your CI Pipeline Execution ↗ for commit 4a47a88
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗ ☁️ Nx Cloud last updated this comment at 2026-10-05 16:58:51 UTC |
Sorry, something went wrong.
npm i https://pkg.pr.new/@nativescript/core@11504 npm i https://pkg.pr.new/@nativescript/vite@11504 npm i https://pkg.pr.new/@nativescript/webpack@11504 commit: 4a47a88 |
Sorry, something went wrong.
The vendorImportsAsHttp and processCodeForDevice comments still described worker vendor imports as going through the deps-bundle bridge, and transitive worker imports as unforkable; both predate ns_worker=1 propagation and contradict the per-module invariant this branch adds.
| Back | FazBrowse Home | New Git URL |
PR Checklist
What is the current behavior?
In a worker serve (?ns_worker=1), ensureNativeScriptModuleBindings rewrites imports into node_modules to /ns/m/node_modules/<pkg>?ns_worker=1, so the worker's graph stays off the deps bundle. Re-exports are not import declarations, so they skip that pass. rewriteImports then hands a package's own export * from './sub' to the import map as a bare specifier, which routes it to the deps-bundle shim.
The worker then evaluates the whole deps bundle as well, and holds two copies of any package it reached through both paths. With @nativescript/canvas, a worker importing @nativescript/canvas/worker crashes on iOS:
TypeError: CanvasModule is not a constructor at Helpers.initialize (/ns/deps-bundle.mjs) ... Error loading ES module: /ns/m/src/canvas/workers/fireflies.workerThe per-module helpers.js installs the CanvasModule global first. The bundle's copy of helpers.js then calls new CanvasModule() on the installed object.
Imports and re-exports also spell the same module differently in a worker: imports use the authored spelling from getPreservedImportSpecifier (…/Canvas2D/Path2D), re-exports the resolved file (…/Canvas2D/Path2D/index.js). So even without the bundle, a module could load once per spelling.
What is the new behavior?
In a worker serve, imports and re-exports into node_modules both name the file Vite resolved: /ns/m/node_modules/<resolved file>?ns_worker=1. Each module has one URL in the worker realm, as on the web. @nativescript/core and framework packages are left as before.
The authored spelling only serves the main realm's import map and vendor routing, so workers no longer use it. The main realm is unchanged.
Verified against an app using @nativescript/canvas workers: