@jsenv/core 40.0.4 → 40.0.6
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/dist/js/build.js
CHANGED
|
@@ -1859,11 +1859,10 @@ const jsenvPluginSubbuilds = (
|
|
|
1859
1859
|
},
|
|
1860
1860
|
fetchUrlContent: async (urlInfo) => {
|
|
1861
1861
|
if (!entryPointBuildUrlSet.has(urlInfo.url)) {
|
|
1862
|
-
return
|
|
1862
|
+
return;
|
|
1863
1863
|
}
|
|
1864
1864
|
await buildPromise;
|
|
1865
1865
|
urlInfo.typeHint = "asset"; // this ensure the rest of jsenv do not scan or modify the content of this file
|
|
1866
|
-
return null;
|
|
1867
1866
|
},
|
|
1868
1867
|
};
|
|
1869
1868
|
});
|
|
@@ -9359,8 +9359,9 @@ const rollupPluginJsenv = ({
|
|
|
9359
9359
|
buildDirectoryUrl,
|
|
9360
9360
|
graph,
|
|
9361
9361
|
jsModuleUrlInfos,
|
|
9362
|
-
sourcemaps,
|
|
9363
9362
|
|
|
9363
|
+
runtimeCompat,
|
|
9364
|
+
sourcemaps,
|
|
9364
9365
|
include,
|
|
9365
9366
|
preserveDynamicImport,
|
|
9366
9367
|
augmentDynamicImportUrlSearchParams,
|
|
@@ -9414,6 +9415,94 @@ const rollupPluginJsenv = ({
|
|
|
9414
9415
|
return new URL(rollupFileInfo.fileName, buildDirectoryUrl).href;
|
|
9415
9416
|
};
|
|
9416
9417
|
|
|
9418
|
+
const packageSideEffectsCacheMap = new Map();
|
|
9419
|
+
const readClosestPackageJsonSideEffects = (url) => {
|
|
9420
|
+
const packageDirectoryUrl = lookupPackageDirectory(url);
|
|
9421
|
+
if (!packageDirectoryUrl) {
|
|
9422
|
+
return undefined;
|
|
9423
|
+
}
|
|
9424
|
+
const fromCache = packageSideEffectsCacheMap.get(packageDirectoryUrl);
|
|
9425
|
+
if (fromCache) {
|
|
9426
|
+
return fromCache.value;
|
|
9427
|
+
}
|
|
9428
|
+
try {
|
|
9429
|
+
const packageFileContent = readFileSync(
|
|
9430
|
+
new URL("./package.json", packageDirectoryUrl),
|
|
9431
|
+
"utf8",
|
|
9432
|
+
);
|
|
9433
|
+
const packageJSON = JSON.parse(packageFileContent);
|
|
9434
|
+
const value = packageJSON.sideEffects;
|
|
9435
|
+
if (Array.isArray(value)) {
|
|
9436
|
+
const sideEffectPatterns = {};
|
|
9437
|
+
for (const v of value) {
|
|
9438
|
+
sideEffectPatterns[v] = true;
|
|
9439
|
+
}
|
|
9440
|
+
const associations = URL_META.resolveAssociations(
|
|
9441
|
+
{ sideEffects: sideEffectPatterns },
|
|
9442
|
+
packageDirectoryUrl,
|
|
9443
|
+
);
|
|
9444
|
+
const isMatching = (url) => {
|
|
9445
|
+
const meta = URL_META.applyAssociations({ url, associations });
|
|
9446
|
+
return meta.sideEffects || false;
|
|
9447
|
+
};
|
|
9448
|
+
packageSideEffectsCacheMap.set(packageDirectoryUrl, {
|
|
9449
|
+
value: isMatching,
|
|
9450
|
+
});
|
|
9451
|
+
} else {
|
|
9452
|
+
packageSideEffectsCacheMap.set(packageDirectoryUrl, { value });
|
|
9453
|
+
}
|
|
9454
|
+
return value;
|
|
9455
|
+
} catch {
|
|
9456
|
+
packageSideEffectsCacheMap.set(packageDirectoryUrl, { value: undefined });
|
|
9457
|
+
return undefined;
|
|
9458
|
+
}
|
|
9459
|
+
};
|
|
9460
|
+
const nodeRuntimeEnabled = Object.keys(runtimeCompat).includes("node");
|
|
9461
|
+
const packageConditions = [nodeRuntimeEnabled ? "node" : "browser", "import"];
|
|
9462
|
+
const inferSideEffectsFromResolvedUrl = (url) => {
|
|
9463
|
+
if (url.startsWith("ignore:")) {
|
|
9464
|
+
// console.log(`may have side effect: ${url}`);
|
|
9465
|
+
// double ignore we must keep the import
|
|
9466
|
+
return null;
|
|
9467
|
+
}
|
|
9468
|
+
if (isSpecifierForNodeBuiltin(url)) {
|
|
9469
|
+
return false;
|
|
9470
|
+
}
|
|
9471
|
+
const closestPackageJsonSideEffects =
|
|
9472
|
+
readClosestPackageJsonSideEffects(url);
|
|
9473
|
+
if (closestPackageJsonSideEffects === undefined) {
|
|
9474
|
+
// console.log(`may have side effect: ${url}`);
|
|
9475
|
+
return null;
|
|
9476
|
+
}
|
|
9477
|
+
if (typeof closestPackageJsonSideEffects === "function") {
|
|
9478
|
+
const haveSideEffect = closestPackageJsonSideEffects(url);
|
|
9479
|
+
// if (haveSideEffect) {
|
|
9480
|
+
// console.log(`have side effect: ${url}`);
|
|
9481
|
+
// }
|
|
9482
|
+
return haveSideEffect;
|
|
9483
|
+
}
|
|
9484
|
+
return closestPackageJsonSideEffects;
|
|
9485
|
+
};
|
|
9486
|
+
const getModuleSideEffects = (url, importer) => {
|
|
9487
|
+
if (!url.startsWith("ignore:")) {
|
|
9488
|
+
return inferSideEffectsFromResolvedUrl(url);
|
|
9489
|
+
}
|
|
9490
|
+
url = url.slice("ignore:".length);
|
|
9491
|
+
if (url.startsWith("file:")) {
|
|
9492
|
+
return inferSideEffectsFromResolvedUrl(url);
|
|
9493
|
+
}
|
|
9494
|
+
try {
|
|
9495
|
+
const result = applyNodeEsmResolution({
|
|
9496
|
+
conditions: packageConditions,
|
|
9497
|
+
parentUrl: importer,
|
|
9498
|
+
specifier: url,
|
|
9499
|
+
});
|
|
9500
|
+
return inferSideEffectsFromResolvedUrl(result.url);
|
|
9501
|
+
} catch {
|
|
9502
|
+
return null;
|
|
9503
|
+
}
|
|
9504
|
+
};
|
|
9505
|
+
|
|
9417
9506
|
return {
|
|
9418
9507
|
name: "jsenv",
|
|
9419
9508
|
async buildStart() {
|
|
@@ -9650,22 +9739,43 @@ const rollupPluginJsenv = ({
|
|
|
9650
9739
|
} else {
|
|
9651
9740
|
url = new URL(specifier, importer).href;
|
|
9652
9741
|
}
|
|
9742
|
+
|
|
9653
9743
|
if (!url.startsWith("file:")) {
|
|
9654
|
-
return {
|
|
9744
|
+
return {
|
|
9745
|
+
id: url,
|
|
9746
|
+
external: true,
|
|
9747
|
+
moduleSideEffects: getModuleSideEffects(url, importer),
|
|
9748
|
+
};
|
|
9655
9749
|
}
|
|
9656
9750
|
if (!importCanBeBundled(url)) {
|
|
9657
|
-
return {
|
|
9751
|
+
return {
|
|
9752
|
+
id: url,
|
|
9753
|
+
external: true,
|
|
9754
|
+
moduleSideEffects: getModuleSideEffects(url, importer),
|
|
9755
|
+
};
|
|
9658
9756
|
}
|
|
9659
9757
|
const urlInfo = graph.getUrlInfo(url);
|
|
9660
9758
|
if (!urlInfo) {
|
|
9661
9759
|
// happen when excluded by referenceAnalysis.include
|
|
9662
|
-
return {
|
|
9760
|
+
return {
|
|
9761
|
+
id: url,
|
|
9762
|
+
external: true,
|
|
9763
|
+
moduleSideEffects: getModuleSideEffects(url, importer),
|
|
9764
|
+
};
|
|
9663
9765
|
}
|
|
9664
9766
|
if (url.startsWith("ignore:")) {
|
|
9665
|
-
return {
|
|
9767
|
+
return {
|
|
9768
|
+
id: url,
|
|
9769
|
+
external: true,
|
|
9770
|
+
moduleSideEffects: getModuleSideEffects(url, importer),
|
|
9771
|
+
};
|
|
9666
9772
|
}
|
|
9667
9773
|
const filePath = fileUrlConverter.asFilePath(url);
|
|
9668
|
-
return
|
|
9774
|
+
return {
|
|
9775
|
+
id: filePath,
|
|
9776
|
+
external: false,
|
|
9777
|
+
moduleSideEffects: getModuleSideEffects(url, importer),
|
|
9778
|
+
};
|
|
9669
9779
|
},
|
|
9670
9780
|
async load(rollupId) {
|
|
9671
9781
|
const fileUrl = fileUrlConverter.asFileUrl(rollupId);
|
|
@@ -9693,81 +9803,10 @@ const applyRollupPlugins = async ({
|
|
|
9693
9803
|
rollup = rollupModule.rollup;
|
|
9694
9804
|
}
|
|
9695
9805
|
|
|
9696
|
-
const packageSideEffectsCacheMap = new Map();
|
|
9697
|
-
const readClosestPackageJsonSideEffects = (url) => {
|
|
9698
|
-
const packageDirectoryUrl = lookupPackageDirectory(url);
|
|
9699
|
-
if (!packageDirectoryUrl) {
|
|
9700
|
-
return undefined;
|
|
9701
|
-
}
|
|
9702
|
-
const fromCache = packageSideEffectsCacheMap.get(packageDirectoryUrl);
|
|
9703
|
-
if (fromCache) {
|
|
9704
|
-
return fromCache.value;
|
|
9705
|
-
}
|
|
9706
|
-
try {
|
|
9707
|
-
const packageFileContent = readFileSync(
|
|
9708
|
-
new URL("./package.json", packageDirectoryUrl),
|
|
9709
|
-
"utf8",
|
|
9710
|
-
);
|
|
9711
|
-
const packageJSON = JSON.parse(packageFileContent);
|
|
9712
|
-
const value = packageJSON.sideEffects;
|
|
9713
|
-
if (Array.isArray(value)) {
|
|
9714
|
-
const sideEffectPatterns = {};
|
|
9715
|
-
for (const v of value) {
|
|
9716
|
-
sideEffectPatterns[v] = true;
|
|
9717
|
-
}
|
|
9718
|
-
const associations = URL_META.resolveAssociations(
|
|
9719
|
-
{ sideEffects: sideEffectPatterns },
|
|
9720
|
-
packageDirectoryUrl,
|
|
9721
|
-
);
|
|
9722
|
-
const isMatching = (url) => {
|
|
9723
|
-
const meta = URL_META.applyAssociations({ url, associations });
|
|
9724
|
-
return meta.sideEffects || false;
|
|
9725
|
-
};
|
|
9726
|
-
packageSideEffectsCacheMap.set(packageDirectoryUrl, {
|
|
9727
|
-
value: isMatching,
|
|
9728
|
-
});
|
|
9729
|
-
} else {
|
|
9730
|
-
packageSideEffectsCacheMap.set(packageDirectoryUrl, { value });
|
|
9731
|
-
}
|
|
9732
|
-
return value;
|
|
9733
|
-
} catch {
|
|
9734
|
-
packageSideEffectsCacheMap.set(packageDirectoryUrl, { value: undefined });
|
|
9735
|
-
return undefined;
|
|
9736
|
-
}
|
|
9737
|
-
};
|
|
9738
|
-
|
|
9739
9806
|
const rollupReturnValue = await rollup({
|
|
9740
9807
|
...rollupInput,
|
|
9741
9808
|
treeshake: {
|
|
9742
9809
|
...rollupInput.treeshake,
|
|
9743
|
-
moduleSideEffects: (id, external) => {
|
|
9744
|
-
if (id.startsWith("ignore:node:")) {
|
|
9745
|
-
return false;
|
|
9746
|
-
}
|
|
9747
|
-
if (isSpecifierForNodeBuiltin(id)) {
|
|
9748
|
-
return false;
|
|
9749
|
-
}
|
|
9750
|
-
if (id.startsWith("ignore:")) {
|
|
9751
|
-
return null;
|
|
9752
|
-
}
|
|
9753
|
-
const url = id.startsWith("file:") ? id : fileSystemPathToUrl(id);
|
|
9754
|
-
const closestPackageJsonSideEffects =
|
|
9755
|
-
readClosestPackageJsonSideEffects(url);
|
|
9756
|
-
if (closestPackageJsonSideEffects !== undefined) {
|
|
9757
|
-
if (typeof closestPackageJsonSideEffects === "function") {
|
|
9758
|
-
return closestPackageJsonSideEffects(url);
|
|
9759
|
-
}
|
|
9760
|
-
return closestPackageJsonSideEffects;
|
|
9761
|
-
}
|
|
9762
|
-
const moduleSideEffects = rollupInput.treeshake?.moduleSideEffects;
|
|
9763
|
-
if (moduleSideEffects) {
|
|
9764
|
-
if (typeof moduleSideEffects === "function") {
|
|
9765
|
-
return moduleSideEffects(id, external);
|
|
9766
|
-
}
|
|
9767
|
-
return moduleSideEffects;
|
|
9768
|
-
}
|
|
9769
|
-
return null;
|
|
9770
|
-
},
|
|
9771
9810
|
},
|
|
9772
9811
|
plugins: rollupPlugins,
|
|
9773
9812
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/core",
|
|
3
|
-
"version": "40.0.
|
|
3
|
+
"version": "40.0.6",
|
|
4
4
|
"description": "Tool to develop, test and build js projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"@jsenv/integrity": "0.0.2",
|
|
86
86
|
"@jsenv/js-module-fallback": "1.4.3",
|
|
87
87
|
"@jsenv/node-esm-resolution": "1.1.0",
|
|
88
|
-
"@jsenv/plugin-bundling": "2.8.
|
|
88
|
+
"@jsenv/plugin-bundling": "2.8.3",
|
|
89
89
|
"@jsenv/plugin-minification": "1.6.2",
|
|
90
90
|
"@jsenv/plugin-supervisor": "1.6.10",
|
|
91
91
|
"@jsenv/plugin-transpilation": "1.5.6",
|
|
@@ -60,11 +60,10 @@ export const jsenvPluginSubbuilds = (
|
|
|
60
60
|
},
|
|
61
61
|
fetchUrlContent: async (urlInfo) => {
|
|
62
62
|
if (!entryPointBuildUrlSet.has(urlInfo.url)) {
|
|
63
|
-
return
|
|
63
|
+
return;
|
|
64
64
|
}
|
|
65
65
|
await buildPromise;
|
|
66
66
|
urlInfo.typeHint = "asset"; // this ensure the rest of jsenv do not scan or modify the content of this file
|
|
67
|
-
return null;
|
|
68
67
|
},
|
|
69
68
|
};
|
|
70
69
|
});
|
|
File without changes
|