@jsenv/plugin-bundling 1.0.5 → 1.1.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": "1.0.5",
3
+ "version": "1.1.1",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -24,13 +24,13 @@
24
24
  "test": "node --conditions=development ./scripts/test.mjs"
25
25
  },
26
26
  "dependencies": {
27
- "@jsenv/ast": "2.0.0",
28
27
  "@jsenv/babel-plugins": "1.1.2",
29
28
  "@jsenv/log": "3.3.3",
30
29
  "@jsenv/url-meta": "7.0.2",
31
30
  "@jsenv/urls": "1.2.8",
32
31
  "@jsenv/sourcemap": "1.0.8",
33
32
  "acorn-import-assertions": "1.8.0",
33
+ "lightningcss": "1.18.0",
34
34
  "rollup": "3.9.1"
35
35
  },
36
36
  "peerDependencies": {
@@ -1,16 +1,39 @@
1
- import { fileURLToPath } from "node:url"
1
+ import { fileURLToPath, pathToFileURL } from "node:url"
2
2
 
3
3
  // Do not use until https://github.com/parcel-bundler/parcel-css/issues/181
4
- export const bundleCss = async (urlInfo, context) => {
5
- const { bundle } = await import("lightningcss")
6
-
4
+ export const bundleCss = async ({ cssUrlInfos, context }) => {
5
+ const bundledCssUrlInfos = {}
6
+ const { bundleAsync } = await import("lightningcss")
7
7
  const targets = runtimeCompatToTargets(context.runtimeCompat)
8
- const { code, map } = bundle({
9
- filename: fileURLToPath(urlInfo.originalUrl),
10
- targets,
11
- minify: false,
12
- })
13
- return { code, map }
8
+ for (const cssUrlInfo of cssUrlInfos) {
9
+ const { code, map } = await bundleAsync({
10
+ filename: fileURLToPath(cssUrlInfo.originalUrl),
11
+ targets,
12
+ minify: false,
13
+ resolver: {
14
+ read: (specifier) => {
15
+ const fileUrlObject = pathToFileURL(specifier)
16
+ const fileUrl = String(fileUrlObject)
17
+ const urlInfo = context.urlGraph.getUrlInfo(fileUrl)
18
+ return urlInfo.content
19
+ },
20
+ resolve(specifier, from) {
21
+ const fileUrlObject = new URL(specifier, pathToFileURL(from))
22
+ const filePath = fileURLToPath(fileUrlObject)
23
+ return filePath
24
+ },
25
+ },
26
+ })
27
+ bundledCssUrlInfos[cssUrlInfo.url] = {
28
+ data: {
29
+ bundlerName: "lightningcss",
30
+ },
31
+ contentType: "text/css",
32
+ content: String(code),
33
+ sourcemap: map,
34
+ }
35
+ }
36
+ return bundledCssUrlInfos
14
37
  }
15
38
 
16
39
  const runtimeCompatToTargets = (runtimeCompat) => {
@@ -79,6 +79,18 @@ export const bundleJsModules = async ({
79
79
  ...rollupInput,
80
80
  },
81
81
  rollupOutput: {
82
+ compact: context.minification,
83
+ minifyInternalExports: context.minification,
84
+ generatedCode: {
85
+ arrowFunctions: context.isSupportedOnCurrentClients("arrow_function"),
86
+ constBindings: context.isSupportedOnCurrentClients("const_bindings"),
87
+ objectShorthand: context.isSupportedOnCurrentClients(
88
+ "object_properties_shorthand",
89
+ ),
90
+ reservedNamesAsProps:
91
+ context.isSupportedOnCurrentClients("reserved_words"),
92
+ symbols: context.isSupportedOnCurrentClients("symbols"),
93
+ },
82
94
  ...rollupOutput,
83
95
  },
84
96
  })
@@ -1,4 +1,4 @@
1
- import { bundleCss } from "./css/css_bundling_postcss.js"
1
+ import { bundleCss } from "./css/css_bundling_lightning_css.js"
2
2
  import { bundleJsClassicWorkers } from "./js_classic_workers/bundle_js_classic_workers.js"
3
3
  import { bundleJsModules } from "./js_module/bundle_js_modules.js"
4
4