@jsenv/plugin-bundling 1.2.2 → 2.0.1
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.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@jsenv/babel-plugins": "1.1.5",
|
|
28
28
|
"@jsenv/log": "3.3.4",
|
|
29
|
-
"@jsenv/url-meta": "7.0
|
|
29
|
+
"@jsenv/url-meta": "7.1.0",
|
|
30
30
|
"@jsenv/urls": "1.2.8",
|
|
31
31
|
"@jsenv/sourcemap": "1.0.9",
|
|
32
32
|
"acorn-import-assertions": "1.8.0",
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* TODO:
|
|
3
|
+
* js classic might contain importScripts or self.importScripts calls
|
|
4
|
+
* (when it's inside worker, service worker, etc...)
|
|
5
|
+
* ideally we should bundle it when urlInfo.subtype === "worker"
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// import { createMagicSource } from "@jsenv/utils/sourcemap/magic_source.js"
|
|
9
|
+
|
|
10
|
+
export const bundleJsClassic = () => {
|
|
11
|
+
return {}
|
|
12
|
+
}
|
|
@@ -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)
|
|
@@ -132,7 +93,11 @@ export const bundleJsModules = async ({
|
|
|
132
93
|
},
|
|
133
94
|
rollupOutput: {
|
|
134
95
|
compact: context.minification,
|
|
135
|
-
|
|
96
|
+
// cannot be enabled otherwise:
|
|
97
|
+
// - rollup rename InlineContent export into one letter export like "n"
|
|
98
|
+
// - inline content detection cannot detect new InlineContent() calls
|
|
99
|
+
// -> inline content is not detected, among other things url are not versioned
|
|
100
|
+
minifyInternalExports: false, // context.minification,
|
|
136
101
|
generatedCode: {
|
|
137
102
|
arrowFunctions: context.isSupportedOnCurrentClients("arrow_function"),
|
|
138
103
|
constBindings: context.isSupportedOnCurrentClients("const_bindings"),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { bundleCss } from "./css/css_bundling_lightning_css.js"
|
|
2
|
-
import {
|
|
2
|
+
import { bundleJsClassic } from "./js_classic/bundle_js_classic.js"
|
|
3
3
|
import { bundleJsModules } from "./js_module/bundle_js_modules.js"
|
|
4
4
|
|
|
5
5
|
export const jsenvPluginBundling = ({
|
|
@@ -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 bundleJsClassic({
|
|
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
|
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* TODO:
|
|
3
|
-
* for each js_classic where subtype is a worker
|
|
4
|
-
* take the url info and find importScripts calls
|
|
5
|
-
* and replace them with the corresponding url info file content
|
|
6
|
-
* we'll ikely need to save the importScripts node location to be able to do that
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
// import { createMagicSource } from "@jsenv/utils/sourcemap/magic_source.js"
|
|
10
|
-
|
|
11
|
-
export const bundleJsClassicWorkers = () => {
|
|
12
|
-
return {}
|
|
13
|
-
}
|