@parcel/transformer-css 2.10.1 → 2.10.3
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/lib/CSSTransformer.js +17 -10
- package/package.json +12 -6
- package/src/CSSTransformer.js +6 -6
- package/wasm-wrapper.js +26 -0
package/lib/CSSTransformer.js
CHANGED
|
@@ -25,16 +25,16 @@ function _plugin() {
|
|
|
25
25
|
};
|
|
26
26
|
return data;
|
|
27
27
|
}
|
|
28
|
-
function
|
|
29
|
-
const data = require("
|
|
30
|
-
|
|
28
|
+
function _utils() {
|
|
29
|
+
const data = require("@parcel/utils");
|
|
30
|
+
_utils = function () {
|
|
31
31
|
return data;
|
|
32
32
|
};
|
|
33
33
|
return data;
|
|
34
34
|
}
|
|
35
|
-
function
|
|
36
|
-
const data = require("
|
|
37
|
-
|
|
35
|
+
function native() {
|
|
36
|
+
const data = _interopRequireWildcard(require("lightningcss"));
|
|
37
|
+
native = function () {
|
|
38
38
|
return data;
|
|
39
39
|
};
|
|
40
40
|
return data;
|
|
@@ -63,6 +63,11 @@ function _diagnostic() {
|
|
|
63
63
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
64
64
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
65
65
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
66
|
+
const {
|
|
67
|
+
transform,
|
|
68
|
+
transformStyleAttribute,
|
|
69
|
+
browserslistToTargets
|
|
70
|
+
} = native();
|
|
66
71
|
var _default = new (_plugin().Transformer)({
|
|
67
72
|
async loadConfig({
|
|
68
73
|
config,
|
|
@@ -103,12 +108,14 @@ var _default = new (_plugin().Transformer)({
|
|
|
103
108
|
shouldScopeHoist: asset.env.shouldScopeHoist,
|
|
104
109
|
sourceMap: asset.env.sourceMap
|
|
105
110
|
});
|
|
106
|
-
let [code, originalMap] = await Promise.all([asset.getBuffer(), asset.getMap()
|
|
111
|
+
let [code, originalMap] = await Promise.all([asset.getBuffer(), asset.getMap(),
|
|
112
|
+
// $FlowFixMe native.default is the init function only when bundled for the browser build
|
|
113
|
+
process.browser && native().default()]);
|
|
107
114
|
let targets = getTargets(asset.env.engines.browsers);
|
|
108
115
|
let res;
|
|
109
116
|
try {
|
|
110
117
|
if (asset.meta.type === 'attr') {
|
|
111
|
-
res =
|
|
118
|
+
res = transformStyleAttribute({
|
|
112
119
|
code,
|
|
113
120
|
analyzeDependencies: true,
|
|
114
121
|
errorRecovery: (config === null || config === void 0 ? void 0 : config.errorRecovery) || false,
|
|
@@ -140,7 +147,7 @@ var _default = new (_plugin().Transformer)({
|
|
|
140
147
|
cssModules = cssModulesConfig !== null && cssModulesConfig !== void 0 ? cssModulesConfig : true;
|
|
141
148
|
}
|
|
142
149
|
}
|
|
143
|
-
res =
|
|
150
|
+
res = transform({
|
|
144
151
|
filename: (0, _utils().normalizeSeparators)(_path().default.relative(options.projectRoot, asset.filePath)),
|
|
145
152
|
code,
|
|
146
153
|
cssModules,
|
|
@@ -353,7 +360,7 @@ function getTargets(browsers) {
|
|
|
353
360
|
if (cached != null) {
|
|
354
361
|
return cached;
|
|
355
362
|
}
|
|
356
|
-
let targets =
|
|
363
|
+
let targets = browserslistToTargets((0, _browserslist().default)(browsers));
|
|
357
364
|
cache.set(browsers, targets);
|
|
358
365
|
return targets;
|
|
359
366
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcel/transformer-css",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -17,16 +17,22 @@
|
|
|
17
17
|
"source": "src/CSSTransformer.js",
|
|
18
18
|
"engines": {
|
|
19
19
|
"node": ">= 12.0.0",
|
|
20
|
-
"parcel": "^2.10.
|
|
20
|
+
"parcel": "^2.10.3"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@parcel/diagnostic": "2.10.
|
|
24
|
-
"@parcel/plugin": "2.10.
|
|
23
|
+
"@parcel/diagnostic": "2.10.3",
|
|
24
|
+
"@parcel/plugin": "2.10.3",
|
|
25
25
|
"@parcel/source-map": "^2.1.1",
|
|
26
|
-
"@parcel/utils": "2.10.
|
|
26
|
+
"@parcel/utils": "2.10.3",
|
|
27
27
|
"browserslist": "^4.6.6",
|
|
28
28
|
"lightningcss": "^1.16.1",
|
|
29
29
|
"nullthrows": "^1.1.1"
|
|
30
30
|
},
|
|
31
|
-
"
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"lightningcss-wasm": "^1.16.1"
|
|
33
|
+
},
|
|
34
|
+
"browser": {
|
|
35
|
+
"lightningcss": "./wasm-wrapper.js"
|
|
36
|
+
},
|
|
37
|
+
"gitHead": "65d42a955db665a04817fa9be55df16f588593d4"
|
|
32
38
|
}
|
package/src/CSSTransformer.js
CHANGED
|
@@ -5,22 +5,20 @@ import type {SourceLocation} from '@parcel/types';
|
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import SourceMap from '@parcel/source-map';
|
|
7
7
|
import {Transformer} from '@parcel/plugin';
|
|
8
|
-
import {
|
|
9
|
-
transform,
|
|
10
|
-
transformStyleAttribute,
|
|
11
|
-
browserslistToTargets,
|
|
12
|
-
type SourceLocation as LightningSourceLocation,
|
|
13
|
-
} from 'lightningcss';
|
|
14
8
|
import {
|
|
15
9
|
remapSourceLocation,
|
|
16
10
|
relativePath,
|
|
17
11
|
globToRegex,
|
|
18
12
|
normalizeSeparators,
|
|
19
13
|
} from '@parcel/utils';
|
|
14
|
+
import {type SourceLocation as LightningSourceLocation} from 'lightningcss';
|
|
15
|
+
import * as native from 'lightningcss';
|
|
20
16
|
import browserslist from 'browserslist';
|
|
21
17
|
import nullthrows from 'nullthrows';
|
|
22
18
|
import ThrowableDiagnostic, {errorToDiagnostic} from '@parcel/diagnostic';
|
|
23
19
|
|
|
20
|
+
const {transform, transformStyleAttribute, browserslistToTargets} = native;
|
|
21
|
+
|
|
24
22
|
export default (new Transformer({
|
|
25
23
|
async loadConfig({config, options}) {
|
|
26
24
|
let conf = await config.getConfigFrom(options.projectRoot + '/index', [], {
|
|
@@ -60,6 +58,8 @@ export default (new Transformer({
|
|
|
60
58
|
let [code, originalMap] = await Promise.all([
|
|
61
59
|
asset.getBuffer(),
|
|
62
60
|
asset.getMap(),
|
|
61
|
+
// $FlowFixMe native.default is the init function only when bundled for the browser build
|
|
62
|
+
process.browser && native.default(),
|
|
63
63
|
]);
|
|
64
64
|
|
|
65
65
|
let targets = getTargets(asset.env.engines.browsers);
|
package/wasm-wrapper.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {transform, transformStyleAttribute} from 'lightningcss-wasm';
|
|
2
|
+
|
|
3
|
+
export {default, browserslistToTargets} from 'lightningcss-wasm';
|
|
4
|
+
|
|
5
|
+
// Hydrate Uint8Array into Buffer
|
|
6
|
+
|
|
7
|
+
function transformWrapper(config) {
|
|
8
|
+
let result = transform(config);
|
|
9
|
+
return {
|
|
10
|
+
...result,
|
|
11
|
+
code: Buffer.from(result.code),
|
|
12
|
+
map: result.map ? Buffer.from(result.map) : result.map,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function transformStyleAttributeWrapper(config) {
|
|
16
|
+
let result = transformStyleAttribute(config);
|
|
17
|
+
return {
|
|
18
|
+
...result,
|
|
19
|
+
code: Buffer.from(result.code),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export {
|
|
24
|
+
transformWrapper as transform,
|
|
25
|
+
transformStyleAttributeWrapper as transformStyleAttribute,
|
|
26
|
+
};
|