@atlaspack/packager-js 2.14.5-canary.22 → 2.14.5-canary.220
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 +358 -0
- package/dist/CJSOutputFormat.js +34 -0
- package/dist/DevPackager.js +202 -0
- package/dist/ESMOutputFormat.js +102 -0
- package/dist/GlobalOutputFormat.js +18 -0
- package/dist/ScopeHoistingPackager.js +1365 -0
- package/dist/helpers.js +170 -0
- package/dist/index.js +105 -0
- package/dist/utils.js +60 -0
- package/lib/DevPackager.js +28 -3
- package/lib/ESMOutputFormat.js +1 -1
- package/lib/ScopeHoistingPackager.js +257 -106
- package/lib/dev-prelude.js +6 -6
- package/lib/helpers.js +38 -3
- package/lib/index.js +3 -3
- 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 +66 -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 +17 -12
- package/src/{CJSOutputFormat.js → CJSOutputFormat.ts} +0 -1
- package/src/{DevPackager.js → DevPackager.ts} +34 -7
- package/src/{ESMOutputFormat.js → ESMOutputFormat.ts} +3 -4
- package/src/{GlobalOutputFormat.js → GlobalOutputFormat.ts} +0 -1
- package/src/{ScopeHoistingPackager.js → ScopeHoistingPackager.ts} +411 -176
- package/src/dev-prelude.js +6 -6
- package/src/{helpers.js → helpers.ts} +37 -3
- package/src/{index.js → index.ts} +21 -17
- package/src/{utils.js → utils.ts} +1 -2
- package/tsconfig.json +27 -0
- package/tsconfig.tsbuildinfo +1 -0
package/src/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
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
// @flow strict-local
|
|
2
1
|
import type {Environment} from '@atlaspack/types';
|
|
3
2
|
|
|
4
|
-
export const
|
|
3
|
+
export const preludeOld = (parcelRequireName: string): string => `
|
|
5
4
|
var $parcel$modules = {};
|
|
6
5
|
var $parcel$inits = {};
|
|
7
6
|
|
|
@@ -35,6 +34,41 @@ if (parcelRequire == null) {
|
|
|
35
34
|
var parcelRegister = parcelRequire.register;
|
|
36
35
|
`;
|
|
37
36
|
|
|
37
|
+
export const preludeNew = (parcelRequireName: string): string => `
|
|
38
|
+
var $parcel$modules = {};
|
|
39
|
+
var $parcel$inits = {};
|
|
40
|
+
|
|
41
|
+
var parcelRequire = $parcel$global[${JSON.stringify(parcelRequireName)}];
|
|
42
|
+
|
|
43
|
+
if (parcelRequire == null) {
|
|
44
|
+
parcelRequire = function(id) {
|
|
45
|
+
var mod = $parcel$modules[id];
|
|
46
|
+
if (mod !== undefined) {
|
|
47
|
+
return mod.exports;
|
|
48
|
+
}
|
|
49
|
+
var init = $parcel$inits[id];
|
|
50
|
+
if (init !== undefined) {
|
|
51
|
+
delete $parcel$inits[id];
|
|
52
|
+
var module = {id: id, exports: {}};
|
|
53
|
+
$parcel$modules[id] = module;
|
|
54
|
+
init.call(module.exports, module, module.exports);
|
|
55
|
+
return module.exports;
|
|
56
|
+
}
|
|
57
|
+
var err = new Error("Cannot find module '" + id + "'");
|
|
58
|
+
err.code = 'MODULE_NOT_FOUND';
|
|
59
|
+
throw err;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
parcelRequire.register = function register(id, init) {
|
|
63
|
+
$parcel$inits[id] = init;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
$parcel$global[${JSON.stringify(parcelRequireName)}] = parcelRequire;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
var parcelRegister = parcelRequire.register;
|
|
70
|
+
`;
|
|
71
|
+
|
|
38
72
|
export const fnExpr = (
|
|
39
73
|
env: Environment,
|
|
40
74
|
params: Array<string>,
|
|
@@ -166,4 +200,4 @@ export const helpers = {
|
|
|
166
200
|
$parcel$interopDefault,
|
|
167
201
|
$parcel$global,
|
|
168
202
|
$parcel$defineInteropFlag,
|
|
169
|
-
};
|
|
203
|
+
} as const;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @flow strict-local
|
|
2
1
|
import type {Async} from '@atlaspack/types';
|
|
3
2
|
import type SourceMap from '@parcel/source-map';
|
|
4
3
|
import {Packager} from '@atlaspack/plugin';
|
|
@@ -6,7 +5,7 @@ import {
|
|
|
6
5
|
replaceInlineReferences,
|
|
7
6
|
replaceURLReferences,
|
|
8
7
|
validateSchema,
|
|
9
|
-
|
|
8
|
+
SchemaEntity,
|
|
10
9
|
} from '@atlaspack/utils';
|
|
11
10
|
import {encodeJSONKeyComponent} from '@atlaspack/diagnostic';
|
|
12
11
|
import {hashString} from '@atlaspack/rust';
|
|
@@ -14,11 +13,11 @@ import nullthrows from 'nullthrows';
|
|
|
14
13
|
import {DevPackager} from './DevPackager';
|
|
15
14
|
import {ScopeHoistingPackager} from './ScopeHoistingPackager';
|
|
16
15
|
|
|
17
|
-
type JSPackagerConfig = {
|
|
18
|
-
parcelRequireName: string
|
|
19
|
-
unstable_asyncBundleRuntime: boolean
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
type JSPackagerConfig = {
|
|
17
|
+
parcelRequireName: string;
|
|
18
|
+
unstable_asyncBundleRuntime: boolean;
|
|
19
|
+
unstable_manualStaticBindingExports: string[] | null;
|
|
20
|
+
};
|
|
22
21
|
|
|
23
22
|
const CONFIG_SCHEMA: SchemaEntity = {
|
|
24
23
|
type: 'object',
|
|
@@ -26,7 +25,7 @@ const CONFIG_SCHEMA: SchemaEntity = {
|
|
|
26
25
|
unstable_asyncBundleRuntime: {
|
|
27
26
|
type: 'boolean',
|
|
28
27
|
},
|
|
29
|
-
|
|
28
|
+
unstable_manualStaticBindingExports: {
|
|
30
29
|
type: 'array',
|
|
31
30
|
items: {
|
|
32
31
|
type: 'string',
|
|
@@ -36,10 +35,13 @@ const CONFIG_SCHEMA: SchemaEntity = {
|
|
|
36
35
|
additionalProperties: false,
|
|
37
36
|
};
|
|
38
37
|
|
|
39
|
-
export default
|
|
38
|
+
export default new Packager({
|
|
40
39
|
async loadConfig({config, options}): Promise<JSPackagerConfig> {
|
|
41
40
|
let packageKey = '@atlaspack/packager-js';
|
|
42
|
-
let conf = await config.getConfigFrom
|
|
41
|
+
let conf = await config.getConfigFrom<{
|
|
42
|
+
unstable_asyncBundleRuntime?: boolean;
|
|
43
|
+
unstable_manualStaticBindingExports?: string[];
|
|
44
|
+
}>(options.projectRoot + '/index', [], {
|
|
43
45
|
packageKey,
|
|
44
46
|
});
|
|
45
47
|
|
|
@@ -59,7 +61,7 @@ export default (new Packager({
|
|
|
59
61
|
|
|
60
62
|
// Generate a name for the global parcelRequire function that is unique to this project.
|
|
61
63
|
// This allows multiple parcel builds to coexist on the same page.
|
|
62
|
-
let packageName = await config.getConfigFrom(
|
|
64
|
+
let packageName = await config.getConfigFrom<string>(
|
|
63
65
|
options.projectRoot + '/index',
|
|
64
66
|
[],
|
|
65
67
|
{
|
|
@@ -73,8 +75,8 @@ export default (new Packager({
|
|
|
73
75
|
unstable_asyncBundleRuntime: Boolean(
|
|
74
76
|
conf?.contents?.unstable_asyncBundleRuntime,
|
|
75
77
|
),
|
|
76
|
-
|
|
77
|
-
conf?.contents?.
|
|
78
|
+
unstable_manualStaticBindingExports:
|
|
79
|
+
conf?.contents?.unstable_manualStaticBindingExports ?? null,
|
|
78
80
|
};
|
|
79
81
|
},
|
|
80
82
|
async package({
|
|
@@ -108,7 +110,7 @@ export default (new Packager({
|
|
|
108
110
|
bundle,
|
|
109
111
|
nullthrows(config).parcelRequireName,
|
|
110
112
|
nullthrows(config).unstable_asyncBundleRuntime,
|
|
111
|
-
nullthrows(config).
|
|
113
|
+
nullthrows(config).unstable_manualStaticBindingExports,
|
|
112
114
|
logger,
|
|
113
115
|
)
|
|
114
116
|
: new DevPackager(
|
|
@@ -147,11 +149,13 @@ export default (new Packager({
|
|
|
147
149
|
map,
|
|
148
150
|
});
|
|
149
151
|
},
|
|
150
|
-
})
|
|
152
|
+
}) as Packager<unknown, unknown>;
|
|
151
153
|
|
|
152
154
|
async function getSourceMapSuffix(
|
|
153
|
-
getSourceMapReference: (
|
|
154
|
-
|
|
155
|
+
getSourceMapReference: (
|
|
156
|
+
arg1?: SourceMap | null | undefined,
|
|
157
|
+
) => Async<string | null | undefined>,
|
|
158
|
+
map?: SourceMap | null,
|
|
155
159
|
): Promise<string> {
|
|
156
160
|
let sourcemapReference = await getSourceMapReference(map);
|
|
157
161
|
if (sourcemapReference != null) {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
import type {BundleGraph, Dependency, NamedBundle} from '@atlaspack/types';
|
|
3
2
|
import type SourceMap from '@parcel/source-map';
|
|
4
3
|
import nullthrows from 'nullthrows';
|
|
@@ -10,7 +9,7 @@ export function replaceScriptDependencies(
|
|
|
10
9
|
bundleGraph: BundleGraph<NamedBundle>,
|
|
11
10
|
bundle: NamedBundle,
|
|
12
11
|
code: string,
|
|
13
|
-
map:
|
|
12
|
+
map: SourceMap | null | undefined,
|
|
14
13
|
parcelRequireName: string,
|
|
15
14
|
): string {
|
|
16
15
|
let entry = nullthrows(bundle.getMainEntry());
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../../tsconfig.base.json",
|
|
3
|
+
"include": ["src"],
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"composite": true
|
|
6
|
+
},
|
|
7
|
+
"references": [
|
|
8
|
+
{
|
|
9
|
+
"path": "../../core/diagnostic/tsconfig.json"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"path": "../../core/feature-flags/tsconfig.json"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"path": "../../core/plugin/tsconfig.json"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"path": "../../core/rust/tsconfig.json"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"path": "../../core/types/tsconfig.json"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"path": "../../core/utils/tsconfig.json"
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
}
|