@jsenv/plugin-bundling 2.8.1 → 2.8.2
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/plugin-bundling",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@jsenv/humanize": "1.3.1",
|
|
26
26
|
"@jsenv/url-meta": "8.5.4",
|
|
27
|
-
"@jsenv/urls": "2.6.
|
|
28
|
-
"@jsenv/sourcemap": "1.3.
|
|
27
|
+
"@jsenv/urls": "2.6.3",
|
|
28
|
+
"@jsenv/sourcemap": "1.3.2",
|
|
29
29
|
"lightningcss": "1.29.2",
|
|
30
30
|
"rollup": "4.35.0"
|
|
31
31
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { lookupPackageDirectory } from "@jsenv/filesystem";
|
|
1
|
+
import { lookupPackageDirectory, readPackageAtOrNull } from "@jsenv/filesystem";
|
|
2
2
|
import { createDetailedMessage } from "@jsenv/humanize";
|
|
3
3
|
import { isSpecifierForNodeBuiltin } from "@jsenv/node-esm-resolution/src/node_builtin_specifiers.js";
|
|
4
4
|
import { sourcemapConverter } from "@jsenv/sourcemap";
|
|
@@ -38,44 +38,44 @@ export const bundleJsModules = async (
|
|
|
38
38
|
|
|
39
39
|
let manualChunks;
|
|
40
40
|
if (chunks) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"file:///**/node_modules/": true,
|
|
44
|
-
...chunks.vendors,
|
|
45
|
-
};
|
|
46
|
-
} else {
|
|
47
|
-
chunks.vendors = {
|
|
48
|
-
"file:///**/node_modules/": true,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
41
|
+
let workspaces;
|
|
42
|
+
let packageName;
|
|
51
43
|
const packageDirectoryUrl = lookupPackageDirectory(rootDirectoryUrl);
|
|
52
44
|
if (packageDirectoryUrl) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
45
|
+
const packageJSON = readPackageAtOrNull(packageDirectoryUrl);
|
|
46
|
+
if (packageJSON) {
|
|
47
|
+
packageName = packageJSON.name;
|
|
48
|
+
workspaces = packageJSON.workspaces;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
let nodeModuleChunkName = "node_modules";
|
|
52
|
+
let packagesChunkName = "packages";
|
|
53
|
+
|
|
54
|
+
if (packageName) {
|
|
55
|
+
let packageNameAsFilename = packageName
|
|
56
|
+
.replaceAll("@", "")
|
|
57
|
+
.replaceAll("-", "_")
|
|
58
|
+
.replaceAll("/", "_");
|
|
59
|
+
nodeModuleChunkName = `${packageNameAsFilename}_node_modules`;
|
|
60
|
+
packagesChunkName = `${packageNameAsFilename}_packages`;
|
|
61
|
+
}
|
|
62
|
+
chunks[nodeModuleChunkName] = {
|
|
63
|
+
"file:///**/node_modules/": true,
|
|
64
|
+
...chunks.vendors,
|
|
65
|
+
};
|
|
66
|
+
if (workspaces) {
|
|
67
|
+
const workspacePatterns = {};
|
|
68
|
+
for (const workspace of workspaces) {
|
|
69
|
+
const workspacePattern = new URL(
|
|
70
|
+
workspace.endsWith("/*") ? workspace.slice(0, -1) : workspace,
|
|
71
|
+
packageDirectoryUrl,
|
|
72
|
+
).href;
|
|
73
|
+
workspacePatterns[workspacePattern] = true;
|
|
74
|
+
}
|
|
75
|
+
chunks[packagesChunkName] = {
|
|
76
|
+
...workspacePatterns,
|
|
77
|
+
...chunks.workspaces,
|
|
78
|
+
};
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
const associations = URL_META.resolveAssociations(chunks, rootDirectoryUrl);
|
|
@@ -149,7 +149,8 @@ export const bundleJsModules = async (
|
|
|
149
149
|
}
|
|
150
150
|
if (
|
|
151
151
|
warning.code === "EMPTY_BUNDLE" &&
|
|
152
|
-
warning.names.join("")
|
|
152
|
+
(warning.names.join("").endsWith("node_modules") ||
|
|
153
|
+
warning.names.join("").endsWith("packages"))
|
|
153
154
|
) {
|
|
154
155
|
return;
|
|
155
156
|
}
|
|
@@ -226,7 +227,13 @@ const rollupPluginJsenv = ({
|
|
|
226
227
|
}
|
|
227
228
|
|
|
228
229
|
const getOriginalUrl = (rollupFileInfo) => {
|
|
229
|
-
if (
|
|
230
|
+
if (
|
|
231
|
+
// - explicitely emitted by emitChunk
|
|
232
|
+
// - import.meta.resolve("")
|
|
233
|
+
rollupFileInfo.isEntry ||
|
|
234
|
+
// - new URL("", import.meta.url)
|
|
235
|
+
rollupFileInfo.isImplicitEntry
|
|
236
|
+
) {
|
|
230
237
|
const { facadeModuleId } = rollupFileInfo;
|
|
231
238
|
if (facadeModuleId) {
|
|
232
239
|
return fileUrlConverter.asFileUrl(facadeModuleId);
|