@parcel/transformer-css 2.6.2 → 2.8.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 +31 -7
- package/package.json +8 -8
- package/src/CSSTransformer.js +29 -2
package/lib/CSSTransformer.js
CHANGED
|
@@ -35,10 +35,10 @@ function _plugin() {
|
|
|
35
35
|
return data;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
function
|
|
39
|
-
const data = require("
|
|
38
|
+
function _lightningcss() {
|
|
39
|
+
const data = require("lightningcss");
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
_lightningcss = function () {
|
|
42
42
|
return data;
|
|
43
43
|
};
|
|
44
44
|
|
|
@@ -105,7 +105,8 @@ var _default = new (_plugin().Transformer)({
|
|
|
105
105
|
async transform({
|
|
106
106
|
asset,
|
|
107
107
|
config,
|
|
108
|
-
options
|
|
108
|
+
options,
|
|
109
|
+
logger
|
|
109
110
|
}) {
|
|
110
111
|
// Normalize the asset's environment so that properties that only affect JS don't cause CSS to be duplicated.
|
|
111
112
|
// For example, with ESModule and CommonJS targets, only a single shared CSS bundle should be produced.
|
|
@@ -125,9 +126,10 @@ var _default = new (_plugin().Transformer)({
|
|
|
125
126
|
|
|
126
127
|
try {
|
|
127
128
|
if (asset.meta.type === 'attr') {
|
|
128
|
-
res = (0,
|
|
129
|
+
res = (0, _lightningcss().transformStyleAttribute)({
|
|
129
130
|
code,
|
|
130
131
|
analyzeDependencies: true,
|
|
132
|
+
errorRecovery: (config === null || config === void 0 ? void 0 : config.errorRecovery) || false,
|
|
131
133
|
targets
|
|
132
134
|
});
|
|
133
135
|
} else {
|
|
@@ -145,7 +147,7 @@ var _default = new (_plugin().Transformer)({
|
|
|
145
147
|
}
|
|
146
148
|
}
|
|
147
149
|
|
|
148
|
-
res = (0,
|
|
150
|
+
res = (0, _lightningcss().transform)({
|
|
149
151
|
filename: _path().default.relative(options.projectRoot, asset.filePath),
|
|
150
152
|
code,
|
|
151
153
|
cssModules,
|
|
@@ -153,6 +155,7 @@ var _default = new (_plugin().Transformer)({
|
|
|
153
155
|
sourceMap: !!asset.env.sourceMap,
|
|
154
156
|
drafts: config === null || config === void 0 ? void 0 : config.drafts,
|
|
155
157
|
pseudoClasses: config === null || config === void 0 ? void 0 : config.pseudoClasses,
|
|
158
|
+
errorRecovery: (config === null || config === void 0 ? void 0 : config.errorRecovery) || false,
|
|
156
159
|
targets
|
|
157
160
|
});
|
|
158
161
|
}
|
|
@@ -175,6 +178,27 @@ var _default = new (_plugin().Transformer)({
|
|
|
175
178
|
});
|
|
176
179
|
}
|
|
177
180
|
|
|
181
|
+
if (res.warnings) {
|
|
182
|
+
for (let warning of res.warnings) {
|
|
183
|
+
logger.warn({
|
|
184
|
+
message: warning.message,
|
|
185
|
+
codeFrames: [{
|
|
186
|
+
filePath: asset.filePath,
|
|
187
|
+
codeHighlights: [{
|
|
188
|
+
start: {
|
|
189
|
+
line: warning.loc.line,
|
|
190
|
+
column: warning.loc.column
|
|
191
|
+
},
|
|
192
|
+
end: {
|
|
193
|
+
line: warning.loc.line,
|
|
194
|
+
column: warning.loc.column
|
|
195
|
+
}
|
|
196
|
+
}]
|
|
197
|
+
}]
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
178
202
|
asset.setBuffer(res.code);
|
|
179
203
|
|
|
180
204
|
if (res.map != null) {
|
|
@@ -339,7 +363,7 @@ function getTargets(browsers) {
|
|
|
339
363
|
return cached;
|
|
340
364
|
}
|
|
341
365
|
|
|
342
|
-
let targets = (0,
|
|
366
|
+
let targets = (0, _lightningcss().browserslistToTargets)((0, _browserslist().default)(browsers));
|
|
343
367
|
cache.set(browsers, targets);
|
|
344
368
|
return targets;
|
|
345
369
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcel/transformer-css",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -17,16 +17,16 @@
|
|
|
17
17
|
"source": "src/CSSTransformer.js",
|
|
18
18
|
"engines": {
|
|
19
19
|
"node": ">= 12.0.0",
|
|
20
|
-
"parcel": "^2.
|
|
20
|
+
"parcel": "^2.8.0"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@parcel/
|
|
24
|
-
"@parcel/
|
|
25
|
-
"@parcel/
|
|
26
|
-
"@parcel/
|
|
27
|
-
"@parcel/utils": "2.6.2",
|
|
23
|
+
"@parcel/diagnostic": "2.8.0",
|
|
24
|
+
"@parcel/plugin": "2.8.0",
|
|
25
|
+
"@parcel/source-map": "^2.1.1",
|
|
26
|
+
"@parcel/utils": "2.8.0",
|
|
28
27
|
"browserslist": "^4.6.6",
|
|
28
|
+
"lightningcss": "^1.16.1",
|
|
29
29
|
"nullthrows": "^1.1.1"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "c3bbe0a6160186f496ca2f9e9bead9376c0522f1"
|
|
32
32
|
}
|
package/src/CSSTransformer.js
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
transform,
|
|
8
8
|
transformStyleAttribute,
|
|
9
9
|
browserslistToTargets,
|
|
10
|
-
} from '
|
|
10
|
+
} from 'lightningcss';
|
|
11
11
|
import {remapSourceLocation, relativePath} from '@parcel/utils';
|
|
12
12
|
import browserslist from 'browserslist';
|
|
13
13
|
import nullthrows from 'nullthrows';
|
|
@@ -20,7 +20,7 @@ export default (new Transformer({
|
|
|
20
20
|
});
|
|
21
21
|
return conf?.contents;
|
|
22
22
|
},
|
|
23
|
-
async transform({asset, config, options}) {
|
|
23
|
+
async transform({asset, config, options, logger}) {
|
|
24
24
|
// Normalize the asset's environment so that properties that only affect JS don't cause CSS to be duplicated.
|
|
25
25
|
// For example, with ESModule and CommonJS targets, only a single shared CSS bundle should be produced.
|
|
26
26
|
let env = asset.env;
|
|
@@ -46,6 +46,7 @@ export default (new Transformer({
|
|
|
46
46
|
res = transformStyleAttribute({
|
|
47
47
|
code,
|
|
48
48
|
analyzeDependencies: true,
|
|
49
|
+
errorRecovery: config?.errorRecovery || false,
|
|
49
50
|
targets,
|
|
50
51
|
});
|
|
51
52
|
} else {
|
|
@@ -77,6 +78,7 @@ export default (new Transformer({
|
|
|
77
78
|
sourceMap: !!asset.env.sourceMap,
|
|
78
79
|
drafts: config?.drafts,
|
|
79
80
|
pseudoClasses: config?.pseudoClasses,
|
|
81
|
+
errorRecovery: config?.errorRecovery || false,
|
|
80
82
|
targets,
|
|
81
83
|
});
|
|
82
84
|
}
|
|
@@ -103,6 +105,31 @@ export default (new Transformer({
|
|
|
103
105
|
});
|
|
104
106
|
}
|
|
105
107
|
|
|
108
|
+
if (res.warnings) {
|
|
109
|
+
for (let warning of res.warnings) {
|
|
110
|
+
logger.warn({
|
|
111
|
+
message: warning.message,
|
|
112
|
+
codeFrames: [
|
|
113
|
+
{
|
|
114
|
+
filePath: asset.filePath,
|
|
115
|
+
codeHighlights: [
|
|
116
|
+
{
|
|
117
|
+
start: {
|
|
118
|
+
line: warning.loc.line,
|
|
119
|
+
column: warning.loc.column,
|
|
120
|
+
},
|
|
121
|
+
end: {
|
|
122
|
+
line: warning.loc.line,
|
|
123
|
+
column: warning.loc.column,
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
},
|
|
128
|
+
],
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
106
133
|
asset.setBuffer(res.code);
|
|
107
134
|
|
|
108
135
|
if (res.map != null) {
|