@atlaspack/transformer-css 2.14.5-canary.16 → 2.14.5-canary.160
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/CHANGELOG.md +157 -0
- package/lib/CSSTransformer.js +40 -4
- package/lib/types/CSSTransformer.d.ts +3 -0
- package/package.json +12 -7
- package/src/{CSSTransformer.js → CSSTransformer.ts} +44 -15
- package/tsconfig.json +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,162 @@
|
|
|
1
1
|
# @atlaspack/transformer-css
|
|
2
2
|
|
|
3
|
+
## 2.14.25
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies []:
|
|
8
|
+
- @atlaspack/utils@2.18.2
|
|
9
|
+
- @atlaspack/plugin@2.14.25
|
|
10
|
+
|
|
11
|
+
## 2.14.24
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies []:
|
|
16
|
+
- @atlaspack/utils@2.18.1
|
|
17
|
+
- @atlaspack/plugin@2.14.24
|
|
18
|
+
|
|
19
|
+
## 2.14.23
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Updated dependencies [[`23d561e`](https://github.com/atlassian-labs/atlaspack/commit/23d561e51e68b0c38fd1ff4e4fb173e5e7b01cf2)]:
|
|
24
|
+
- @atlaspack/utils@2.18.0
|
|
25
|
+
- @atlaspack/plugin@2.14.23
|
|
26
|
+
|
|
27
|
+
## 2.14.22
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- [#720](https://github.com/atlassian-labs/atlaspack/pull/720) [`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94) Thanks [@alshdavid](https://github.com/alshdavid)! - Migrate to TypeScript
|
|
32
|
+
|
|
33
|
+
- Updated dependencies [[`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94)]:
|
|
34
|
+
- @atlaspack/diagnostic@2.14.2
|
|
35
|
+
- @atlaspack/plugin@2.14.22
|
|
36
|
+
- @atlaspack/utils@2.17.4
|
|
37
|
+
|
|
38
|
+
## 2.14.21
|
|
39
|
+
|
|
40
|
+
### Patch Changes
|
|
41
|
+
|
|
42
|
+
- Updated dependencies []:
|
|
43
|
+
- @atlaspack/utils@2.17.3
|
|
44
|
+
- @atlaspack/plugin@2.14.21
|
|
45
|
+
|
|
46
|
+
## 2.14.20
|
|
47
|
+
|
|
48
|
+
### Patch Changes
|
|
49
|
+
|
|
50
|
+
- [#702](https://github.com/atlassian-labs/atlaspack/pull/702) [`daaa768`](https://github.com/atlassian-labs/atlaspack/commit/daaa7688786772d7e3713b71c5bba6b89ec704aa) Thanks [@alshdavid](https://github.com/alshdavid)! - Fixes to Flow types
|
|
51
|
+
|
|
52
|
+
- Updated dependencies [[`daaa768`](https://github.com/atlassian-labs/atlaspack/commit/daaa7688786772d7e3713b71c5bba6b89ec704aa)]:
|
|
53
|
+
- @atlaspack/plugin@2.14.20
|
|
54
|
+
- @atlaspack/utils@2.17.2
|
|
55
|
+
|
|
56
|
+
## 2.14.19
|
|
57
|
+
|
|
58
|
+
### Patch Changes
|
|
59
|
+
|
|
60
|
+
- Updated dependencies []:
|
|
61
|
+
- @atlaspack/utils@2.17.1
|
|
62
|
+
- @atlaspack/plugin@2.14.19
|
|
63
|
+
|
|
64
|
+
## 2.14.18
|
|
65
|
+
|
|
66
|
+
### Patch Changes
|
|
67
|
+
|
|
68
|
+
- Updated dependencies [[`dbb4072`](https://github.com/atlassian-labs/atlaspack/commit/dbb40721ebeb45990a14ba04e6b44e7f836fb32d), [`de23e0c`](https://github.com/atlassian-labs/atlaspack/commit/de23e0ce49d5504fe3947ac26640a3d951087da3), [`18a57cf`](https://github.com/atlassian-labs/atlaspack/commit/18a57cf8a4789b2de5ad8e2676f317a26cc91417), [`a5ed1b4`](https://github.com/atlassian-labs/atlaspack/commit/a5ed1b414498560f393ff491af4da25b6e8dde56)]:
|
|
69
|
+
- @atlaspack/utils@2.17.0
|
|
70
|
+
- @atlaspack/plugin@2.14.18
|
|
71
|
+
|
|
72
|
+
## 2.14.17
|
|
73
|
+
|
|
74
|
+
### Patch Changes
|
|
75
|
+
|
|
76
|
+
- Updated dependencies []:
|
|
77
|
+
- @atlaspack/utils@2.16.1
|
|
78
|
+
- @atlaspack/plugin@2.14.17
|
|
79
|
+
|
|
80
|
+
## 2.14.16
|
|
81
|
+
|
|
82
|
+
### Patch Changes
|
|
83
|
+
|
|
84
|
+
- Updated dependencies [[`30ee2cf`](https://github.com/atlassian-labs/atlaspack/commit/30ee2cfcd34cf2646ded0eda13fdb80a2a5de529)]:
|
|
85
|
+
- @atlaspack/utils@2.16.0
|
|
86
|
+
- @atlaspack/plugin@2.14.16
|
|
87
|
+
|
|
88
|
+
## 2.14.15
|
|
89
|
+
|
|
90
|
+
### Patch Changes
|
|
91
|
+
|
|
92
|
+
- Updated dependencies []:
|
|
93
|
+
- @atlaspack/utils@2.15.3
|
|
94
|
+
- @atlaspack/plugin@2.14.15
|
|
95
|
+
|
|
96
|
+
## 2.14.14
|
|
97
|
+
|
|
98
|
+
### Patch Changes
|
|
99
|
+
|
|
100
|
+
- Updated dependencies []:
|
|
101
|
+
- @atlaspack/utils@2.15.2
|
|
102
|
+
- @atlaspack/plugin@2.14.14
|
|
103
|
+
|
|
104
|
+
## 2.14.13
|
|
105
|
+
|
|
106
|
+
### Patch Changes
|
|
107
|
+
|
|
108
|
+
- Updated dependencies []:
|
|
109
|
+
- @atlaspack/utils@2.15.1
|
|
110
|
+
- @atlaspack/plugin@2.14.13
|
|
111
|
+
|
|
112
|
+
## 2.14.12
|
|
113
|
+
|
|
114
|
+
### Patch Changes
|
|
115
|
+
|
|
116
|
+
- Updated dependencies [[`e39c6cf`](https://github.com/atlassian-labs/atlaspack/commit/e39c6cf05f7e95ce5420dbcea66f401b1cbd397c)]:
|
|
117
|
+
- @atlaspack/utils@2.15.0
|
|
118
|
+
- @atlaspack/plugin@2.14.12
|
|
119
|
+
|
|
120
|
+
## 2.14.11
|
|
121
|
+
|
|
122
|
+
### Patch Changes
|
|
123
|
+
|
|
124
|
+
- Updated dependencies []:
|
|
125
|
+
- @atlaspack/utils@2.14.11
|
|
126
|
+
- @atlaspack/plugin@2.14.11
|
|
127
|
+
|
|
128
|
+
## 2.14.10
|
|
129
|
+
|
|
130
|
+
### Patch Changes
|
|
131
|
+
|
|
132
|
+
- Updated dependencies []:
|
|
133
|
+
- @atlaspack/plugin@2.14.10
|
|
134
|
+
- @atlaspack/utils@2.14.10
|
|
135
|
+
|
|
136
|
+
## 2.14.9
|
|
137
|
+
|
|
138
|
+
### Patch Changes
|
|
139
|
+
|
|
140
|
+
- Updated dependencies []:
|
|
141
|
+
- @atlaspack/utils@2.14.9
|
|
142
|
+
- @atlaspack/plugin@2.14.9
|
|
143
|
+
|
|
144
|
+
## 2.14.8
|
|
145
|
+
|
|
146
|
+
### Patch Changes
|
|
147
|
+
|
|
148
|
+
- Updated dependencies []:
|
|
149
|
+
- @atlaspack/utils@2.14.8
|
|
150
|
+
- @atlaspack/plugin@2.14.8
|
|
151
|
+
|
|
152
|
+
## 2.14.7
|
|
153
|
+
|
|
154
|
+
### Patch Changes
|
|
155
|
+
|
|
156
|
+
- Updated dependencies []:
|
|
157
|
+
- @atlaspack/utils@2.14.7
|
|
158
|
+
- @atlaspack/plugin@2.14.7
|
|
159
|
+
|
|
3
160
|
## 2.14.6
|
|
4
161
|
|
|
5
162
|
### Patch Changes
|
package/lib/CSSTransformer.js
CHANGED
|
@@ -78,15 +78,27 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
78
78
|
packageKey: '@atlaspack/transformer-css'
|
|
79
79
|
});
|
|
80
80
|
let contents = conf === null || conf === void 0 ? void 0 : conf.contents;
|
|
81
|
+
// @ts-expect-error TS2339
|
|
81
82
|
if (typeof (contents === null || contents === void 0 || (_contents$cssModules = contents.cssModules) === null || _contents$cssModules === void 0 ? void 0 : _contents$cssModules.include) === 'string') {
|
|
83
|
+
// @ts-expect-error TS2339
|
|
82
84
|
contents.cssModules.include = [(0, _utils().globToRegex)(contents.cssModules.include)];
|
|
85
|
+
// @ts-expect-error TS2339
|
|
83
86
|
} else if (Array.isArray(contents === null || contents === void 0 || (_contents$cssModules2 = contents.cssModules) === null || _contents$cssModules2 === void 0 ? void 0 : _contents$cssModules2.include)) {
|
|
84
|
-
|
|
87
|
+
// @ts-expect-error TS2339
|
|
88
|
+
contents.cssModules.include = contents.cssModules.include.map(
|
|
89
|
+
// @ts-expect-error TS7006
|
|
90
|
+
include => typeof include === 'string' ? (0, _utils().globToRegex)(include) : include);
|
|
85
91
|
}
|
|
92
|
+
// @ts-expect-error TS2339
|
|
86
93
|
if (typeof (contents === null || contents === void 0 || (_contents$cssModules3 = contents.cssModules) === null || _contents$cssModules3 === void 0 ? void 0 : _contents$cssModules3.exclude) === 'string') {
|
|
94
|
+
// @ts-expect-error TS2339
|
|
87
95
|
contents.cssModules.exclude = [(0, _utils().globToRegex)(contents.cssModules.exclude)];
|
|
96
|
+
// @ts-expect-error TS2339
|
|
88
97
|
} else if (Array.isArray(contents === null || contents === void 0 || (_contents$cssModules4 = contents.cssModules) === null || _contents$cssModules4 === void 0 ? void 0 : _contents$cssModules4.exclude)) {
|
|
89
|
-
|
|
98
|
+
// @ts-expect-error TS2339
|
|
99
|
+
contents.cssModules.exclude = contents.cssModules.exclude.map(
|
|
100
|
+
// @ts-expect-error TS7006
|
|
101
|
+
exclude => typeof exclude === 'string' ? (0, _utils().globToRegex)(exclude) : exclude);
|
|
90
102
|
}
|
|
91
103
|
return contents;
|
|
92
104
|
},
|
|
@@ -109,7 +121,7 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
109
121
|
sourceMap: asset.env.sourceMap
|
|
110
122
|
});
|
|
111
123
|
let [code, originalMap] = await Promise.all([asset.getBuffer(), asset.getMap(),
|
|
112
|
-
//
|
|
124
|
+
// @ts-expect-error TS2339
|
|
113
125
|
process.browser && native().default()]);
|
|
114
126
|
let targets = getTargets(asset.env.engines.browsers);
|
|
115
127
|
let res;
|
|
@@ -118,12 +130,14 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
118
130
|
res = transformStyleAttribute({
|
|
119
131
|
code,
|
|
120
132
|
analyzeDependencies: true,
|
|
133
|
+
// @ts-expect-error TS2339
|
|
121
134
|
errorRecovery: (config === null || config === void 0 ? void 0 : config.errorRecovery) || false,
|
|
122
135
|
targets
|
|
123
136
|
});
|
|
124
137
|
} else {
|
|
125
138
|
let cssModules = false;
|
|
126
139
|
if (asset.meta.type !== 'tag' && asset.meta.cssModulesCompiled == null) {
|
|
140
|
+
// @ts-expect-error TS2339
|
|
127
141
|
let cssModulesConfig = config === null || config === void 0 ? void 0 : config.cssModules;
|
|
128
142
|
let isCSSModule = /\.module\./.test(asset.filePath);
|
|
129
143
|
if (asset.isSource) {
|
|
@@ -132,6 +146,7 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
132
146
|
if (typeof cssModulesConfig === 'boolean') {
|
|
133
147
|
isCSSModule = true;
|
|
134
148
|
} else if (cssModulesConfig !== null && cssModulesConfig !== void 0 && cssModulesConfig.include) {
|
|
149
|
+
// @ts-expect-error TS7006
|
|
135
150
|
isCSSModule = cssModulesConfig.include.some(include => include.test(projectRootPath));
|
|
136
151
|
} else if (cssModulesConfig !== null && cssModulesConfig !== void 0 && cssModulesConfig.global) {
|
|
137
152
|
isCSSModule = true;
|
|
@@ -155,8 +170,11 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
155
170
|
preserveImports: true
|
|
156
171
|
} : false,
|
|
157
172
|
sourceMap: !!asset.env.sourceMap,
|
|
173
|
+
// @ts-expect-error TS2339
|
|
158
174
|
drafts: config === null || config === void 0 ? void 0 : config.drafts,
|
|
175
|
+
// @ts-expect-error TS2339
|
|
159
176
|
pseudoClasses: config === null || config === void 0 ? void 0 : config.pseudoClasses,
|
|
177
|
+
// @ts-expect-error TS2339
|
|
160
178
|
errorRecovery: (config === null || config === void 0 ? void 0 : config.errorRecovery) || false,
|
|
161
179
|
targets
|
|
162
180
|
});
|
|
@@ -196,7 +214,10 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
196
214
|
});
|
|
197
215
|
}
|
|
198
216
|
}
|
|
217
|
+
|
|
218
|
+
// @ts-expect-error TS2339
|
|
199
219
|
if (res.map != null) {
|
|
220
|
+
// @ts-expect-error TS2339
|
|
200
221
|
let vlqMap = JSON.parse(Buffer.from(res.map).toString());
|
|
201
222
|
let map = new (_sourceMap().default)(options.projectRoot);
|
|
202
223
|
map.addVLQMap(vlqMap);
|
|
@@ -211,6 +232,8 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
211
232
|
if (originalMap) {
|
|
212
233
|
loc = (0, _utils().remapSourceLocation)(loc, originalMap);
|
|
213
234
|
}
|
|
235
|
+
|
|
236
|
+
// @ts-expect-error TS2339
|
|
214
237
|
if (dep.type === 'import' && !res.exports) {
|
|
215
238
|
asset.addDependency({
|
|
216
239
|
specifier: dep.url,
|
|
@@ -236,9 +259,13 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
236
259
|
}
|
|
237
260
|
let assets = [asset];
|
|
238
261
|
let buffer = Buffer.from(res.code);
|
|
262
|
+
|
|
263
|
+
// @ts-expect-error TS2339
|
|
239
264
|
if (res.exports != null) {
|
|
265
|
+
// @ts-expect-error TS2339
|
|
240
266
|
let exports = res.exports;
|
|
241
267
|
asset.symbols.ensure();
|
|
268
|
+
// @ts-expect-error TS2345
|
|
242
269
|
asset.symbols.set('default', 'default');
|
|
243
270
|
let dependencies = new Map();
|
|
244
271
|
let locals = new Map();
|
|
@@ -246,6 +273,7 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
246
273
|
let depjs = '';
|
|
247
274
|
let js = '';
|
|
248
275
|
let cssImports = '';
|
|
276
|
+
let jsDeps = [];
|
|
249
277
|
for (let key in exports) {
|
|
250
278
|
locals.set(exports[key].name, key);
|
|
251
279
|
}
|
|
@@ -300,6 +328,7 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
300
328
|
asset.addDependency({
|
|
301
329
|
specifier: (0, _nullthrows().default)(asset.uniqueKey),
|
|
302
330
|
specifierType: 'esm',
|
|
331
|
+
// @ts-expect-error TS2322
|
|
303
332
|
symbols: new Map([[key, {
|
|
304
333
|
local: exports[key].name,
|
|
305
334
|
isWeak: false,
|
|
@@ -313,6 +342,7 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
313
342
|
// It's possible that the exports can be ordered differently between builds.
|
|
314
343
|
// Sorting by key is safe as the order is irrelevant but needs to be deterministic.
|
|
315
344
|
for (let key of Object.keys(exports).sort()) {
|
|
345
|
+
// @ts-expect-error TS2345
|
|
316
346
|
asset.symbols.set(key, exports[key].name);
|
|
317
347
|
add(key);
|
|
318
348
|
}
|
|
@@ -323,11 +353,15 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
323
353
|
let d = `dep_$${c++}`;
|
|
324
354
|
depjs += `import * as ${d} from ${JSON.stringify(dep.url)};\n`;
|
|
325
355
|
js += `for (let key in ${d}) { if (key in module.exports) module.exports[key] += ' ' + ${d}[key]; else module.exports[key] = ${d}[key]; }\n`;
|
|
356
|
+
// @ts-expect-error TS2345
|
|
326
357
|
asset.symbols.set('*', '*');
|
|
327
358
|
}
|
|
328
359
|
}
|
|
329
360
|
}
|
|
361
|
+
|
|
362
|
+
// @ts-expect-error TS2339
|
|
330
363
|
if (res.references != null) {
|
|
364
|
+
// @ts-expect-error TS2339
|
|
331
365
|
let references = res.references;
|
|
332
366
|
for (let symbol in references) {
|
|
333
367
|
let reference = references[symbol];
|
|
@@ -335,6 +369,7 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
335
369
|
specifier: reference.specifier,
|
|
336
370
|
specifierType: 'esm',
|
|
337
371
|
packageConditions: ['style'],
|
|
372
|
+
// @ts-expect-error TS2322
|
|
338
373
|
symbols: new Map([[reference.name, {
|
|
339
374
|
local: symbol,
|
|
340
375
|
isWeak: false,
|
|
@@ -347,8 +382,9 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
347
382
|
}
|
|
348
383
|
assets.push({
|
|
349
384
|
type: 'js',
|
|
385
|
+
// @ts-expect-error TS2353
|
|
350
386
|
content: depjs + js,
|
|
351
|
-
dependencies:
|
|
387
|
+
dependencies: jsDeps,
|
|
352
388
|
env
|
|
353
389
|
});
|
|
354
390
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/transformer-css",
|
|
3
|
-
"version": "2.14.5-canary.
|
|
3
|
+
"version": "2.14.5-canary.160+4be63eda8",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -9,15 +9,16 @@
|
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "https://github.com/atlassian-labs/atlaspack.git"
|
|
11
11
|
},
|
|
12
|
-
"main": "lib/CSSTransformer.js",
|
|
13
|
-
"source": "src/CSSTransformer.
|
|
12
|
+
"main": "./lib/CSSTransformer.js",
|
|
13
|
+
"source": "./src/CSSTransformer.ts",
|
|
14
|
+
"types": "./lib/types/CSSTransformer.d.ts",
|
|
14
15
|
"engines": {
|
|
15
16
|
"node": ">= 16.0.0"
|
|
16
17
|
},
|
|
17
18
|
"dependencies": {
|
|
18
|
-
"@atlaspack/diagnostic": "2.14.1-canary.
|
|
19
|
-
"@atlaspack/plugin": "2.14.5-canary.
|
|
20
|
-
"@atlaspack/utils": "2.14.5-canary.
|
|
19
|
+
"@atlaspack/diagnostic": "2.14.1-canary.228+4be63eda8",
|
|
20
|
+
"@atlaspack/plugin": "2.14.5-canary.160+4be63eda8",
|
|
21
|
+
"@atlaspack/utils": "2.14.5-canary.160+4be63eda8",
|
|
21
22
|
"@parcel/source-map": "^2.1.1",
|
|
22
23
|
"browserslist": "^4.6.6",
|
|
23
24
|
"lightningcss": "^1.28.2",
|
|
@@ -30,5 +31,9 @@
|
|
|
30
31
|
"lightningcss": "lightningcss-wasm"
|
|
31
32
|
},
|
|
32
33
|
"type": "commonjs",
|
|
33
|
-
"
|
|
34
|
+
"scripts": {
|
|
35
|
+
"check-ts": "tsc --emitDeclarationOnly --rootDir src",
|
|
36
|
+
"build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
|
|
37
|
+
},
|
|
38
|
+
"gitHead": "4be63eda8e561c18803bf04681fe1d61b7eaae93"
|
|
34
39
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// @flow strict-local
|
|
2
|
-
|
|
3
1
|
import type {SourceLocation} from '@atlaspack/types';
|
|
4
2
|
|
|
5
3
|
import path from 'path';
|
|
@@ -11,7 +9,7 @@ import {
|
|
|
11
9
|
globToRegex,
|
|
12
10
|
normalizeSeparators,
|
|
13
11
|
} from '@atlaspack/utils';
|
|
14
|
-
import {
|
|
12
|
+
import {SourceLocation as LightningSourceLocation} from 'lightningcss';
|
|
15
13
|
import * as native from 'lightningcss';
|
|
16
14
|
import browserslist from 'browserslist';
|
|
17
15
|
import nullthrows from 'nullthrows';
|
|
@@ -19,24 +17,36 @@ import ThrowableDiagnostic, {errorToDiagnostic} from '@atlaspack/diagnostic';
|
|
|
19
17
|
|
|
20
18
|
const {transform, transformStyleAttribute, browserslistToTargets} = native;
|
|
21
19
|
|
|
22
|
-
export default
|
|
20
|
+
export default new Transformer({
|
|
23
21
|
async loadConfig({config, options}) {
|
|
24
22
|
let conf = await config.getConfigFrom(options.projectRoot + '/index', [], {
|
|
25
23
|
packageKey: '@atlaspack/transformer-css',
|
|
26
24
|
});
|
|
27
25
|
let contents = conf?.contents;
|
|
26
|
+
// @ts-expect-error TS2339
|
|
28
27
|
if (typeof contents?.cssModules?.include === 'string') {
|
|
28
|
+
// @ts-expect-error TS2339
|
|
29
29
|
contents.cssModules.include = [globToRegex(contents.cssModules.include)];
|
|
30
|
+
// @ts-expect-error TS2339
|
|
30
31
|
} else if (Array.isArray(contents?.cssModules?.include)) {
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
// @ts-expect-error TS2339
|
|
33
|
+
contents.cssModules.include = contents.cssModules.include.map(
|
|
34
|
+
// @ts-expect-error TS7006
|
|
35
|
+
(include) =>
|
|
36
|
+
typeof include === 'string' ? globToRegex(include) : include,
|
|
33
37
|
);
|
|
34
38
|
}
|
|
39
|
+
// @ts-expect-error TS2339
|
|
35
40
|
if (typeof contents?.cssModules?.exclude === 'string') {
|
|
41
|
+
// @ts-expect-error TS2339
|
|
36
42
|
contents.cssModules.exclude = [globToRegex(contents.cssModules.exclude)];
|
|
43
|
+
// @ts-expect-error TS2339
|
|
37
44
|
} else if (Array.isArray(contents?.cssModules?.exclude)) {
|
|
38
|
-
|
|
39
|
-
|
|
45
|
+
// @ts-expect-error TS2339
|
|
46
|
+
contents.cssModules.exclude = contents.cssModules.exclude.map(
|
|
47
|
+
// @ts-expect-error TS7006
|
|
48
|
+
(exclude) =>
|
|
49
|
+
typeof exclude === 'string' ? globToRegex(exclude) : exclude,
|
|
40
50
|
);
|
|
41
51
|
}
|
|
42
52
|
return contents;
|
|
@@ -58,7 +68,7 @@ export default (new Transformer({
|
|
|
58
68
|
let [code, originalMap] = await Promise.all([
|
|
59
69
|
asset.getBuffer(),
|
|
60
70
|
asset.getMap(),
|
|
61
|
-
//
|
|
71
|
+
// @ts-expect-error TS2339
|
|
62
72
|
process.browser && native.default(),
|
|
63
73
|
]);
|
|
64
74
|
|
|
@@ -69,6 +79,7 @@ export default (new Transformer({
|
|
|
69
79
|
res = transformStyleAttribute({
|
|
70
80
|
code,
|
|
71
81
|
analyzeDependencies: true,
|
|
82
|
+
// @ts-expect-error TS2339
|
|
72
83
|
errorRecovery: config?.errorRecovery || false,
|
|
73
84
|
targets,
|
|
74
85
|
});
|
|
@@ -78,6 +89,7 @@ export default (new Transformer({
|
|
|
78
89
|
asset.meta.type !== 'tag' &&
|
|
79
90
|
asset.meta.cssModulesCompiled == null
|
|
80
91
|
) {
|
|
92
|
+
// @ts-expect-error TS2339
|
|
81
93
|
let cssModulesConfig = config?.cssModules;
|
|
82
94
|
let isCSSModule = /\.module\./.test(asset.filePath);
|
|
83
95
|
if (asset.isSource) {
|
|
@@ -88,6 +100,7 @@ export default (new Transformer({
|
|
|
88
100
|
if (typeof cssModulesConfig === 'boolean') {
|
|
89
101
|
isCSSModule = true;
|
|
90
102
|
} else if (cssModulesConfig?.include) {
|
|
103
|
+
// @ts-expect-error TS7006
|
|
91
104
|
isCSSModule = cssModulesConfig.include.some((include) =>
|
|
92
105
|
include.test(projectRootPath),
|
|
93
106
|
);
|
|
@@ -96,7 +109,7 @@ export default (new Transformer({
|
|
|
96
109
|
}
|
|
97
110
|
|
|
98
111
|
if (
|
|
99
|
-
cssModulesConfig?.exclude?.some((exclude) =>
|
|
112
|
+
cssModulesConfig?.exclude?.some((exclude: any) =>
|
|
100
113
|
exclude.test(projectRootPath),
|
|
101
114
|
)
|
|
102
115
|
) {
|
|
@@ -126,13 +139,16 @@ export default (new Transformer({
|
|
|
126
139
|
}
|
|
127
140
|
: false,
|
|
128
141
|
sourceMap: !!asset.env.sourceMap,
|
|
142
|
+
// @ts-expect-error TS2339
|
|
129
143
|
drafts: config?.drafts,
|
|
144
|
+
// @ts-expect-error TS2339
|
|
130
145
|
pseudoClasses: config?.pseudoClasses,
|
|
146
|
+
// @ts-expect-error TS2339
|
|
131
147
|
errorRecovery: config?.errorRecovery || false,
|
|
132
148
|
targets,
|
|
133
149
|
});
|
|
134
150
|
}
|
|
135
|
-
} catch (err) {
|
|
151
|
+
} catch (err: any) {
|
|
136
152
|
err.filePath = asset.filePath;
|
|
137
153
|
let diagnostic = errorToDiagnostic(err, {
|
|
138
154
|
origin: '@atlaspack/transformer-css',
|
|
@@ -180,7 +196,9 @@ export default (new Transformer({
|
|
|
180
196
|
}
|
|
181
197
|
}
|
|
182
198
|
|
|
199
|
+
// @ts-expect-error TS2339
|
|
183
200
|
if (res.map != null) {
|
|
201
|
+
// @ts-expect-error TS2339
|
|
184
202
|
let vlqMap = JSON.parse(Buffer.from(res.map).toString());
|
|
185
203
|
let map = new SourceMap(options.projectRoot);
|
|
186
204
|
map.addVLQMap(vlqMap);
|
|
@@ -199,6 +217,7 @@ export default (new Transformer({
|
|
|
199
217
|
loc = remapSourceLocation(loc, originalMap);
|
|
200
218
|
}
|
|
201
219
|
|
|
220
|
+
// @ts-expect-error TS2339
|
|
202
221
|
if (dep.type === 'import' && !res.exports) {
|
|
203
222
|
asset.addDependency({
|
|
204
223
|
specifier: dep.url,
|
|
@@ -226,9 +245,12 @@ export default (new Transformer({
|
|
|
226
245
|
let assets = [asset];
|
|
227
246
|
let buffer = Buffer.from(res.code);
|
|
228
247
|
|
|
248
|
+
// @ts-expect-error TS2339
|
|
229
249
|
if (res.exports != null) {
|
|
250
|
+
// @ts-expect-error TS2339
|
|
230
251
|
let exports = res.exports;
|
|
231
252
|
asset.symbols.ensure();
|
|
253
|
+
// @ts-expect-error TS2345
|
|
232
254
|
asset.symbols.set('default', 'default');
|
|
233
255
|
|
|
234
256
|
let dependencies = new Map();
|
|
@@ -238,7 +260,7 @@ export default (new Transformer({
|
|
|
238
260
|
let js = '';
|
|
239
261
|
let cssImports = '';
|
|
240
262
|
|
|
241
|
-
let jsDeps = [];
|
|
263
|
+
let jsDeps: Array<never> = [];
|
|
242
264
|
|
|
243
265
|
for (let key in exports) {
|
|
244
266
|
locals.set(exports[key].name, key);
|
|
@@ -247,7 +269,7 @@ export default (new Transformer({
|
|
|
247
269
|
asset.uniqueKey ??= asset.id;
|
|
248
270
|
|
|
249
271
|
let seen = new Set();
|
|
250
|
-
let add = (key) => {
|
|
272
|
+
let add = (key: string) => {
|
|
251
273
|
if (seen.has(key)) {
|
|
252
274
|
return;
|
|
253
275
|
}
|
|
@@ -299,6 +321,7 @@ export default (new Transformer({
|
|
|
299
321
|
asset.addDependency({
|
|
300
322
|
specifier: nullthrows(asset.uniqueKey),
|
|
301
323
|
specifierType: 'esm',
|
|
324
|
+
// @ts-expect-error TS2322
|
|
302
325
|
symbols: new Map([
|
|
303
326
|
[key, {local: exports[key].name, isWeak: false, loc: null}],
|
|
304
327
|
]),
|
|
@@ -311,6 +334,7 @@ export default (new Transformer({
|
|
|
311
334
|
// It's possible that the exports can be ordered differently between builds.
|
|
312
335
|
// Sorting by key is safe as the order is irrelevant but needs to be deterministic.
|
|
313
336
|
for (let key of Object.keys(exports).sort()) {
|
|
337
|
+
// @ts-expect-error TS2345
|
|
314
338
|
asset.symbols.set(key, exports[key].name);
|
|
315
339
|
add(key);
|
|
316
340
|
}
|
|
@@ -322,12 +346,15 @@ export default (new Transformer({
|
|
|
322
346
|
let d = `dep_$${c++}`;
|
|
323
347
|
depjs += `import * as ${d} from ${JSON.stringify(dep.url)};\n`;
|
|
324
348
|
js += `for (let key in ${d}) { if (key in module.exports) module.exports[key] += ' ' + ${d}[key]; else module.exports[key] = ${d}[key]; }\n`;
|
|
349
|
+
// @ts-expect-error TS2345
|
|
325
350
|
asset.symbols.set('*', '*');
|
|
326
351
|
}
|
|
327
352
|
}
|
|
328
353
|
}
|
|
329
354
|
|
|
355
|
+
// @ts-expect-error TS2339
|
|
330
356
|
if (res.references != null) {
|
|
357
|
+
// @ts-expect-error TS2339
|
|
331
358
|
let references = res.references;
|
|
332
359
|
for (let symbol in references) {
|
|
333
360
|
let reference = references[symbol];
|
|
@@ -335,6 +362,7 @@ export default (new Transformer({
|
|
|
335
362
|
specifier: reference.specifier,
|
|
336
363
|
specifierType: 'esm',
|
|
337
364
|
packageConditions: ['style'],
|
|
365
|
+
// @ts-expect-error TS2322
|
|
338
366
|
symbols: new Map([
|
|
339
367
|
[reference.name, {local: symbol, isWeak: false, loc: null}],
|
|
340
368
|
]),
|
|
@@ -347,6 +375,7 @@ export default (new Transformer({
|
|
|
347
375
|
|
|
348
376
|
assets.push({
|
|
349
377
|
type: 'js',
|
|
378
|
+
// @ts-expect-error TS2353
|
|
350
379
|
content: depjs + js,
|
|
351
380
|
dependencies: jsDeps,
|
|
352
381
|
env,
|
|
@@ -361,11 +390,11 @@ export default (new Transformer({
|
|
|
361
390
|
asset.setBuffer(buffer);
|
|
362
391
|
return assets;
|
|
363
392
|
},
|
|
364
|
-
})
|
|
393
|
+
}) as Transformer<unknown>;
|
|
365
394
|
|
|
366
395
|
let cache = new Map();
|
|
367
396
|
|
|
368
|
-
function getTargets(browsers) {
|
|
397
|
+
function getTargets(browsers: undefined | string | Array<string>) {
|
|
369
398
|
if (browsers == null) {
|
|
370
399
|
return undefined;
|
|
371
400
|
}
|
package/tsconfig.json
ADDED