@jsenv/plugin-bundling 1.2.1 → 2.0.0
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": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
"test": "node --conditions=development ./scripts/test.mjs"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@jsenv/babel-plugins": "1.1.
|
|
28
|
-
"@jsenv/log": "3.3.
|
|
29
|
-
"@jsenv/url-meta": "7.0
|
|
27
|
+
"@jsenv/babel-plugins": "1.1.5",
|
|
28
|
+
"@jsenv/log": "3.3.4",
|
|
29
|
+
"@jsenv/url-meta": "7.1.0",
|
|
30
30
|
"@jsenv/urls": "1.2.8",
|
|
31
|
-
"@jsenv/sourcemap": "1.0.
|
|
31
|
+
"@jsenv/sourcemap": "1.0.9",
|
|
32
32
|
"acorn-import-assertions": "1.8.0",
|
|
33
|
-
"lightningcss": "1.
|
|
34
|
-
"rollup": "3.
|
|
33
|
+
"lightningcss": "1.19.0",
|
|
34
|
+
"rollup": "3.19.1"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@jsenv/core": "*"
|
|
@@ -3,18 +3,22 @@ import { pathToFileURL } from "node:url"
|
|
|
3
3
|
import { URL_META } from "@jsenv/url-meta"
|
|
4
4
|
import { isFileSystemPath } from "@jsenv/urls"
|
|
5
5
|
import { createDetailedMessage } from "@jsenv/log"
|
|
6
|
-
import { babelHelperClientDirectoryUrl } from "@jsenv/babel-plugins"
|
|
7
6
|
import { sourcemapConverter } from "@jsenv/sourcemap"
|
|
8
|
-
import { newStylesheetClientFileUrl } from "@jsenv/core/src/plugins/transpilation/babel/new_stylesheet/babel_plugin_new_stylesheet_as_jsenv_import.js"
|
|
9
7
|
import { globalThisClientFileUrl } from "@jsenv/core/src/plugins/transpilation/babel/global_this/babel_plugin_global_this_as_jsenv_import.js"
|
|
10
|
-
import { regeneratorRuntimeClientFileUrl } from "@jsenv/core/src/plugins/transpilation/babel/regenerator_runtime/babel_plugin_regenerator_runtime_as_jsenv_import.js"
|
|
11
8
|
|
|
12
9
|
import { fileUrlConverter } from "./file_url_converter.js"
|
|
13
10
|
|
|
14
11
|
export const bundleJsModules = async ({
|
|
15
12
|
jsModuleUrlInfos,
|
|
16
13
|
context,
|
|
17
|
-
|
|
14
|
+
include,
|
|
15
|
+
chunks = {},
|
|
16
|
+
strictExports = false,
|
|
17
|
+
preserveDynamicImport = false,
|
|
18
|
+
rollup,
|
|
19
|
+
rollupInput = {},
|
|
20
|
+
rollupOutput = {},
|
|
21
|
+
rollupPlugins = [],
|
|
18
22
|
}) => {
|
|
19
23
|
const {
|
|
20
24
|
signal,
|
|
@@ -26,53 +30,10 @@ export const bundleJsModules = async ({
|
|
|
26
30
|
runtimeCompat,
|
|
27
31
|
sourcemaps,
|
|
28
32
|
} = context
|
|
29
|
-
const {
|
|
30
|
-
vendorsChunk = true,
|
|
31
|
-
babelHelpersChunk = true,
|
|
32
|
-
customChunks = {},
|
|
33
|
-
include,
|
|
34
|
-
preserveDynamicImport = false,
|
|
35
|
-
strictExports = false,
|
|
36
|
-
rollup,
|
|
37
|
-
rollupInput = {},
|
|
38
|
-
rollupOutput = {},
|
|
39
|
-
rollupPlugins = [],
|
|
40
|
-
} = options
|
|
41
|
-
|
|
42
|
-
const chunksAssociations = {
|
|
43
|
-
...(vendorsChunk
|
|
44
|
-
? {
|
|
45
|
-
vendors: {
|
|
46
|
-
"./**/node_modules/": true,
|
|
47
|
-
[newStylesheetClientFileUrl]: true,
|
|
48
|
-
[globalThisClientFileUrl]: true,
|
|
49
|
-
[regeneratorRuntimeClientFileUrl]: true,
|
|
50
|
-
},
|
|
51
|
-
}
|
|
52
|
-
: {}),
|
|
53
|
-
...(babelHelpersChunk
|
|
54
|
-
? {
|
|
55
|
-
babel_helpers: {
|
|
56
|
-
[babelHelperClientDirectoryUrl]: true,
|
|
57
|
-
[newStylesheetClientFileUrl]: true,
|
|
58
|
-
[globalThisClientFileUrl]: true,
|
|
59
|
-
[regeneratorRuntimeClientFileUrl]: true,
|
|
60
|
-
"./**/babel-plugin-transform-async-to-promises/helpers.mjs": true,
|
|
61
|
-
},
|
|
62
|
-
}
|
|
63
|
-
: {}),
|
|
64
|
-
...customChunks,
|
|
65
|
-
}
|
|
66
33
|
|
|
67
34
|
let manualChunks
|
|
68
|
-
if (
|
|
69
|
-
|
|
70
|
-
Object.keys(chunksAssociations).length
|
|
71
|
-
) {
|
|
72
|
-
const associations = URL_META.resolveAssociations(
|
|
73
|
-
chunksAssociations,
|
|
74
|
-
rootDirectoryUrl,
|
|
75
|
-
)
|
|
35
|
+
if (Object.keys(chunks).length) {
|
|
36
|
+
const associations = URL_META.resolveAssociations(chunks, rootDirectoryUrl)
|
|
76
37
|
manualChunks = (id) => {
|
|
77
38
|
if (rollupOutput.manualChunks) {
|
|
78
39
|
const manualChunkName = rollupOutput.manualChunks(id)
|
|
@@ -7,37 +7,40 @@ export const jsenvPluginBundling = ({
|
|
|
7
7
|
js_classic = {},
|
|
8
8
|
js_module = {},
|
|
9
9
|
} = {}) => {
|
|
10
|
+
const bundle = {}
|
|
11
|
+
|
|
12
|
+
if (css) {
|
|
13
|
+
bundle.css = (cssUrlInfos, context) => {
|
|
14
|
+
return bundleCss({
|
|
15
|
+
cssUrlInfos,
|
|
16
|
+
context,
|
|
17
|
+
})
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
if (js_classic) {
|
|
21
|
+
bundle.js_classic = (jsClassicUrlInfos, context) => {
|
|
22
|
+
return bundleJsClassicWorkers({
|
|
23
|
+
jsClassicUrlInfos,
|
|
24
|
+
context,
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (js_module) {
|
|
29
|
+
if (js_module === true) {
|
|
30
|
+
js_module = {}
|
|
31
|
+
}
|
|
32
|
+
bundle.js_module = (jsModuleUrlInfos, context) => {
|
|
33
|
+
return bundleJsModules({
|
|
34
|
+
jsModuleUrlInfos,
|
|
35
|
+
context,
|
|
36
|
+
...js_module,
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
10
41
|
return {
|
|
11
42
|
name: "jsenv:bundling",
|
|
12
43
|
appliesDuring: "build",
|
|
13
|
-
bundle
|
|
14
|
-
css: css
|
|
15
|
-
? (cssUrlInfos, context) => {
|
|
16
|
-
return bundleCss({
|
|
17
|
-
cssUrlInfos,
|
|
18
|
-
context,
|
|
19
|
-
options: css === true ? {} : css,
|
|
20
|
-
})
|
|
21
|
-
}
|
|
22
|
-
: undefined,
|
|
23
|
-
js_classic: js_classic
|
|
24
|
-
? (jsClassicUrlInfos, context) => {
|
|
25
|
-
return bundleJsClassicWorkers({
|
|
26
|
-
jsClassicUrlInfos,
|
|
27
|
-
context,
|
|
28
|
-
options: js_classic === true ? {} : js_classic,
|
|
29
|
-
})
|
|
30
|
-
}
|
|
31
|
-
: undefined,
|
|
32
|
-
js_module: js_module
|
|
33
|
-
? (jsModuleUrlInfos, context) => {
|
|
34
|
-
return bundleJsModules({
|
|
35
|
-
jsModuleUrlInfos,
|
|
36
|
-
context,
|
|
37
|
-
options: js_module === true ? {} : js_module,
|
|
38
|
-
})
|
|
39
|
-
}
|
|
40
|
-
: undefined,
|
|
41
|
-
},
|
|
44
|
+
bundle,
|
|
42
45
|
}
|
|
43
46
|
}
|