@parcel/transformer-css 2.10.2 → 2.11.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/lib/CSSTransformer.js +22 -16
- package/package.json +13 -7
- package/src/CSSTransformer.js +8 -8
- 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;
|
|
@@ -60,10 +60,15 @@ function _diagnostic() {
|
|
|
60
60
|
};
|
|
61
61
|
return data;
|
|
62
62
|
}
|
|
63
|
-
function _getRequireWildcardCache(
|
|
64
|
-
function _interopRequireWildcard(
|
|
63
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
64
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
65
65
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
66
|
-
|
|
66
|
+
const {
|
|
67
|
+
transform,
|
|
68
|
+
transformStyleAttribute,
|
|
69
|
+
browserslistToTargets
|
|
70
|
+
} = native();
|
|
71
|
+
var _default = exports.default = new (_plugin().Transformer)({
|
|
67
72
|
async loadConfig({
|
|
68
73
|
config,
|
|
69
74
|
options
|
|
@@ -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,
|
|
@@ -187,9 +194,9 @@ var _default = new (_plugin().Transformer)({
|
|
|
187
194
|
});
|
|
188
195
|
}
|
|
189
196
|
}
|
|
190
|
-
asset.setBuffer(res.code);
|
|
197
|
+
asset.setBuffer(Buffer.from(res.code));
|
|
191
198
|
if (res.map != null) {
|
|
192
|
-
let vlqMap = JSON.parse(res.map.toString());
|
|
199
|
+
let vlqMap = JSON.parse(Buffer.from(res.map).toString());
|
|
193
200
|
let map = new (_sourceMap().default)(options.projectRoot);
|
|
194
201
|
map.addVLQMap(vlqMap);
|
|
195
202
|
if (originalMap) {
|
|
@@ -343,7 +350,6 @@ var _default = new (_plugin().Transformer)({
|
|
|
343
350
|
return assets;
|
|
344
351
|
}
|
|
345
352
|
});
|
|
346
|
-
exports.default = _default;
|
|
347
353
|
let cache = new Map();
|
|
348
354
|
function getTargets(browsers) {
|
|
349
355
|
if (browsers == null) {
|
|
@@ -353,7 +359,7 @@ function getTargets(browsers) {
|
|
|
353
359
|
if (cached != null) {
|
|
354
360
|
return cached;
|
|
355
361
|
}
|
|
356
|
-
let targets =
|
|
362
|
+
let targets = browserslistToTargets((0, _browserslist().default)(browsers));
|
|
357
363
|
cache.set(browsers, targets);
|
|
358
364
|
return targets;
|
|
359
365
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcel/transformer-css",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.11.0",
|
|
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.
|
|
20
|
+
"parcel": "^2.11.0"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@parcel/diagnostic": "2.
|
|
24
|
-
"@parcel/plugin": "2.
|
|
23
|
+
"@parcel/diagnostic": "2.11.0",
|
|
24
|
+
"@parcel/plugin": "2.11.0",
|
|
25
25
|
"@parcel/source-map": "^2.1.1",
|
|
26
|
-
"@parcel/utils": "2.
|
|
26
|
+
"@parcel/utils": "2.11.0",
|
|
27
27
|
"browserslist": "^4.6.6",
|
|
28
|
-
"lightningcss": "^1.
|
|
28
|
+
"lightningcss": "^1.22.1",
|
|
29
29
|
"nullthrows": "^1.1.1"
|
|
30
30
|
},
|
|
31
|
-
"
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"lightningcss-wasm": "^1.22.1"
|
|
33
|
+
},
|
|
34
|
+
"browser": {
|
|
35
|
+
"lightningcss": "./wasm-wrapper.js"
|
|
36
|
+
},
|
|
37
|
+
"gitHead": "f8076f1644cabc944695b5ec82602c8ae32bcf21"
|
|
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);
|
|
@@ -175,10 +175,10 @@ export default (new Transformer({
|
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
-
asset.setBuffer(res.code);
|
|
178
|
+
asset.setBuffer(Buffer.from(res.code));
|
|
179
179
|
|
|
180
180
|
if (res.map != null) {
|
|
181
|
-
let vlqMap = JSON.parse(res.map.toString());
|
|
181
|
+
let vlqMap = JSON.parse(Buffer.from(res.map).toString());
|
|
182
182
|
let map = new SourceMap(options.projectRoot);
|
|
183
183
|
map.addVLQMap(vlqMap);
|
|
184
184
|
|
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
|
+
};
|