@parcel/packager-js 2.0.0-canary.1543 → 2.0.0-dev.1425
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/lib/ScopeHoistingPackager.js +4 -4
- package/lib/index.js +16 -17
- package/package.json +8 -8
- package/src/ScopeHoistingPackager.js +3 -4
- package/src/index.js +19 -14
|
@@ -520,7 +520,7 @@ ${code}
|
|
|
520
520
|
let replacements = new Map();
|
|
521
521
|
for (let dep of deps) {
|
|
522
522
|
let specifierType = dep.specifierType === 'esm' ? `:${dep.specifierType}` : '';
|
|
523
|
-
depMap.get(`${assetId}:${(0, _utils2.getSpecifier)(dep)}${
|
|
523
|
+
depMap.get(`${assetId}:${(0, _utils2.getSpecifier)(dep)}${dep.meta.isESM ? specifierType : ''}`).push(dep);
|
|
524
524
|
let asyncResolution = this.bundleGraph.resolveAsyncDependency(dep, this.bundle);
|
|
525
525
|
let resolved = (asyncResolution === null || asyncResolution === void 0 ? void 0 : asyncResolution.type) === 'asset' ?
|
|
526
526
|
// Prefer the underlying asset over a runtime to load it. It will
|
|
@@ -732,7 +732,7 @@ ${code}
|
|
|
732
732
|
|
|
733
733
|
// If this is an ESM default import of a CJS module with a `default` symbol,
|
|
734
734
|
// and no __esModule flag, we need to resolve to the namespace instead.
|
|
735
|
-
let isDefaultInterop = exportSymbol === 'default' && staticExports && !isWrapped && (
|
|
735
|
+
let isDefaultInterop = exportSymbol === 'default' && staticExports && !isWrapped && (dep === null || dep === void 0 ? void 0 : dep.meta.isESM) && resolvedAsset.symbols.hasExportSymbol('*') && resolvedAsset.symbols.hasExportSymbol('default') && !resolvedAsset.symbols.hasExportSymbol('__esModule');
|
|
736
736
|
|
|
737
737
|
// Find the namespace object for the resolved module. If wrapped and this
|
|
738
738
|
// is an inline require (not top-level), use a parcelRequire call, otherwise
|
|
@@ -760,12 +760,12 @@ ${code}
|
|
|
760
760
|
return obj;
|
|
761
761
|
}
|
|
762
762
|
} else if ((!staticExports || isWrapped || !symbol || isExternalCommonJS) && resolvedAsset !== parentAsset) {
|
|
763
|
+
var _dep$meta;
|
|
763
764
|
// If the resolved asset is wrapped or has non-static exports,
|
|
764
765
|
// we need to use a member access off the namespace object rather
|
|
765
766
|
// than a direct reference. If importing default from a CJS module,
|
|
766
767
|
// use a helper to check the __esModule flag at runtime.
|
|
767
|
-
|
|
768
|
-
if ((!dep || kind === 'Import' || kind === 'Export') && exportSymbol === 'default' && resolvedAsset.symbols.hasExportSymbol('*') && this.needsDefaultInterop(resolvedAsset)) {
|
|
768
|
+
if ((!dep || (_dep$meta = dep.meta) !== null && _dep$meta !== void 0 && _dep$meta.isESM) && exportSymbol === 'default' && resolvedAsset.symbols.hasExportSymbol('*') && this.needsDefaultInterop(resolvedAsset)) {
|
|
769
769
|
this.usedHelpers.add('$parcel$interopDefault');
|
|
770
770
|
return `(/*@__PURE__*/$parcel$interopDefault(${obj}))`;
|
|
771
771
|
} else {
|
package/lib/index.js
CHANGED
|
@@ -32,13 +32,6 @@ function _rust() {
|
|
|
32
32
|
};
|
|
33
33
|
return data;
|
|
34
34
|
}
|
|
35
|
-
function _path() {
|
|
36
|
-
const data = _interopRequireDefault(require("path"));
|
|
37
|
-
_path = function () {
|
|
38
|
-
return data;
|
|
39
|
-
};
|
|
40
|
-
return data;
|
|
41
|
-
}
|
|
42
35
|
function _nullthrows() {
|
|
43
36
|
const data = _interopRequireDefault(require("nullthrows"));
|
|
44
37
|
_nullthrows = function () {
|
|
@@ -63,23 +56,29 @@ var _default = exports.default = new (_plugin().Packager)({
|
|
|
63
56
|
config,
|
|
64
57
|
options
|
|
65
58
|
}) {
|
|
66
|
-
var
|
|
67
|
-
// Generate a name for the global parcelRequire function that is unique to this project.
|
|
68
|
-
// This allows multiple parcel builds to coexist on the same page.
|
|
69
|
-
let pkg = await config.getConfigFrom(_path().default.join(options.projectRoot, 'index'), ['package.json']);
|
|
59
|
+
var _packageName$contents, _packageName$contents2, _conf$contents;
|
|
70
60
|
let packageKey = '@parcel/packager-js';
|
|
71
|
-
|
|
61
|
+
let conf = await config.getConfigFrom(options.projectRoot + '/index', [], {
|
|
62
|
+
packageKey
|
|
63
|
+
});
|
|
64
|
+
if (conf !== null && conf !== void 0 && conf.contents) {
|
|
72
65
|
_utils().validateSchema.diagnostic(CONFIG_SCHEMA, {
|
|
73
|
-
data:
|
|
74
|
-
source: await options.inputFS.readFile(
|
|
75
|
-
filePath:
|
|
66
|
+
data: conf === null || conf === void 0 ? void 0 : conf.contents,
|
|
67
|
+
source: await options.inputFS.readFile(conf.filePath, 'utf8'),
|
|
68
|
+
filePath: conf.filePath,
|
|
76
69
|
prependKey: `/${(0, _diagnostic().encodeJSONKeyComponent)(packageKey)}`
|
|
77
70
|
}, packageKey, `Invalid config for ${packageKey}`);
|
|
78
71
|
}
|
|
79
|
-
|
|
72
|
+
|
|
73
|
+
// Generate a name for the global parcelRequire function that is unique to this project.
|
|
74
|
+
// This allows multiple parcel builds to coexist on the same page.
|
|
75
|
+
let packageName = await config.getConfigFrom(options.projectRoot + '/index', [], {
|
|
76
|
+
packageKey: 'name'
|
|
77
|
+
});
|
|
78
|
+
let name = (_packageName$contents = packageName === null || packageName === void 0 || (_packageName$contents2 = packageName.contents) === null || _packageName$contents2 === void 0 ? void 0 : _packageName$contents2.name) !== null && _packageName$contents !== void 0 ? _packageName$contents : '';
|
|
80
79
|
return {
|
|
81
80
|
parcelRequireName: 'parcelRequire' + (0, _rust().hashString)(name).slice(-4),
|
|
82
|
-
unstable_asyncBundleRuntime: Boolean(
|
|
81
|
+
unstable_asyncBundleRuntime: Boolean(conf === null || conf === void 0 || (_conf$contents = conf.contents) === null || _conf$contents === void 0 ? void 0 : _conf$contents.unstable_asyncBundleRuntime)
|
|
83
82
|
};
|
|
84
83
|
},
|
|
85
84
|
async package({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcel/packager-js",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-dev.1425+8b1749694",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -17,17 +17,17 @@
|
|
|
17
17
|
"source": "src/index.js",
|
|
18
18
|
"engines": {
|
|
19
19
|
"node": ">= 12.0.0",
|
|
20
|
-
"parcel": "^2.0.0-
|
|
20
|
+
"parcel": "^2.0.0-dev.1423+8b1749694"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@parcel/diagnostic": "2.0.0-
|
|
24
|
-
"@parcel/plugin": "2.0.0-
|
|
25
|
-
"@parcel/rust": "2.12.1-
|
|
23
|
+
"@parcel/diagnostic": "2.0.0-dev.1425+8b1749694",
|
|
24
|
+
"@parcel/plugin": "2.0.0-dev.1425+8b1749694",
|
|
25
|
+
"@parcel/rust": "2.12.1-dev.3262+8b1749694",
|
|
26
26
|
"@parcel/source-map": "^2.1.1",
|
|
27
|
-
"@parcel/types": "2.0.0-
|
|
28
|
-
"@parcel/utils": "2.0.0-
|
|
27
|
+
"@parcel/types": "2.0.0-dev.1425+8b1749694",
|
|
28
|
+
"@parcel/utils": "2.0.0-dev.1425+8b1749694",
|
|
29
29
|
"globals": "^13.2.0",
|
|
30
30
|
"nullthrows": "^1.1.1"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "8b1749694c0ef79cefdacad40bb90c869a93993a"
|
|
33
33
|
}
|
|
@@ -672,7 +672,7 @@ ${code}
|
|
|
672
672
|
depMap
|
|
673
673
|
.get(
|
|
674
674
|
`${assetId}:${getSpecifier(dep)}${
|
|
675
|
-
|
|
675
|
+
dep.meta.isESM ? specifierType : ''
|
|
676
676
|
}`,
|
|
677
677
|
)
|
|
678
678
|
.push(dep);
|
|
@@ -985,7 +985,7 @@ ${code}
|
|
|
985
985
|
exportSymbol === 'default' &&
|
|
986
986
|
staticExports &&
|
|
987
987
|
!isWrapped &&
|
|
988
|
-
|
|
988
|
+
dep?.meta.isESM &&
|
|
989
989
|
resolvedAsset.symbols.hasExportSymbol('*') &&
|
|
990
990
|
resolvedAsset.symbols.hasExportSymbol('default') &&
|
|
991
991
|
!resolvedAsset.symbols.hasExportSymbol('__esModule');
|
|
@@ -1026,9 +1026,8 @@ ${code}
|
|
|
1026
1026
|
// we need to use a member access off the namespace object rather
|
|
1027
1027
|
// than a direct reference. If importing default from a CJS module,
|
|
1028
1028
|
// use a helper to check the __esModule flag at runtime.
|
|
1029
|
-
let kind = dep?.meta.kind;
|
|
1030
1029
|
if (
|
|
1031
|
-
(!dep ||
|
|
1030
|
+
(!dep || dep.meta?.isESM) &&
|
|
1032
1031
|
exportSymbol === 'default' &&
|
|
1033
1032
|
resolvedAsset.symbols.hasExportSymbol('*') &&
|
|
1034
1033
|
this.needsDefaultInterop(resolvedAsset)
|
package/src/index.js
CHANGED
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
} from '@parcel/utils';
|
|
11
11
|
import {encodeJSONKeyComponent} from '@parcel/diagnostic';
|
|
12
12
|
import {hashString} from '@parcel/rust';
|
|
13
|
-
import path from 'path';
|
|
14
13
|
import nullthrows from 'nullthrows';
|
|
15
14
|
import {DevPackager} from './DevPackager';
|
|
16
15
|
import {ScopeHoistingPackager} from './ScopeHoistingPackager';
|
|
@@ -32,22 +31,18 @@ const CONFIG_SCHEMA: SchemaEntity = {
|
|
|
32
31
|
|
|
33
32
|
export default (new Packager({
|
|
34
33
|
async loadConfig({config, options}): Promise<JSPackagerConfig> {
|
|
35
|
-
// Generate a name for the global parcelRequire function that is unique to this project.
|
|
36
|
-
// This allows multiple parcel builds to coexist on the same page.
|
|
37
|
-
let pkg = await config.getConfigFrom(
|
|
38
|
-
path.join(options.projectRoot, 'index'),
|
|
39
|
-
['package.json'],
|
|
40
|
-
);
|
|
41
|
-
|
|
42
34
|
let packageKey = '@parcel/packager-js';
|
|
35
|
+
let conf = await config.getConfigFrom(options.projectRoot + '/index', [], {
|
|
36
|
+
packageKey,
|
|
37
|
+
});
|
|
43
38
|
|
|
44
|
-
if (
|
|
39
|
+
if (conf?.contents) {
|
|
45
40
|
validateSchema.diagnostic(
|
|
46
41
|
CONFIG_SCHEMA,
|
|
47
42
|
{
|
|
48
|
-
data:
|
|
49
|
-
source: await options.inputFS.readFile(
|
|
50
|
-
filePath:
|
|
43
|
+
data: conf?.contents,
|
|
44
|
+
source: await options.inputFS.readFile(conf.filePath, 'utf8'),
|
|
45
|
+
filePath: conf.filePath,
|
|
51
46
|
prependKey: `/${encodeJSONKeyComponent(packageKey)}`,
|
|
52
47
|
},
|
|
53
48
|
packageKey,
|
|
@@ -55,11 +50,21 @@ export default (new Packager({
|
|
|
55
50
|
);
|
|
56
51
|
}
|
|
57
52
|
|
|
58
|
-
|
|
53
|
+
// Generate a name for the global parcelRequire function that is unique to this project.
|
|
54
|
+
// This allows multiple parcel builds to coexist on the same page.
|
|
55
|
+
let packageName = await config.getConfigFrom(
|
|
56
|
+
options.projectRoot + '/index',
|
|
57
|
+
[],
|
|
58
|
+
{
|
|
59
|
+
packageKey: 'name',
|
|
60
|
+
},
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
let name = packageName?.contents?.name ?? '';
|
|
59
64
|
return {
|
|
60
65
|
parcelRequireName: 'parcelRequire' + hashString(name).slice(-4),
|
|
61
66
|
unstable_asyncBundleRuntime: Boolean(
|
|
62
|
-
|
|
67
|
+
conf?.contents?.unstable_asyncBundleRuntime,
|
|
63
68
|
),
|
|
64
69
|
};
|
|
65
70
|
},
|