@atlaspack/packager-js 2.14.5-canary.19 → 2.14.5-canary.190
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 +302 -0
- package/lib/DevPackager.js +28 -3
- package/lib/ScopeHoistingPackager.js +338 -87
- package/lib/dev-prelude.js +6 -6
- package/lib/helpers.js +38 -3
- package/lib/index.js +5 -10
- package/lib/types/CJSOutputFormat.d.ts +7 -0
- package/lib/types/DevPackager.d.ts +15 -0
- package/lib/types/ESMOutputFormat.d.ts +7 -0
- package/lib/types/GlobalOutputFormat.d.ts +7 -0
- package/lib/types/ScopeHoistingPackager.d.ts +67 -0
- package/lib/types/helpers.d.ts +12 -0
- package/lib/types/index.d.ts +3 -0
- package/lib/types/utils.d.ts +6 -0
- package/package.json +18 -12
- package/src/{CJSOutputFormat.js → CJSOutputFormat.ts} +0 -1
- package/src/{DevPackager.js → DevPackager.ts} +34 -7
- package/src/{ESMOutputFormat.js → ESMOutputFormat.ts} +2 -3
- package/src/{GlobalOutputFormat.js → GlobalOutputFormat.ts} +0 -1
- package/src/{ScopeHoistingPackager.js → ScopeHoistingPackager.ts} +405 -125
- package/src/dev-prelude.js +6 -6
- package/src/{helpers.js → helpers.ts} +37 -3
- package/src/{index.js → index.ts} +13 -20
- package/src/{utils.js → utils.ts} +1 -2
- package/tsconfig.json +4 -0
package/lib/dev-prelude.js
CHANGED
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
typeof globalThis !== 'undefined'
|
|
13
13
|
? globalThis
|
|
14
14
|
: typeof self !== 'undefined'
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
? self
|
|
16
|
+
: typeof window !== 'undefined'
|
|
17
|
+
? window
|
|
18
|
+
: typeof global !== 'undefined'
|
|
19
|
+
? global
|
|
20
|
+
: {};
|
|
21
21
|
/* eslint-enable no-undef */
|
|
22
22
|
|
|
23
23
|
// Save the require from previous bundle to this closure if any
|
package/lib/helpers.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
const
|
|
6
|
+
exports.preludeOld = exports.preludeNew = exports.helpers = exports.fnExpr = exports.bundleQueuePrelude = void 0;
|
|
7
|
+
const preludeOld = parcelRequireName => `
|
|
8
8
|
var $parcel$modules = {};
|
|
9
9
|
var $parcel$inits = {};
|
|
10
10
|
|
|
@@ -37,7 +37,42 @@ if (parcelRequire == null) {
|
|
|
37
37
|
|
|
38
38
|
var parcelRegister = parcelRequire.register;
|
|
39
39
|
`;
|
|
40
|
-
exports.
|
|
40
|
+
exports.preludeOld = preludeOld;
|
|
41
|
+
const preludeNew = parcelRequireName => `
|
|
42
|
+
var $parcel$modules = {};
|
|
43
|
+
var $parcel$inits = {};
|
|
44
|
+
|
|
45
|
+
var parcelRequire = $parcel$global[${JSON.stringify(parcelRequireName)}];
|
|
46
|
+
|
|
47
|
+
if (parcelRequire == null) {
|
|
48
|
+
parcelRequire = function(id) {
|
|
49
|
+
var mod = $parcel$modules[id];
|
|
50
|
+
if (mod !== undefined) {
|
|
51
|
+
return mod.exports;
|
|
52
|
+
}
|
|
53
|
+
var init = $parcel$inits[id];
|
|
54
|
+
if (init !== undefined) {
|
|
55
|
+
delete $parcel$inits[id];
|
|
56
|
+
var module = {id: id, exports: {}};
|
|
57
|
+
$parcel$modules[id] = module;
|
|
58
|
+
init.call(module.exports, module, module.exports);
|
|
59
|
+
return module.exports;
|
|
60
|
+
}
|
|
61
|
+
var err = new Error("Cannot find module '" + id + "'");
|
|
62
|
+
err.code = 'MODULE_NOT_FOUND';
|
|
63
|
+
throw err;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
parcelRequire.register = function register(id, init) {
|
|
67
|
+
$parcel$inits[id] = init;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
$parcel$global[${JSON.stringify(parcelRequireName)}] = parcelRequire;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
var parcelRegister = parcelRequire.register;
|
|
74
|
+
`;
|
|
75
|
+
exports.preludeNew = preludeNew;
|
|
41
76
|
const fnExpr = (env, params, body) => {
|
|
42
77
|
let block = `{ ${body.join(' ')} }`;
|
|
43
78
|
if (env.supports('arrow-functions')) {
|
package/lib/index.js
CHANGED
|
@@ -47,12 +47,6 @@ const CONFIG_SCHEMA = {
|
|
|
47
47
|
properties: {
|
|
48
48
|
unstable_asyncBundleRuntime: {
|
|
49
49
|
type: 'boolean'
|
|
50
|
-
},
|
|
51
|
-
unstable_forceSkipWrapAssets: {
|
|
52
|
-
type: 'array',
|
|
53
|
-
items: {
|
|
54
|
-
type: 'string'
|
|
55
|
-
}
|
|
56
50
|
}
|
|
57
51
|
},
|
|
58
52
|
additionalProperties: false
|
|
@@ -62,7 +56,7 @@ var _default = exports.default = new (_plugin().Packager)({
|
|
|
62
56
|
config,
|
|
63
57
|
options
|
|
64
58
|
}) {
|
|
65
|
-
var _conf$contents
|
|
59
|
+
var _conf$contents;
|
|
66
60
|
let packageKey = '@atlaspack/packager-js';
|
|
67
61
|
let conf = await config.getConfigFrom(options.projectRoot + '/index', [], {
|
|
68
62
|
packageKey
|
|
@@ -83,9 +77,10 @@ var _default = exports.default = new (_plugin().Packager)({
|
|
|
83
77
|
});
|
|
84
78
|
let name = (packageName === null || packageName === void 0 ? void 0 : packageName.contents) ?? '';
|
|
85
79
|
return {
|
|
80
|
+
// @ts-expect-error TS2345
|
|
86
81
|
parcelRequireName: 'parcelRequire' + (0, _rust().hashString)(name).slice(-4),
|
|
87
|
-
unstable_asyncBundleRuntime: Boolean(
|
|
88
|
-
|
|
82
|
+
unstable_asyncBundleRuntime: Boolean( // @ts-expect-error TS2339
|
|
83
|
+
conf === null || conf === void 0 || (_conf$contents = conf.contents) === null || _conf$contents === void 0 ? void 0 : _conf$contents.unstable_asyncBundleRuntime)
|
|
89
84
|
};
|
|
90
85
|
},
|
|
91
86
|
async package({
|
|
@@ -108,7 +103,7 @@ var _default = exports.default = new (_plugin().Packager)({
|
|
|
108
103
|
}
|
|
109
104
|
}
|
|
110
105
|
if (contents == null) {
|
|
111
|
-
let packager = bundle.env.shouldScopeHoist ? new _ScopeHoistingPackager.ScopeHoistingPackager(options, bundleGraph, bundle, (0, _nullthrows().default)(config).parcelRequireName, (0, _nullthrows().default)(config).unstable_asyncBundleRuntime,
|
|
106
|
+
let packager = bundle.env.shouldScopeHoist ? new _ScopeHoistingPackager.ScopeHoistingPackager(options, bundleGraph, bundle, (0, _nullthrows().default)(config).parcelRequireName, (0, _nullthrows().default)(config).unstable_asyncBundleRuntime, logger) : new _DevPackager.DevPackager(options, bundleGraph, bundle, (0, _nullthrows().default)(config).parcelRequireName);
|
|
112
107
|
({
|
|
113
108
|
contents,
|
|
114
109
|
map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ScopeHoistingPackager, OutputFormat } from './ScopeHoistingPackager';
|
|
2
|
+
export declare class CJSOutputFormat implements OutputFormat {
|
|
3
|
+
packager: ScopeHoistingPackager;
|
|
4
|
+
constructor(packager: ScopeHoistingPackager);
|
|
5
|
+
buildBundlePrelude(): [string, number];
|
|
6
|
+
buildBundlePostlude(): [string, number];
|
|
7
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { BundleGraph, PluginOptions, NamedBundle } from '@atlaspack/types';
|
|
2
|
+
import SourceMap from '@parcel/source-map';
|
|
3
|
+
export declare class DevPackager {
|
|
4
|
+
options: PluginOptions;
|
|
5
|
+
bundleGraph: BundleGraph<NamedBundle>;
|
|
6
|
+
bundle: NamedBundle;
|
|
7
|
+
parcelRequireName: string;
|
|
8
|
+
constructor(options: PluginOptions, bundleGraph: BundleGraph<NamedBundle>, bundle: NamedBundle, parcelRequireName: string);
|
|
9
|
+
package(): Promise<{
|
|
10
|
+
contents: string;
|
|
11
|
+
map: SourceMap | null | undefined;
|
|
12
|
+
}>;
|
|
13
|
+
getPrefix(): string;
|
|
14
|
+
isEntry(): boolean;
|
|
15
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ScopeHoistingPackager, OutputFormat } from './ScopeHoistingPackager';
|
|
2
|
+
export declare class ESMOutputFormat implements OutputFormat {
|
|
3
|
+
packager: ScopeHoistingPackager;
|
|
4
|
+
constructor(packager: ScopeHoistingPackager);
|
|
5
|
+
buildBundlePrelude(): [string, number];
|
|
6
|
+
buildBundlePostlude(): [string, number];
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ScopeHoistingPackager, OutputFormat } from './ScopeHoistingPackager';
|
|
2
|
+
export declare class GlobalOutputFormat implements OutputFormat {
|
|
3
|
+
packager: ScopeHoistingPackager;
|
|
4
|
+
constructor(packager: ScopeHoistingPackager);
|
|
5
|
+
buildBundlePrelude(): [string, number];
|
|
6
|
+
buildBundlePostlude(): [string, number];
|
|
7
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { Asset, BundleGraph, Dependency, PluginOptions, NamedBundle, PluginLogger } from '@atlaspack/types';
|
|
2
|
+
import SourceMap from '@parcel/source-map';
|
|
3
|
+
export interface OutputFormat {
|
|
4
|
+
buildBundlePrelude(): [string, number];
|
|
5
|
+
buildBundlePostlude(): [string, number];
|
|
6
|
+
}
|
|
7
|
+
export declare class ScopeHoistingPackager {
|
|
8
|
+
options: PluginOptions;
|
|
9
|
+
bundleGraph: BundleGraph<NamedBundle>;
|
|
10
|
+
bundle: NamedBundle;
|
|
11
|
+
parcelRequireName: string;
|
|
12
|
+
useAsyncBundleRuntime: boolean;
|
|
13
|
+
outputFormat: OutputFormat;
|
|
14
|
+
isAsyncBundle: boolean;
|
|
15
|
+
globalNames: ReadonlySet<string>;
|
|
16
|
+
assetOutputs: Map<string, {
|
|
17
|
+
code: string;
|
|
18
|
+
map: Buffer | null | undefined;
|
|
19
|
+
}>;
|
|
20
|
+
exportedSymbols: Map<string, {
|
|
21
|
+
asset: Asset;
|
|
22
|
+
exportSymbol: string;
|
|
23
|
+
local: string;
|
|
24
|
+
exportAs: Array<string>;
|
|
25
|
+
}>;
|
|
26
|
+
externals: Map<string, Map<string, string>>;
|
|
27
|
+
topLevelNames: Map<string, number>;
|
|
28
|
+
seenAssets: Set<string>;
|
|
29
|
+
wrappedAssets: Set<string>;
|
|
30
|
+
hoistedRequires: Map<string, Map<string, string>>;
|
|
31
|
+
seenHoistedRequires: Set<string>;
|
|
32
|
+
needsPrelude: boolean;
|
|
33
|
+
usedHelpers: Set<string>;
|
|
34
|
+
externalAssets: Set<Asset>;
|
|
35
|
+
logger: PluginLogger;
|
|
36
|
+
useBothScopeHoistingImprovements: boolean;
|
|
37
|
+
constructor(options: PluginOptions, bundleGraph: BundleGraph<NamedBundle>, bundle: NamedBundle, parcelRequireName: string, useAsyncBundleRuntime: boolean, logger: PluginLogger);
|
|
38
|
+
package(): Promise<{
|
|
39
|
+
contents: string;
|
|
40
|
+
map: SourceMap | null | undefined;
|
|
41
|
+
}>;
|
|
42
|
+
shouldBundleQueue(bundle: NamedBundle): boolean;
|
|
43
|
+
runWhenReady(bundle: NamedBundle, codeToRun: string): string;
|
|
44
|
+
loadAssets(): Promise<{
|
|
45
|
+
wrapped: Array<Asset>;
|
|
46
|
+
constant: Array<Asset>;
|
|
47
|
+
}>;
|
|
48
|
+
isReExported(asset: Asset): boolean;
|
|
49
|
+
buildExportedSymbols(): void;
|
|
50
|
+
getTopLevelName(name: string): string;
|
|
51
|
+
getPropertyAccess(obj: string, property: string): string;
|
|
52
|
+
visitAsset(asset: Asset): [string, SourceMap | null | undefined, number];
|
|
53
|
+
getAssetFilePath(asset: Asset): string;
|
|
54
|
+
buildAsset(asset: Asset, code: string, map?: Buffer | null): [string, SourceMap | null | undefined, number];
|
|
55
|
+
buildReplacements(asset: Asset, deps: Array<Dependency>): [Map<string, Array<Dependency>>, Map<string, string>];
|
|
56
|
+
addExternal(dep: Dependency, replacements?: Map<string, string>, referencedBundle?: NamedBundle): void;
|
|
57
|
+
isWrapped(resolved: Asset, parentAsset: Asset): boolean;
|
|
58
|
+
getSymbolResolution(parentAsset: Asset, resolved: Asset, imported: string, dep?: Dependency, replacements?: Map<string, string>): string;
|
|
59
|
+
getHoistedParcelRequires(parentAsset: Asset, dep: Dependency, resolved: Asset): [string, number];
|
|
60
|
+
buildAssetPrelude(asset: Asset, deps: Array<Dependency>, replacements: Map<string, string>): [string, number, string];
|
|
61
|
+
buildBundlePrelude(): [string, number];
|
|
62
|
+
needsDefaultInterop(asset: Asset): boolean;
|
|
63
|
+
shouldSkipAsset(asset: Asset): boolean;
|
|
64
|
+
isScriptEntry(asset: Asset): boolean;
|
|
65
|
+
buildFunctionExpression(args: Array<string>, expr: string): string;
|
|
66
|
+
hasConditionalDependency(): boolean;
|
|
67
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Environment } from '@atlaspack/types';
|
|
2
|
+
export declare const preludeOld: (parcelRequireName: string) => string;
|
|
3
|
+
export declare const preludeNew: (parcelRequireName: string) => string;
|
|
4
|
+
export declare const fnExpr: (env: Environment, params: Array<string>, body: Array<string>) => string;
|
|
5
|
+
export declare const bundleQueuePrelude: (env: Environment) => string;
|
|
6
|
+
export declare const helpers: {
|
|
7
|
+
readonly $parcel$export: "\nfunction $parcel$export(e, n, v, s) {\n Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});\n}\n";
|
|
8
|
+
readonly $parcel$exportWildcard: "\nfunction $parcel$exportWildcard(dest, source) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule' || Object.prototype.hasOwnProperty.call(dest, key)) {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function get() {\n return source[key];\n }\n });\n });\n\n return dest;\n}\n";
|
|
9
|
+
readonly $parcel$interopDefault: "\nfunction $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\n}\n";
|
|
10
|
+
readonly $parcel$global: (env: Environment) => string;
|
|
11
|
+
readonly $parcel$defineInteropFlag: "\nfunction $parcel$defineInteropFlag(a) {\n Object.defineProperty(a, '__esModule', {value: true, configurable: true});\n}\n";
|
|
12
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { BundleGraph, Dependency, NamedBundle } from '@atlaspack/types';
|
|
2
|
+
import type SourceMap from '@parcel/source-map';
|
|
3
|
+
export declare function replaceScriptDependencies(bundleGraph: BundleGraph<NamedBundle>, bundle: NamedBundle, code: string, map: SourceMap | null | undefined, parcelRequireName: string): string;
|
|
4
|
+
export declare function getSpecifier(dep: Dependency): string;
|
|
5
|
+
export declare function isValidIdentifier(id: string): boolean;
|
|
6
|
+
export declare function makeValidIdentifier(name: string): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/packager-js",
|
|
3
|
-
"version": "2.14.5-canary.
|
|
3
|
+
"version": "2.14.5-canary.190+7a52bab62",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -9,22 +9,28 @@
|
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "https://github.com/atlassian-labs/atlaspack.git"
|
|
11
11
|
},
|
|
12
|
-
"main": "lib/index.js",
|
|
13
|
-
"source": "src/index.
|
|
12
|
+
"main": "./lib/index.js",
|
|
13
|
+
"source": "./src/index.ts",
|
|
14
|
+
"types": "./lib/index.d.ts",
|
|
14
15
|
"engines": {
|
|
15
16
|
"node": ">= 16.0.0"
|
|
16
17
|
},
|
|
17
18
|
"dependencies": {
|
|
18
|
-
"@atlaspack/diagnostic": "2.14.1-canary.
|
|
19
|
-
"@atlaspack/feature-flags": "2.14.1-canary.
|
|
20
|
-
"@atlaspack/plugin": "2.14.5-canary.
|
|
21
|
-
"@atlaspack/rust": "3.2.1-canary.
|
|
22
|
-
"@atlaspack/types": "2.14.5-canary.
|
|
23
|
-
"@atlaspack/utils": "2.14.5-canary.
|
|
19
|
+
"@atlaspack/diagnostic": "2.14.1-canary.258+7a52bab62",
|
|
20
|
+
"@atlaspack/feature-flags": "2.14.1-canary.258+7a52bab62",
|
|
21
|
+
"@atlaspack/plugin": "2.14.5-canary.190+7a52bab62",
|
|
22
|
+
"@atlaspack/rust": "3.2.1-canary.190+7a52bab62",
|
|
23
|
+
"@atlaspack/types": "2.14.5-canary.190+7a52bab62",
|
|
24
|
+
"@atlaspack/utils": "2.14.5-canary.190+7a52bab62",
|
|
24
25
|
"@parcel/source-map": "^2.1.1",
|
|
25
26
|
"globals": "^13.2.0",
|
|
26
|
-
"nullthrows": "^1.1.1"
|
|
27
|
+
"nullthrows": "^1.1.1",
|
|
28
|
+
"outdent": "^0.8.0"
|
|
27
29
|
},
|
|
28
30
|
"type": "commonjs",
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
+
"scripts": {
|
|
32
|
+
"check-ts": "tsc --emitDeclarationOnly --rootDir src",
|
|
33
|
+
"build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
|
|
34
|
+
},
|
|
35
|
+
"gitHead": "7a52bab6281e8edbfa66af248eb6f872c6b4b7bd"
|
|
36
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @flow strict-local
|
|
2
1
|
import type {BundleGraph, PluginOptions, NamedBundle} from '@atlaspack/types';
|
|
3
2
|
|
|
4
3
|
import {
|
|
@@ -8,6 +7,7 @@ import {
|
|
|
8
7
|
normalizeSeparators,
|
|
9
8
|
} from '@atlaspack/utils';
|
|
10
9
|
import SourceMap from '@parcel/source-map';
|
|
10
|
+
import {getFeatureFlag} from '@atlaspack/feature-flags';
|
|
11
11
|
import invariant from 'assert';
|
|
12
12
|
import path from 'path';
|
|
13
13
|
import fs from 'fs';
|
|
@@ -36,7 +36,10 @@ export class DevPackager {
|
|
|
36
36
|
this.parcelRequireName = parcelRequireName;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
async package(): Promise<{
|
|
39
|
+
async package(): Promise<{
|
|
40
|
+
contents: string;
|
|
41
|
+
map: SourceMap | null | undefined;
|
|
42
|
+
}> {
|
|
40
43
|
// Load assets
|
|
41
44
|
let queue = new PromiseQueue({maxConcurrent: 32});
|
|
42
45
|
this.bundle.traverseAssets((asset) => {
|
|
@@ -58,7 +61,13 @@ export class DevPackager {
|
|
|
58
61
|
|
|
59
62
|
let prefix = this.getPrefix();
|
|
60
63
|
let lineOffset = countLines(prefix);
|
|
61
|
-
let script:
|
|
64
|
+
let script:
|
|
65
|
+
| {
|
|
66
|
+
code: string;
|
|
67
|
+
mapBuffer: Buffer | null | undefined;
|
|
68
|
+
}
|
|
69
|
+
| null
|
|
70
|
+
| undefined = null;
|
|
62
71
|
|
|
63
72
|
this.bundle.traverse((node) => {
|
|
64
73
|
let wrapped = first ? '' : ',';
|
|
@@ -93,11 +102,12 @@ export class DevPackager {
|
|
|
93
102
|
this.bundle.env.sourceType === 'script' &&
|
|
94
103
|
asset === this.bundle.getMainEntry()
|
|
95
104
|
) {
|
|
105
|
+
// @ts-expect-error TS2322
|
|
96
106
|
script = results[i++];
|
|
97
107
|
return;
|
|
98
108
|
}
|
|
99
109
|
|
|
100
|
-
let deps = {};
|
|
110
|
+
let deps: Record<string, any> = {};
|
|
101
111
|
let dependencies = this.bundleGraph.getDependencies(asset);
|
|
102
112
|
for (let dep of dependencies) {
|
|
103
113
|
let resolved = this.bundleGraph.getResolvedAsset(dep, this.bundle);
|
|
@@ -112,6 +122,19 @@ export class DevPackager {
|
|
|
112
122
|
}
|
|
113
123
|
}
|
|
114
124
|
|
|
125
|
+
if (getFeatureFlag('hmrImprovements')) {
|
|
126
|
+
// Add dependencies for parcelRequire calls added by runtimes
|
|
127
|
+
// so that the HMR runtime can correctly traverse parents.
|
|
128
|
+
let hmrDeps = asset.meta.hmrDeps;
|
|
129
|
+
if (this.options.hmrOptions && Array.isArray(hmrDeps)) {
|
|
130
|
+
for (let id of hmrDeps) {
|
|
131
|
+
invariant(typeof id === 'string');
|
|
132
|
+
deps[id] = id;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// @ts-expect-error TS2339
|
|
115
138
|
let {code, mapBuffer} = results[i];
|
|
116
139
|
let output = code || '';
|
|
117
140
|
wrapped +=
|
|
@@ -192,6 +215,7 @@ export class DevPackager {
|
|
|
192
215
|
// runtimes with a parcelRequire call.
|
|
193
216
|
if (this.bundle.env.sourceType === 'script' && script) {
|
|
194
217
|
let entryMap;
|
|
218
|
+
// @ts-expect-error TS2339
|
|
195
219
|
let mapBuffer = script.mapBuffer;
|
|
196
220
|
if (mapBuffer) {
|
|
197
221
|
entryMap = new SourceMap(this.options.projectRoot, mapBuffer);
|
|
@@ -199,11 +223,13 @@ export class DevPackager {
|
|
|
199
223
|
contents += replaceScriptDependencies(
|
|
200
224
|
this.bundleGraph,
|
|
201
225
|
this.bundle,
|
|
226
|
+
// @ts-expect-error TS2339
|
|
202
227
|
script.code,
|
|
203
228
|
entryMap,
|
|
204
229
|
this.parcelRequireName,
|
|
205
230
|
);
|
|
206
231
|
if (this.bundle.env.sourceMap && entryMap) {
|
|
232
|
+
// @ts-expect-error TS2551
|
|
207
233
|
map.addSourceMap(entryMap, lineOffset);
|
|
208
234
|
}
|
|
209
235
|
}
|
|
@@ -215,7 +241,7 @@ export class DevPackager {
|
|
|
215
241
|
}
|
|
216
242
|
|
|
217
243
|
getPrefix(): string {
|
|
218
|
-
let interpreter:
|
|
244
|
+
let interpreter: string | null | undefined;
|
|
219
245
|
let mainEntry = this.bundle.getMainEntry();
|
|
220
246
|
if (mainEntry && this.isEntry() && !this.bundle.target.env.isBrowser()) {
|
|
221
247
|
let _interpreter = mainEntry.meta.interpreter;
|
|
@@ -224,7 +250,7 @@ export class DevPackager {
|
|
|
224
250
|
}
|
|
225
251
|
|
|
226
252
|
let importScripts = '';
|
|
227
|
-
if (this.bundle.env.isWorker()) {
|
|
253
|
+
if (this.bundle.env.isWorker() || this.bundle.env.isTesseract()) {
|
|
228
254
|
let bundles = this.bundleGraph.getReferencedBundles(this.bundle);
|
|
229
255
|
for (let b of bundles) {
|
|
230
256
|
importScripts += `importScripts("${relativeBundlePath(
|
|
@@ -246,7 +272,8 @@ export class DevPackager {
|
|
|
246
272
|
return (
|
|
247
273
|
!this.bundleGraph.hasParentBundleOfType(this.bundle, 'js') ||
|
|
248
274
|
this.bundle.env.isIsolated() ||
|
|
249
|
-
this.bundle.bundleBehavior === 'isolated'
|
|
275
|
+
this.bundle.bundleBehavior === 'isolated' ||
|
|
276
|
+
this.bundle.bundleBehavior === 'inlineIsolated'
|
|
250
277
|
);
|
|
251
278
|
}
|
|
252
279
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
import type {
|
|
3
2
|
ScopeHoistingPackager,
|
|
4
3
|
OutputFormat,
|
|
@@ -18,7 +17,7 @@ export class ESMOutputFormat implements OutputFormat {
|
|
|
18
17
|
for (let [source, specifiers] of this.packager.externals) {
|
|
19
18
|
let defaultSpecifier = null;
|
|
20
19
|
let namespaceSpecifier = null;
|
|
21
|
-
let namedSpecifiers = [];
|
|
20
|
+
let namedSpecifiers: Array<string> = [];
|
|
22
21
|
for (let [imported, symbol] of specifiers) {
|
|
23
22
|
if (imported === 'default' /* || isCommonJS*/) {
|
|
24
23
|
defaultSpecifier = symbol;
|
|
@@ -77,7 +76,7 @@ export class ESMOutputFormat implements OutputFormat {
|
|
|
77
76
|
buildBundlePostlude(): [string, number] {
|
|
78
77
|
let res = '';
|
|
79
78
|
let lines = 0;
|
|
80
|
-
let exportSpecifiers = [];
|
|
79
|
+
let exportSpecifiers: Array<string> = [];
|
|
81
80
|
for (let {
|
|
82
81
|
asset,
|
|
83
82
|
exportSymbol,
|