@nativescript/vite 8.0.0-alpha.56 → 8.0.0-alpha.58
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/configuration/angular.js +3 -3
- package/configuration/angular.js.map +1 -1
- package/helpers/global-defines.d.ts +1 -1
- package/helpers/global-defines.js +1 -1
- package/helpers/workers.js +10 -10
- package/helpers/workers.js.map +1 -1
- package/hmr/client/hot-context.d.ts +67 -0
- package/hmr/client/hot-context.js +284 -0
- package/hmr/client/hot-context.js.map +1 -0
- package/hmr/client/index.js +49 -60
- package/hmr/client/index.js.map +1 -1
- package/hmr/client/utils.js +29 -57
- package/hmr/client/utils.js.map +1 -1
- package/hmr/entry-runtime.js +73 -39
- package/hmr/entry-runtime.js.map +1 -1
- package/hmr/frameworks/angular/client/index.js +103 -161
- package/hmr/frameworks/angular/client/index.js.map +1 -1
- package/hmr/frameworks/angular/server/strategy.js +4 -6
- package/hmr/frameworks/angular/server/strategy.js.map +1 -1
- package/hmr/frameworks/angular/server/websocket-angular-hot-update.js +2 -2
- package/hmr/frameworks/angular/server/websocket-angular-hot-update.js.map +1 -1
- package/hmr/frameworks/solid/client/app-runtime.js +9 -7
- package/hmr/frameworks/solid/client/app-runtime.js.map +1 -1
- package/hmr/frameworks/solid/server/strategy.js +1 -1
- package/hmr/frameworks/solid/server/strategy.js.map +1 -1
- package/hmr/frameworks/typescript/server/strategy.js +1 -1
- package/hmr/frameworks/typescript/server/strategy.js.map +1 -1
- package/hmr/frameworks/vue/client/index.d.ts +1 -0
- package/hmr/frameworks/vue/client/index.js +90 -12
- package/hmr/frameworks/vue/client/index.js.map +1 -1
- package/hmr/frameworks/vue/server/sfc-route-assemble.js +43 -39
- package/hmr/frameworks/vue/server/sfc-route-assemble.js.map +1 -1
- package/hmr/frameworks/vue/server/sfc-route-serve.js +18 -30
- package/hmr/frameworks/vue/server/sfc-route-serve.js.map +1 -1
- package/hmr/frameworks/vue/server/sfc-route-shared.d.ts +13 -16
- package/hmr/frameworks/vue/server/sfc-route-shared.js +20 -24
- package/hmr/frameworks/vue/server/sfc-route-shared.js.map +1 -1
- package/hmr/frameworks/vue/server/strategy.js +14 -12
- package/hmr/frameworks/vue/server/strategy.js.map +1 -1
- package/hmr/helpers/vendor-rewrite.d.ts +1 -1
- package/hmr/helpers/vendor-rewrite.js +5 -3
- package/hmr/helpers/vendor-rewrite.js.map +1 -1
- package/hmr/server/boot-closure-route.d.ts +16 -0
- package/hmr/server/boot-closure-route.js +99 -0
- package/hmr/server/boot-closure-route.js.map +1 -0
- package/hmr/server/core-bundle.d.ts +116 -0
- package/hmr/server/core-bundle.js +460 -0
- package/hmr/server/core-bundle.js.map +1 -0
- package/hmr/server/framework-strategy.d.ts +10 -5
- package/hmr/server/hmr-module-graph.js +7 -6
- package/hmr/server/hmr-module-graph.js.map +1 -1
- package/hmr/server/import-map.d.ts +3 -3
- package/hmr/server/import-map.js +4 -4
- package/hmr/server/import-map.js.map +1 -1
- package/hmr/server/ns-rt-route.js +2 -1
- package/hmr/server/ns-rt-route.js.map +1 -1
- package/hmr/server/perf-instrumentation.js +1 -1
- package/hmr/server/perf-instrumentation.js.map +1 -1
- package/hmr/server/process-code-for-device.d.ts +16 -0
- package/hmr/server/process-code-for-device.js +94 -2
- package/hmr/server/process-code-for-device.js.map +1 -1
- package/hmr/server/vite-plugin.d.ts +1 -0
- package/hmr/server/vite-plugin.js +110 -20
- package/hmr/server/vite-plugin.js.map +1 -1
- package/hmr/server/websocket-import-map-route.d.ts +1 -1
- package/hmr/server/websocket-import-map-route.js +1 -1
- package/hmr/server/websocket-ns-core.d.ts +16 -3
- package/hmr/server/websocket-ns-core.js +100 -5
- package/hmr/server/websocket-ns-core.js.map +1 -1
- package/hmr/server/websocket-ns-m-paths.d.ts +1 -3
- package/hmr/server/websocket-ns-m-paths.js +24 -80
- package/hmr/server/websocket-ns-m-paths.js.map +1 -1
- package/hmr/server/websocket-ns-m.js +41 -77
- package/hmr/server/websocket-ns-m.js.map +1 -1
- package/hmr/server/websocket-served-module-helpers.d.ts +1 -1
- package/hmr/server/websocket-served-module-helpers.js +11 -5
- package/hmr/server/websocket-served-module-helpers.js.map +1 -1
- package/hmr/server/websocket-txn.js +4 -1
- package/hmr/server/websocket-txn.js.map +1 -1
- package/hmr/server/websocket.js +8 -1
- package/hmr/server/websocket.js.map +1 -1
- package/hmr/shared/ns-globals.d.ts +2 -15
- package/hmr/shared/ns-globals.js +2 -3
- package/hmr/shared/ns-globals.js.map +1 -1
- package/hmr/shared/runtime/boot-complete.d.ts +14 -0
- package/hmr/shared/runtime/boot-complete.js +32 -0
- package/hmr/shared/runtime/boot-complete.js.map +1 -0
- package/hmr/shared/runtime/boot-progress.js +6 -5
- package/hmr/shared/runtime/boot-progress.js.map +1 -1
- package/hmr/shared/runtime/boot-timeline.d.ts +1 -1
- package/hmr/shared/runtime/boot-timeline.js +6 -7
- package/hmr/shared/runtime/boot-timeline.js.map +1 -1
- package/hmr/shared/runtime/browser-runtime-contract.d.ts +34 -22
- package/hmr/shared/runtime/browser-runtime-contract.js +6 -9
- package/hmr/shared/runtime/browser-runtime-contract.js.map +1 -1
- package/hmr/shared/runtime/dev-overlay.js +1 -1
- package/hmr/shared/runtime/dev-overlay.js.map +1 -1
- package/hmr/shared/runtime/root-placeholder.js +5 -4
- package/hmr/shared/runtime/root-placeholder.js.map +1 -1
- package/hmr/shared/runtime/session-bootstrap.js +90 -48
- package/hmr/shared/runtime/session-bootstrap.js.map +1 -1
- package/package.json +5 -1
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { resolveProjectMainEntryPath } from './vite-plugin.js';
|
|
2
|
+
import { CORE_BUNDLE_PATH, isCorePerModuleServingEnabled } from './core-bundle.js';
|
|
3
|
+
import { getServerOrigin } from './server-origin.js';
|
|
4
|
+
// `/__ns_dev__/boot-closure` — the server-computed cold-boot module closure.
|
|
5
|
+
//
|
|
6
|
+
// The device bootstrap (`session-bootstrap.ts`) fetches this list and hands
|
|
7
|
+
// it to `__NS_DEV__.kickstartPrefetch(urls)` so the runtime can pre-fill its HTTP
|
|
8
|
+
// body cache in ONE parallel wave before V8's synchronous
|
|
9
|
+
// `ResolveModuleCallback` walks the entry graph. The server owns the module
|
|
10
|
+
// graph, so closure computation lives here — the runtime performs no import
|
|
11
|
+
// scanning of its own; it fetches exactly this list.
|
|
12
|
+
//
|
|
13
|
+
// Watchdog note: the response must come back fast even on a cold Vite
|
|
14
|
+
// process. `populateInitialGraph` starts at `configureServer` time (see
|
|
15
|
+
// websocket.ts) and we only wait for it up to `maxWaitMs`; a PARTIAL list is
|
|
16
|
+
// fine — the kickstart tolerates partial pre-fill and V8 falls back to
|
|
17
|
+
// per-module fetches for anything missing.
|
|
18
|
+
const SCRIPT_EXT_RE = /\.(ts|tsx|js|jsx|mjs|mts|cts)$/i;
|
|
19
|
+
// Pure helper (unit-testable): graph ids → ordered, deduped absolute URL list.
|
|
20
|
+
// The entry goes first so the deepest chain starts fetching immediately; the
|
|
21
|
+
// /ns/rt and /ns/core bridges ride along since every app module imports them.
|
|
22
|
+
// In core-bundle mode the single-eval `/ns/core-bundle.mjs` payload is the
|
|
23
|
+
// biggest body in the boot closure, so it goes right after the entry — the
|
|
24
|
+
// kickstart prewarm then downloads it in parallel with everything else
|
|
25
|
+
// instead of V8 discovering it mid-walk through the /ns/core shim.
|
|
26
|
+
export function buildBootClosureUrls(options) {
|
|
27
|
+
const origin = options.origin.replace(/\/$/, '');
|
|
28
|
+
const urls = [];
|
|
29
|
+
const seen = new Set();
|
|
30
|
+
const add = (url) => {
|
|
31
|
+
if (!seen.has(url)) {
|
|
32
|
+
seen.add(url);
|
|
33
|
+
urls.push(url);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const entryPath = options.entryPathname.startsWith('/') ? options.entryPathname : `/${options.entryPathname}`;
|
|
37
|
+
add(`${origin}/ns/m${entryPath.replace(SCRIPT_EXT_RE, '')}`);
|
|
38
|
+
if (options.includeCoreBundle) {
|
|
39
|
+
add(`${origin}${CORE_BUNDLE_PATH}`);
|
|
40
|
+
}
|
|
41
|
+
add(`${origin}/ns/rt`);
|
|
42
|
+
add(`${origin}/ns/core`);
|
|
43
|
+
for (const id of options.graphModuleIds) {
|
|
44
|
+
if (typeof id !== 'string' || !id.startsWith('/'))
|
|
45
|
+
continue;
|
|
46
|
+
// Vue SFCs and other non-script assets are served through their own
|
|
47
|
+
// routes with their own identity; the /ns/m closure is script-only.
|
|
48
|
+
if (!SCRIPT_EXT_RE.test(id))
|
|
49
|
+
continue;
|
|
50
|
+
add(`${origin}/ns/m${id.replace(SCRIPT_EXT_RE, '')}`);
|
|
51
|
+
}
|
|
52
|
+
return urls;
|
|
53
|
+
}
|
|
54
|
+
export function registerBootClosureRoute(server, source, options) {
|
|
55
|
+
const maxWaitMs = options?.maxWaitMs ?? 3000;
|
|
56
|
+
server.middlewares.use(async (req, res, next) => {
|
|
57
|
+
try {
|
|
58
|
+
const url = new URL(req.url || '', 'http://localhost');
|
|
59
|
+
if (url.pathname !== '/__ns_dev__/boot-closure')
|
|
60
|
+
return next();
|
|
61
|
+
res.setHeader('Access-Control-Allow-Origin', '*');
|
|
62
|
+
res.setHeader('Access-Control-Allow-Methods', 'GET, OPTIONS');
|
|
63
|
+
if (req.method === 'OPTIONS') {
|
|
64
|
+
res.statusCode = 204;
|
|
65
|
+
res.end();
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
// Wait for the background graph walk, but never past the budget —
|
|
69
|
+
// partial closures are acceptable by contract.
|
|
70
|
+
await Promise.race([source.ensureInitialGraphPopulationStarted(server), new Promise((resolve) => setTimeout(resolve, maxWaitMs))]);
|
|
71
|
+
// Use the single trusted origin resolver — never the client-supplied
|
|
72
|
+
// `Host` header (see the import-map route and CLAUDE.md invariant 6:
|
|
73
|
+
// every device-reachable URL must be byte-identical to the origin
|
|
74
|
+
// baked into bundle.mjs).
|
|
75
|
+
const origin = getServerOrigin(server);
|
|
76
|
+
const projectRoot = server.config?.root || process.cwd();
|
|
77
|
+
const payload = {
|
|
78
|
+
urls: buildBootClosureUrls({
|
|
79
|
+
origin,
|
|
80
|
+
entryPathname: resolveProjectMainEntryPath(projectRoot),
|
|
81
|
+
graphModuleIds: source.getGraphModuleIds(),
|
|
82
|
+
// If the bundle build later fails, the kickstart prefetch of this
|
|
83
|
+
// URL just gets a 503 body — prewarm tolerates failures, and the
|
|
84
|
+
// /ns/core shims never reference the bundle in that case.
|
|
85
|
+
includeCoreBundle: !isCorePerModuleServingEnabled(),
|
|
86
|
+
}),
|
|
87
|
+
};
|
|
88
|
+
res.setHeader('Content-Type', 'application/json');
|
|
89
|
+
res.statusCode = 200;
|
|
90
|
+
res.end(JSON.stringify(payload));
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
res.statusCode = 500;
|
|
94
|
+
res.setHeader('Content-Type', 'application/json');
|
|
95
|
+
res.end(JSON.stringify({ error: error?.message || 'Failed to compute NativeScript boot closure', urls: [] }));
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=boot-closure-route.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boot-closure-route.js","sourceRoot":"","sources":["../../../../../packages/vite/hmr/server/boot-closure-route.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,6BAA6B,EAAE,MAAM,kBAAkB,CAAC;AACnF,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,6EAA6E;AAC7E,EAAE;AACF,4EAA4E;AAC5E,kFAAkF;AAClF,0DAA0D;AAC1D,4EAA4E;AAC5E,4EAA4E;AAC5E,qDAAqD;AACrD,EAAE;AACF,sEAAsE;AACtE,wEAAwE;AACxE,6EAA6E;AAC7E,uEAAuE;AACvE,2CAA2C;AAE3C,MAAM,aAAa,GAAG,iCAAiC,CAAC;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eAAe,CAAC,MAAM,CAAC,CAAC;YACvC,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,IAAI,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;YACzD,MAAM,OAAO,GAAG;gBACf,IAAI,EAAE,oBAAoB,CAAC;oBAC1B,MAAM;oBACN,aAAa,EAAE,2BAA2B,CAAC,WAAW,CAAC;oBACvD,cAAc,EAAE,MAAM,CAAC,iBAAiB,EAAE;oBAC1C,kEAAkE;oBAClE,iEAAiE;oBACjE,0DAA0D;oBAC1D,iBAAiB,EAAE,CAAC,6BAA6B,EAAE;iBACnD,CAAC;aACF,CAAC;YAEF,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;YAClD,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC;YACrB,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;QAClC,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACrB,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC;YACrB,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;YAClD,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,IAAI,6CAA6C,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;QAC/G,CAAC;IACF,CAAC,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single-eval @nativescript/core bundle for device serving (bundle mode).
|
|
3
|
+
*
|
|
4
|
+
* DEFAULT MODE (consumers)
|
|
5
|
+
* ------------------------
|
|
6
|
+
* Instead of serving @nativescript/core per-module through Vite's transform
|
|
7
|
+
* pipeline (~hundreds of serial HTTP fetches + per-file transforms during cold
|
|
8
|
+
* boot), the dev server pre-bundles the ENTIRE core package with esbuild into
|
|
9
|
+
* one ESM payload served at `GET /ns/core-bundle.mjs`. The canonical
|
|
10
|
+
* `/ns/core[/<sub>]` URL space is preserved — those routes serve THIN SHIMS
|
|
11
|
+
* that statically import the bundle and re-export the requested subpath's
|
|
12
|
+
* namespace from the `globalThis.__NS_CORE_MODULES__` registry the bundle
|
|
13
|
+
* populates. Because every shim's only dependency is the one bundle URL,
|
|
14
|
+
* V8/iOS evaluates core exactly once per app lifetime — the single-realm
|
|
15
|
+
* invariant is enforced by construction, with ONE big prefetchable payload
|
|
16
|
+
* instead of a deep serial fetch chain.
|
|
17
|
+
*
|
|
18
|
+
* OPT-IN PER-MODULE MODE (core maintainers)
|
|
19
|
+
* -----------------------------------------
|
|
20
|
+
* Set `NS_CORE_PER_MODULE=1` to keep the classic per-module `/ns/core` bridge
|
|
21
|
+
* (websocket-ns-core.ts). That is the right mode when editing
|
|
22
|
+
* `@nativescript/core` source live inside the NativeScript monorepo: each core
|
|
23
|
+
* module stays individually served/transformed so core edits participate in
|
|
24
|
+
* HMR. Consumers of the published package don't edit core mid-session, so the
|
|
25
|
+
* bundle is both safe and much faster for them.
|
|
26
|
+
*
|
|
27
|
+
* FAILURE FALLBACK
|
|
28
|
+
* ----------------
|
|
29
|
+
* If the esbuild bundle build fails for any reason, the service marks itself
|
|
30
|
+
* failed and `/ns/core[/<sub>]` transparently falls back to the per-module
|
|
31
|
+
* bridge for the whole session (logged loudly once). Boot still works; only
|
|
32
|
+
* the speed win is lost.
|
|
33
|
+
*/
|
|
34
|
+
import type { ViteDevServer } from 'vite';
|
|
35
|
+
import type { Platform } from '../../helpers/platform-types.js';
|
|
36
|
+
/**
|
|
37
|
+
* Per-module /ns/core serving mode (vs the default single-eval bundle).
|
|
38
|
+
*
|
|
39
|
+
* `NS_CORE_PER_MODULE=1|true` forces it on, `0|false` forces bundle mode.
|
|
40
|
+
* When unset, it AUTO-ENABLES for monorepo core source (packages/core in the
|
|
41
|
+
* NativeScript repo). Two reasons:
|
|
42
|
+
* - core maintainers edit core live, and per-module serving keeps those
|
|
43
|
+
* edits in HMR;
|
|
44
|
+
* - realm safety: the build-time externalizer emits
|
|
45
|
+
* `/ns/m/packages/core/<file>` URLs for workspace-source core (see the
|
|
46
|
+
* `ns-core-external-urls` workspace branch in configuration/base.ts), so
|
|
47
|
+
* the served graph's core realm lives under /ns/m. A bundle-mode
|
|
48
|
+
* `/ns/core-bundle.mjs` would evaluate a complete SECOND copy of core for
|
|
49
|
+
* the entry's `/ns/core/globals|application|…` imports — duplicate native
|
|
50
|
+
* class registrations crash in MetadataBuilder at startup.
|
|
51
|
+
*/
|
|
52
|
+
export declare function isCorePerModuleServingEnabled(env?: NodeJS.ProcessEnv, hasWorkspaceCoreSource?: () => boolean): boolean;
|
|
53
|
+
export interface CoreBundleState {
|
|
54
|
+
/** Full ESM payload served at /ns/core-bundle.mjs (shape header + esbuild output). */
|
|
55
|
+
code: string;
|
|
56
|
+
/** Canonical subpaths registered in the bundle's __NS_CORE_MODULES__ registry. */
|
|
57
|
+
subs: Set<string>;
|
|
58
|
+
hash: string;
|
|
59
|
+
builtAt: number;
|
|
60
|
+
buildMs: number;
|
|
61
|
+
}
|
|
62
|
+
export interface CoreBundleService {
|
|
63
|
+
/** Resolves the built bundle, or null when the build failed (per-module fallback). */
|
|
64
|
+
ensureBuilt(): Promise<CoreBundleState | null>;
|
|
65
|
+
/** Synchronous view — null until built (or when failed). */
|
|
66
|
+
getState(): CoreBundleState | null;
|
|
67
|
+
hasFailed(): boolean;
|
|
68
|
+
}
|
|
69
|
+
export interface GenerateCoreBundleOptions {
|
|
70
|
+
projectRoot: string;
|
|
71
|
+
platform: Platform | string;
|
|
72
|
+
mode: 'development' | 'production' | string;
|
|
73
|
+
flavor?: string;
|
|
74
|
+
verbose?: boolean;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Resolve the physical @nativescript/core root the same way configuration/
|
|
78
|
+
* base.ts does: prefer monorepo source (`<workspace>/packages/core`), else the
|
|
79
|
+
* node_modules install reachable from the project root.
|
|
80
|
+
*/
|
|
81
|
+
export declare function resolveCoreRootForBundle(projectRoot: string): string;
|
|
82
|
+
/**
|
|
83
|
+
* Enumerate every importable core subpath (canonical form, per
|
|
84
|
+
* `normalizeCoreSub`) for the given platform. A subpath is included when it
|
|
85
|
+
* has a platform-neutral variant OR a variant for the current platform —
|
|
86
|
+
* other-platform-only modules (e.g. `ui/frame/activity.android` on iOS) are
|
|
87
|
+
* skipped since they can never resolve for this build.
|
|
88
|
+
*/
|
|
89
|
+
export declare function enumerateCoreModuleSubpaths(coreRoot: string, platform: string): string[];
|
|
90
|
+
/**
|
|
91
|
+
* Synthetic esbuild entry: evaluate core once, expose every subpath's live
|
|
92
|
+
* namespace through `globalThis.__NS_CORE_MODULES__` (the SAME registry the
|
|
93
|
+
* per-module bridge footers populate, so the vendor CJS `require()` shim and
|
|
94
|
+
* `_nsReq` lookups keep working unchanged), and re-export the package main so
|
|
95
|
+
* `/ns/core-bundle.mjs` itself has core's full named-export surface.
|
|
96
|
+
*/
|
|
97
|
+
export declare function buildCoreBundleEntryCode(subs: readonly string[]): string;
|
|
98
|
+
export declare function generateCoreBundle(options: GenerateCoreBundleOptions): Promise<CoreBundleState>;
|
|
99
|
+
export declare function createCoreBundleService(options: GenerateCoreBundleOptions): CoreBundleService;
|
|
100
|
+
/**
|
|
101
|
+
* Process-wide bundle service derived from the dev server's config + CLI
|
|
102
|
+
* flags. One dev server per process, so a module-level singleton matches the
|
|
103
|
+
* vendor manifest's lifecycle.
|
|
104
|
+
*/
|
|
105
|
+
export declare function getSharedCoreBundleService(server: ViteDevServer): CoreBundleService;
|
|
106
|
+
/** Test seam: drop the shared service so specs can mount fresh. */
|
|
107
|
+
export declare function resetSharedCoreBundleServiceForTests(): void;
|
|
108
|
+
export declare const CORE_BUNDLE_PATH = "/ns/core-bundle.mjs";
|
|
109
|
+
/**
|
|
110
|
+
* Shim served at `/ns/core` in bundle mode. `export * from` gives real,
|
|
111
|
+
* live named bindings straight off the bundle module record; the explicit
|
|
112
|
+
* default keeps the "default import + destructure" consumer rewrite working
|
|
113
|
+
* (see buildDefaultExportFooter in ns-core-cjs-shape.ts for that contract).
|
|
114
|
+
*/
|
|
115
|
+
export declare function buildCoreMainShimCode(): string;
|
|
116
|
+
export declare function buildCoreSubShimCode(sub: string, exportNames: readonly string[], hasOwnDefaultExport?: boolean): string;
|