@jsenv/plugin-bundling 1.0.4 → 1.0.5
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.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"test": "node --conditions=development ./scripts/test.mjs"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@jsenv/ast": "
|
|
27
|
+
"@jsenv/ast": "2.0.0",
|
|
28
28
|
"@jsenv/babel-plugins": "1.1.2",
|
|
29
29
|
"@jsenv/log": "3.3.3",
|
|
30
30
|
"@jsenv/url-meta": "7.0.2",
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { fileURLToPath } from "node:url"
|
|
2
|
+
|
|
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
|
+
|
|
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 }
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const runtimeCompatToTargets = (runtimeCompat) => {
|
|
17
|
+
const targets = {}
|
|
18
|
+
;["chrome", "firefox", "ie", "opera", "safari"].forEach((runtimeName) => {
|
|
19
|
+
const version = runtimeCompat[runtimeName]
|
|
20
|
+
if (version) {
|
|
21
|
+
targets[runtimeName] = versionToBits(version)
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
return targets
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const versionToBits = (version) => {
|
|
28
|
+
const [major, minor = 0, patch = 0] = version
|
|
29
|
+
.split("-")[0]
|
|
30
|
+
.split(".")
|
|
31
|
+
.map((v) => parseInt(v, 10))
|
|
32
|
+
return (major << 16) | (minor << 8) | patch
|
|
33
|
+
}
|
|
@@ -11,7 +11,6 @@ import { applyPostCss, postCssPluginUrlVisitor } from "@jsenv/ast"
|
|
|
11
11
|
|
|
12
12
|
import { sortByDependencies } from "./sort_by_dependencies.js"
|
|
13
13
|
|
|
14
|
-
// Do not use until https://github.com/parcel-bundler/parcel-css/issues/181
|
|
15
14
|
export const bundleCss = async ({ cssUrlInfos, context }) => {
|
|
16
15
|
const bundledCssUrlInfos = {}
|
|
17
16
|
const cssBundleInfos = await performCssBundling({
|
|
@@ -21,7 +20,7 @@ export const bundleCss = async ({ cssUrlInfos, context }) => {
|
|
|
21
20
|
cssUrlInfos.forEach((cssUrlInfo) => {
|
|
22
21
|
bundledCssUrlInfos[cssUrlInfo.url] = {
|
|
23
22
|
data: {
|
|
24
|
-
bundlerName: "
|
|
23
|
+
bundlerName: "postcss",
|
|
25
24
|
},
|
|
26
25
|
contentType: "text/css",
|
|
27
26
|
content: cssBundleInfos[cssUrlInfo.url].bundleContent,
|