@atlaspack/transformer-css 2.14.5-canary.28 → 2.14.5-canary.280
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 +270 -0
- package/dist/CSSTransformer.js +405 -0
- package/lib/CSSTransformer.js +59 -6
- package/lib/types/CSSTransformer.d.ts +3 -0
- package/package.json +14 -8
- package/src/{CSSTransformer.js → CSSTransformer.ts} +69 -17
- package/tsconfig.json +24 -0
- package/tsconfig.tsbuildinfo +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,275 @@
|
|
|
1
1
|
# @atlaspack/transformer-css
|
|
2
2
|
|
|
3
|
+
## 2.14.37
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`373ee2d`](https://github.com/atlassian-labs/atlaspack/commit/373ee2d3b5cc315df1e90e647619f915892e2b87)]:
|
|
8
|
+
- @atlaspack/feature-flags@2.26.1
|
|
9
|
+
- @atlaspack/utils@3.1.1
|
|
10
|
+
- @atlaspack/plugin@2.14.37
|
|
11
|
+
- @atlaspack/types@2.15.27
|
|
12
|
+
|
|
13
|
+
## 2.14.36
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [[`58527ee`](https://github.com/atlassian-labs/atlaspack/commit/58527eec15c1aebaaadbeb63586f3082c16beae3), [`cfb39a0`](https://github.com/atlassian-labs/atlaspack/commit/cfb39a0d729eb620cf2ca1611750a2bf7a080d08), [`d0c7bea`](https://github.com/atlassian-labs/atlaspack/commit/d0c7bea04458255b4c5d4299600e734b5f919fe1), [`9cd9521`](https://github.com/atlassian-labs/atlaspack/commit/9cd9521978f783046e2ae4ce78f2de7aeb07d073), [`5776be2`](https://github.com/atlassian-labs/atlaspack/commit/5776be21f70a3f2b9471ba33da3ba1a883f21f1a)]:
|
|
18
|
+
- @atlaspack/feature-flags@2.26.0
|
|
19
|
+
- @atlaspack/utils@3.1.0
|
|
20
|
+
- @atlaspack/plugin@2.14.36
|
|
21
|
+
- @atlaspack/types@2.15.26
|
|
22
|
+
|
|
23
|
+
## 2.14.35
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- Updated dependencies [[`79a7e22`](https://github.com/atlassian-labs/atlaspack/commit/79a7e22ef119891a2f4180a9d3cc66b38dd52092), [`3da8e69`](https://github.com/atlassian-labs/atlaspack/commit/3da8e690605472d81c531366b65fa9844f8ca337), [`c372f3f`](https://github.com/atlassian-labs/atlaspack/commit/c372f3fd6fce8200d5cf47f41bc7895c6cbb5558), [`17dfea9`](https://github.com/atlassian-labs/atlaspack/commit/17dfea9e9f3169807808520df9c09ebf70dc8b10), [`f1070ec`](https://github.com/atlassian-labs/atlaspack/commit/f1070ec48e99b4ec111a03179c5ab5b74163fab1)]:
|
|
28
|
+
- @atlaspack/feature-flags@2.25.5
|
|
29
|
+
- @atlaspack/utils@3.0.3
|
|
30
|
+
- @atlaspack/plugin@2.14.35
|
|
31
|
+
- @atlaspack/types@2.15.25
|
|
32
|
+
|
|
33
|
+
## 2.14.34
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- Updated dependencies [[`662d3c6`](https://github.com/atlassian-labs/atlaspack/commit/662d3c627888b16bf27df15cfac5a9094509e93d)]:
|
|
38
|
+
- @atlaspack/feature-flags@2.25.4
|
|
39
|
+
- @atlaspack/types@2.15.24
|
|
40
|
+
- @atlaspack/utils@3.0.2
|
|
41
|
+
- @atlaspack/plugin@2.14.34
|
|
42
|
+
|
|
43
|
+
## 2.14.33
|
|
44
|
+
|
|
45
|
+
### Patch Changes
|
|
46
|
+
|
|
47
|
+
- Updated dependencies [[`236e546`](https://github.com/atlassian-labs/atlaspack/commit/236e5465863dca6044a7191e05260a5b924c342e), [`f07351a`](https://github.com/atlassian-labs/atlaspack/commit/f07351a2398b6a8e5155a2daad77e69b7dcb2b4b)]:
|
|
48
|
+
- @atlaspack/utils@3.0.1
|
|
49
|
+
- @atlaspack/feature-flags@2.25.3
|
|
50
|
+
- @atlaspack/types@2.15.23
|
|
51
|
+
- @atlaspack/plugin@2.14.33
|
|
52
|
+
|
|
53
|
+
## 2.14.32
|
|
54
|
+
|
|
55
|
+
### Patch Changes
|
|
56
|
+
|
|
57
|
+
- [#800](https://github.com/atlassian-labs/atlaspack/pull/800) [`1180103`](https://github.com/atlassian-labs/atlaspack/commit/118010351ed444f8178988afb3f77807154dd933) Thanks [@mattcompiles](https://github.com/mattcompiles)! - Fix errors when creating diagnostics with relative file paths
|
|
58
|
+
|
|
59
|
+
BREAKING CHANGE: The `remapSourceLocation` API in `@atlaspack/utils` now requires the project root
|
|
60
|
+
|
|
61
|
+
- Updated dependencies [[`0207171`](https://github.com/atlassian-labs/atlaspack/commit/0207171e59e985c51e105aec2e0a99de174374bd), [`10ee3fa`](https://github.com/atlassian-labs/atlaspack/commit/10ee3fa5b75a92acde8973673d9b3c5b6f3958e5), [`1180103`](https://github.com/atlassian-labs/atlaspack/commit/118010351ed444f8178988afb3f77807154dd933), [`2bc93b1`](https://github.com/atlassian-labs/atlaspack/commit/2bc93b17cea07fd7cbb68acec84d8471345a22b4)]:
|
|
62
|
+
- @atlaspack/feature-flags@2.25.2
|
|
63
|
+
- @atlaspack/utils@3.0.0
|
|
64
|
+
- @atlaspack/plugin@2.14.32
|
|
65
|
+
- @atlaspack/types@2.15.22
|
|
66
|
+
|
|
67
|
+
## 2.14.31
|
|
68
|
+
|
|
69
|
+
### Patch Changes
|
|
70
|
+
|
|
71
|
+
- [#785](https://github.com/atlassian-labs/atlaspack/pull/785) [`0e7dd5e`](https://github.com/atlassian-labs/atlaspack/commit/0e7dd5ec6fbe05aa9e0bb5775a9d0975f206a922) Thanks [@matt-koko](https://github.com/matt-koko)! - We need to re-publish every package in Atlaspack with the corrected types field.
|
|
72
|
+
|
|
73
|
+
- Updated dependencies [[`0e7dd5e`](https://github.com/atlassian-labs/atlaspack/commit/0e7dd5ec6fbe05aa9e0bb5775a9d0975f206a922)]:
|
|
74
|
+
- @atlaspack/diagnostic@2.14.4
|
|
75
|
+
- @atlaspack/feature-flags@2.25.1
|
|
76
|
+
- @atlaspack/plugin@2.14.31
|
|
77
|
+
- @atlaspack/types@2.15.21
|
|
78
|
+
- @atlaspack/utils@2.19.3
|
|
79
|
+
|
|
80
|
+
## 2.14.30
|
|
81
|
+
|
|
82
|
+
### Patch Changes
|
|
83
|
+
|
|
84
|
+
- [#779](https://github.com/atlassian-labs/atlaspack/pull/779) [`7a52bab`](https://github.com/atlassian-labs/atlaspack/commit/7a52bab6281e8edbfa66af248eb6f872c6b4b7bd) Thanks [@marcins](https://github.com/marcins)! - Add new feature flag `preserveUnstableSingleFileOutputInCss` which when enabled will ensure the `unstableSingleFileOutput` property on the asset environment is preserved when transforming CSS.
|
|
85
|
+
|
|
86
|
+
- Updated dependencies [[`7a52bab`](https://github.com/atlassian-labs/atlaspack/commit/7a52bab6281e8edbfa66af248eb6f872c6b4b7bd), [`038e87a`](https://github.com/atlassian-labs/atlaspack/commit/038e87a7858d39556d59d3a2d17db534d45f62c6), [`f6532d7`](https://github.com/atlassian-labs/atlaspack/commit/f6532d7a4f7f007bd4e5e36af04dd466f0b9f572), [`602f8ed`](https://github.com/atlassian-labs/atlaspack/commit/602f8ed9d8381301df8b2cc82c1d5cf6f2f94fec)]:
|
|
87
|
+
- @atlaspack/feature-flags@2.25.0
|
|
88
|
+
- @atlaspack/utils@2.19.2
|
|
89
|
+
- @atlaspack/plugin@2.14.30
|
|
90
|
+
- @atlaspack/types@2.15.20
|
|
91
|
+
|
|
92
|
+
## 2.14.29
|
|
93
|
+
|
|
94
|
+
### Patch Changes
|
|
95
|
+
|
|
96
|
+
- Updated dependencies []:
|
|
97
|
+
- @atlaspack/utils@2.19.1
|
|
98
|
+
- @atlaspack/plugin@2.14.29
|
|
99
|
+
- @atlaspack/types@2.15.19
|
|
100
|
+
|
|
101
|
+
## 2.14.28
|
|
102
|
+
|
|
103
|
+
### Patch Changes
|
|
104
|
+
|
|
105
|
+
- Updated dependencies [[`f0349a6`](https://github.com/atlassian-labs/atlaspack/commit/f0349a6b9b04755088f121095ca6301a2ada3767)]:
|
|
106
|
+
- @atlaspack/utils@2.19.0
|
|
107
|
+
- @atlaspack/plugin@2.14.28
|
|
108
|
+
- @atlaspack/types@2.15.18
|
|
109
|
+
|
|
110
|
+
## 2.14.27
|
|
111
|
+
|
|
112
|
+
### Patch Changes
|
|
113
|
+
|
|
114
|
+
- [#752](https://github.com/atlassian-labs/atlaspack/pull/752) [`a0aed1d`](https://github.com/atlassian-labs/atlaspack/commit/a0aed1dac6111096f7061675ac16a1417cbf6a17) Thanks [@marcins](https://github.com/marcins)! - Fix missing dependencies in package.json
|
|
115
|
+
|
|
116
|
+
- Updated dependencies []:
|
|
117
|
+
- @atlaspack/utils@2.18.4
|
|
118
|
+
- @atlaspack/plugin@2.14.27
|
|
119
|
+
- @atlaspack/types@2.15.17
|
|
120
|
+
|
|
121
|
+
## 2.14.26
|
|
122
|
+
|
|
123
|
+
### Patch Changes
|
|
124
|
+
|
|
125
|
+
- [#742](https://github.com/atlassian-labs/atlaspack/pull/742) [`ee040bb`](https://github.com/atlassian-labs/atlaspack/commit/ee040bb6428f29b57d892ddd8107e29077d08ffd) Thanks [@yamadapc](https://github.com/yamadapc)! - Internal changes and bug fixes to environmentDeduplication flag
|
|
126
|
+
|
|
127
|
+
- Updated dependencies [[`ee040bb`](https://github.com/atlassian-labs/atlaspack/commit/ee040bb6428f29b57d892ddd8107e29077d08ffd), [`889c65c`](https://github.com/atlassian-labs/atlaspack/commit/889c65cd25b811045e26a117e7404f694dde77a2)]:
|
|
128
|
+
- @atlaspack/diagnostic@2.14.3
|
|
129
|
+
- @atlaspack/plugin@2.14.26
|
|
130
|
+
- @atlaspack/utils@2.18.3
|
|
131
|
+
|
|
132
|
+
## 2.14.25
|
|
133
|
+
|
|
134
|
+
### Patch Changes
|
|
135
|
+
|
|
136
|
+
- Updated dependencies []:
|
|
137
|
+
- @atlaspack/utils@2.18.2
|
|
138
|
+
- @atlaspack/plugin@2.14.25
|
|
139
|
+
|
|
140
|
+
## 2.14.24
|
|
141
|
+
|
|
142
|
+
### Patch Changes
|
|
143
|
+
|
|
144
|
+
- Updated dependencies []:
|
|
145
|
+
- @atlaspack/utils@2.18.1
|
|
146
|
+
- @atlaspack/plugin@2.14.24
|
|
147
|
+
|
|
148
|
+
## 2.14.23
|
|
149
|
+
|
|
150
|
+
### Patch Changes
|
|
151
|
+
|
|
152
|
+
- Updated dependencies [[`23d561e`](https://github.com/atlassian-labs/atlaspack/commit/23d561e51e68b0c38fd1ff4e4fb173e5e7b01cf2)]:
|
|
153
|
+
- @atlaspack/utils@2.18.0
|
|
154
|
+
- @atlaspack/plugin@2.14.23
|
|
155
|
+
|
|
156
|
+
## 2.14.22
|
|
157
|
+
|
|
158
|
+
### Patch Changes
|
|
159
|
+
|
|
160
|
+
- [#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
|
|
161
|
+
|
|
162
|
+
- Updated dependencies [[`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94)]:
|
|
163
|
+
- @atlaspack/diagnostic@2.14.2
|
|
164
|
+
- @atlaspack/plugin@2.14.22
|
|
165
|
+
- @atlaspack/utils@2.17.4
|
|
166
|
+
|
|
167
|
+
## 2.14.21
|
|
168
|
+
|
|
169
|
+
### Patch Changes
|
|
170
|
+
|
|
171
|
+
- Updated dependencies []:
|
|
172
|
+
- @atlaspack/utils@2.17.3
|
|
173
|
+
- @atlaspack/plugin@2.14.21
|
|
174
|
+
|
|
175
|
+
## 2.14.20
|
|
176
|
+
|
|
177
|
+
### Patch Changes
|
|
178
|
+
|
|
179
|
+
- [#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
|
|
180
|
+
|
|
181
|
+
- Updated dependencies [[`daaa768`](https://github.com/atlassian-labs/atlaspack/commit/daaa7688786772d7e3713b71c5bba6b89ec704aa)]:
|
|
182
|
+
- @atlaspack/plugin@2.14.20
|
|
183
|
+
- @atlaspack/utils@2.17.2
|
|
184
|
+
|
|
185
|
+
## 2.14.19
|
|
186
|
+
|
|
187
|
+
### Patch Changes
|
|
188
|
+
|
|
189
|
+
- Updated dependencies []:
|
|
190
|
+
- @atlaspack/utils@2.17.1
|
|
191
|
+
- @atlaspack/plugin@2.14.19
|
|
192
|
+
|
|
193
|
+
## 2.14.18
|
|
194
|
+
|
|
195
|
+
### Patch Changes
|
|
196
|
+
|
|
197
|
+
- 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)]:
|
|
198
|
+
- @atlaspack/utils@2.17.0
|
|
199
|
+
- @atlaspack/plugin@2.14.18
|
|
200
|
+
|
|
201
|
+
## 2.14.17
|
|
202
|
+
|
|
203
|
+
### Patch Changes
|
|
204
|
+
|
|
205
|
+
- Updated dependencies []:
|
|
206
|
+
- @atlaspack/utils@2.16.1
|
|
207
|
+
- @atlaspack/plugin@2.14.17
|
|
208
|
+
|
|
209
|
+
## 2.14.16
|
|
210
|
+
|
|
211
|
+
### Patch Changes
|
|
212
|
+
|
|
213
|
+
- Updated dependencies [[`30ee2cf`](https://github.com/atlassian-labs/atlaspack/commit/30ee2cfcd34cf2646ded0eda13fdb80a2a5de529)]:
|
|
214
|
+
- @atlaspack/utils@2.16.0
|
|
215
|
+
- @atlaspack/plugin@2.14.16
|
|
216
|
+
|
|
217
|
+
## 2.14.15
|
|
218
|
+
|
|
219
|
+
### Patch Changes
|
|
220
|
+
|
|
221
|
+
- Updated dependencies []:
|
|
222
|
+
- @atlaspack/utils@2.15.3
|
|
223
|
+
- @atlaspack/plugin@2.14.15
|
|
224
|
+
|
|
225
|
+
## 2.14.14
|
|
226
|
+
|
|
227
|
+
### Patch Changes
|
|
228
|
+
|
|
229
|
+
- Updated dependencies []:
|
|
230
|
+
- @atlaspack/utils@2.15.2
|
|
231
|
+
- @atlaspack/plugin@2.14.14
|
|
232
|
+
|
|
233
|
+
## 2.14.13
|
|
234
|
+
|
|
235
|
+
### Patch Changes
|
|
236
|
+
|
|
237
|
+
- Updated dependencies []:
|
|
238
|
+
- @atlaspack/utils@2.15.1
|
|
239
|
+
- @atlaspack/plugin@2.14.13
|
|
240
|
+
|
|
241
|
+
## 2.14.12
|
|
242
|
+
|
|
243
|
+
### Patch Changes
|
|
244
|
+
|
|
245
|
+
- Updated dependencies [[`e39c6cf`](https://github.com/atlassian-labs/atlaspack/commit/e39c6cf05f7e95ce5420dbcea66f401b1cbd397c)]:
|
|
246
|
+
- @atlaspack/utils@2.15.0
|
|
247
|
+
- @atlaspack/plugin@2.14.12
|
|
248
|
+
|
|
249
|
+
## 2.14.11
|
|
250
|
+
|
|
251
|
+
### Patch Changes
|
|
252
|
+
|
|
253
|
+
- Updated dependencies []:
|
|
254
|
+
- @atlaspack/utils@2.14.11
|
|
255
|
+
- @atlaspack/plugin@2.14.11
|
|
256
|
+
|
|
257
|
+
## 2.14.10
|
|
258
|
+
|
|
259
|
+
### Patch Changes
|
|
260
|
+
|
|
261
|
+
- Updated dependencies []:
|
|
262
|
+
- @atlaspack/plugin@2.14.10
|
|
263
|
+
- @atlaspack/utils@2.14.10
|
|
264
|
+
|
|
265
|
+
## 2.14.9
|
|
266
|
+
|
|
267
|
+
### Patch Changes
|
|
268
|
+
|
|
269
|
+
- Updated dependencies []:
|
|
270
|
+
- @atlaspack/utils@2.14.9
|
|
271
|
+
- @atlaspack/plugin@2.14.9
|
|
272
|
+
|
|
3
273
|
## 2.14.8
|
|
4
274
|
|
|
5
275
|
### Patch Changes
|
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
const path_1 = __importDefault(require("path"));
|
|
40
|
+
const source_map_1 = __importDefault(require("@parcel/source-map"));
|
|
41
|
+
const plugin_1 = require("@atlaspack/plugin");
|
|
42
|
+
const utils_1 = require("@atlaspack/utils");
|
|
43
|
+
const native = __importStar(require("lightningcss"));
|
|
44
|
+
const browserslist_1 = __importDefault(require("browserslist"));
|
|
45
|
+
const nullthrows_1 = __importDefault(require("nullthrows"));
|
|
46
|
+
const diagnostic_1 = __importStar(require("@atlaspack/diagnostic"));
|
|
47
|
+
const feature_flags_1 = require("@atlaspack/feature-flags");
|
|
48
|
+
const { transform, transformStyleAttribute, browserslistToTargets } = native;
|
|
49
|
+
exports.default = new plugin_1.Transformer({
|
|
50
|
+
async loadConfig({ config, options }) {
|
|
51
|
+
let conf = await config.getConfigFrom(options.projectRoot + '/index', [], {
|
|
52
|
+
packageKey: '@atlaspack/transformer-css',
|
|
53
|
+
});
|
|
54
|
+
let contents = conf?.contents;
|
|
55
|
+
// @ts-expect-error TS2339
|
|
56
|
+
if (typeof contents?.cssModules?.include === 'string') {
|
|
57
|
+
// @ts-expect-error TS2339
|
|
58
|
+
contents.cssModules.include = [(0, utils_1.globToRegex)(contents.cssModules.include)];
|
|
59
|
+
// @ts-expect-error TS2339
|
|
60
|
+
}
|
|
61
|
+
else if (Array.isArray(contents?.cssModules?.include)) {
|
|
62
|
+
// @ts-expect-error TS2339
|
|
63
|
+
contents.cssModules.include = contents.cssModules.include.map(
|
|
64
|
+
// @ts-expect-error TS7006
|
|
65
|
+
(include) => typeof include === 'string' ? (0, utils_1.globToRegex)(include) : include);
|
|
66
|
+
}
|
|
67
|
+
// @ts-expect-error TS2339
|
|
68
|
+
if (typeof contents?.cssModules?.exclude === 'string') {
|
|
69
|
+
// @ts-expect-error TS2339
|
|
70
|
+
contents.cssModules.exclude = [(0, utils_1.globToRegex)(contents.cssModules.exclude)];
|
|
71
|
+
// @ts-expect-error TS2339
|
|
72
|
+
}
|
|
73
|
+
else if (Array.isArray(contents?.cssModules?.exclude)) {
|
|
74
|
+
// @ts-expect-error TS2339
|
|
75
|
+
contents.cssModules.exclude = contents.cssModules.exclude.map(
|
|
76
|
+
// @ts-expect-error TS7006
|
|
77
|
+
(exclude) => typeof exclude === 'string' ? (0, utils_1.globToRegex)(exclude) : exclude);
|
|
78
|
+
}
|
|
79
|
+
return contents;
|
|
80
|
+
},
|
|
81
|
+
async transform({ asset, config, options, logger }) {
|
|
82
|
+
if ((0, feature_flags_1.getFeatureFlag)('compiledCssInJsTransformer') &&
|
|
83
|
+
asset.filePath.endsWith('.compiled.css')) {
|
|
84
|
+
return handleCompiledCssAsset(asset);
|
|
85
|
+
}
|
|
86
|
+
// Normalize the asset's environment so that properties that only affect JS don't cause CSS to be duplicated.
|
|
87
|
+
// For example, with ESModule and CommonJS targets, only a single shared CSS bundle should be produced.
|
|
88
|
+
let env = asset.env;
|
|
89
|
+
asset.setEnvironment({
|
|
90
|
+
context: 'browser',
|
|
91
|
+
engines: {
|
|
92
|
+
browsers: asset.env.engines.browsers,
|
|
93
|
+
},
|
|
94
|
+
shouldOptimize: asset.env.shouldOptimize,
|
|
95
|
+
shouldScopeHoist: asset.env.shouldScopeHoist,
|
|
96
|
+
sourceMap: asset.env.sourceMap,
|
|
97
|
+
unstableSingleFileOutput: (0, feature_flags_1.getFeatureFlag)('preserveUnstableSingleFileOutputInCss')
|
|
98
|
+
? asset.env.unstableSingleFileOutput
|
|
99
|
+
: undefined,
|
|
100
|
+
});
|
|
101
|
+
let [code, originalMap] = await Promise.all([
|
|
102
|
+
asset.getBuffer(),
|
|
103
|
+
asset.getMap(),
|
|
104
|
+
// @ts-expect-error TS2339
|
|
105
|
+
process.browser && native.default(),
|
|
106
|
+
]);
|
|
107
|
+
let targets = getTargets(asset.env.engines.browsers);
|
|
108
|
+
let res;
|
|
109
|
+
try {
|
|
110
|
+
if (asset.meta.type === 'attr') {
|
|
111
|
+
res = transformStyleAttribute({
|
|
112
|
+
code,
|
|
113
|
+
analyzeDependencies: true,
|
|
114
|
+
// @ts-expect-error TS2339
|
|
115
|
+
errorRecovery: config?.errorRecovery || false,
|
|
116
|
+
targets,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
let cssModules = false;
|
|
121
|
+
if (asset.meta.type !== 'tag' &&
|
|
122
|
+
asset.meta.cssModulesCompiled == null) {
|
|
123
|
+
// @ts-expect-error TS2339
|
|
124
|
+
let cssModulesConfig = config?.cssModules;
|
|
125
|
+
let isCSSModule = /\.module\./.test(asset.filePath);
|
|
126
|
+
if (asset.isSource) {
|
|
127
|
+
let projectRootPath = path_1.default.relative(options.projectRoot, asset.filePath);
|
|
128
|
+
if (typeof cssModulesConfig === 'boolean') {
|
|
129
|
+
isCSSModule = true;
|
|
130
|
+
}
|
|
131
|
+
else if (cssModulesConfig?.include) {
|
|
132
|
+
// @ts-expect-error TS7006
|
|
133
|
+
isCSSModule = cssModulesConfig.include.some((include) => include.test(projectRootPath));
|
|
134
|
+
}
|
|
135
|
+
else if (cssModulesConfig?.global) {
|
|
136
|
+
isCSSModule = true;
|
|
137
|
+
}
|
|
138
|
+
if (cssModulesConfig?.exclude?.some((exclude) => exclude.test(projectRootPath))) {
|
|
139
|
+
isCSSModule = false;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (isCSSModule) {
|
|
143
|
+
if (cssModulesConfig?.dashedIdents && !asset.isSource) {
|
|
144
|
+
cssModulesConfig.dashedIdents = false;
|
|
145
|
+
}
|
|
146
|
+
cssModules = cssModulesConfig ?? true;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
res = transform({
|
|
150
|
+
filename: (0, utils_1.normalizeSeparators)(path_1.default.relative(options.projectRoot, asset.filePath)),
|
|
151
|
+
code,
|
|
152
|
+
cssModules,
|
|
153
|
+
analyzeDependencies: asset.meta.hasDependencies !== false
|
|
154
|
+
? {
|
|
155
|
+
preserveImports: true,
|
|
156
|
+
}
|
|
157
|
+
: false,
|
|
158
|
+
sourceMap: !!asset.env.sourceMap,
|
|
159
|
+
// @ts-expect-error TS2339
|
|
160
|
+
drafts: config?.drafts,
|
|
161
|
+
// @ts-expect-error TS2339
|
|
162
|
+
pseudoClasses: config?.pseudoClasses,
|
|
163
|
+
// @ts-expect-error TS2339
|
|
164
|
+
errorRecovery: config?.errorRecovery || false,
|
|
165
|
+
targets,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
catch (err) {
|
|
170
|
+
err.filePath = asset.filePath;
|
|
171
|
+
let diagnostic = (0, diagnostic_1.errorToDiagnostic)(err, {
|
|
172
|
+
origin: '@atlaspack/transformer-css',
|
|
173
|
+
});
|
|
174
|
+
if (err.data?.type === 'AmbiguousUrlInCustomProperty' && err.data.url) {
|
|
175
|
+
let p = '/' +
|
|
176
|
+
(0, utils_1.relativePath)(options.projectRoot, path_1.default.resolve(path_1.default.dirname(asset.filePath), err.data.url), false);
|
|
177
|
+
diagnostic[0].hints = [`Replace with: url(${p})`];
|
|
178
|
+
diagnostic[0].documentationURL =
|
|
179
|
+
'https://parceljs.org/languages/css/#url()';
|
|
180
|
+
}
|
|
181
|
+
throw new diagnostic_1.default({
|
|
182
|
+
diagnostic,
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
if (res.warnings) {
|
|
186
|
+
for (let warning of res.warnings) {
|
|
187
|
+
logger.warn({
|
|
188
|
+
message: warning.message,
|
|
189
|
+
codeFrames: [
|
|
190
|
+
{
|
|
191
|
+
filePath: asset.filePath,
|
|
192
|
+
codeHighlights: [
|
|
193
|
+
{
|
|
194
|
+
start: {
|
|
195
|
+
line: warning.loc.line,
|
|
196
|
+
column: warning.loc.column + 1,
|
|
197
|
+
},
|
|
198
|
+
end: {
|
|
199
|
+
line: warning.loc.line,
|
|
200
|
+
column: warning.loc.column + 1,
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
],
|
|
204
|
+
},
|
|
205
|
+
],
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
// @ts-expect-error TS2339
|
|
210
|
+
if (res.map != null) {
|
|
211
|
+
// @ts-expect-error TS2339
|
|
212
|
+
let vlqMap = JSON.parse(Buffer.from(res.map).toString());
|
|
213
|
+
let map = new source_map_1.default(options.projectRoot);
|
|
214
|
+
map.addVLQMap(vlqMap);
|
|
215
|
+
if (originalMap) {
|
|
216
|
+
map.extends(originalMap);
|
|
217
|
+
}
|
|
218
|
+
asset.setMap(map);
|
|
219
|
+
}
|
|
220
|
+
if (res.dependencies) {
|
|
221
|
+
for (let dep of res.dependencies) {
|
|
222
|
+
let loc = convertLoc(dep.loc);
|
|
223
|
+
if (originalMap) {
|
|
224
|
+
loc = (0, utils_1.remapSourceLocation)(loc, originalMap, options.projectRoot);
|
|
225
|
+
}
|
|
226
|
+
// @ts-expect-error TS2339
|
|
227
|
+
if (dep.type === 'import' && !res.exports) {
|
|
228
|
+
asset.addDependency({
|
|
229
|
+
specifier: dep.url,
|
|
230
|
+
specifierType: 'url',
|
|
231
|
+
loc,
|
|
232
|
+
packageConditions: ['style'],
|
|
233
|
+
meta: {
|
|
234
|
+
// For the glob resolver to distinguish between `@import` and other URL dependencies.
|
|
235
|
+
isCSSImport: true,
|
|
236
|
+
media: dep.media,
|
|
237
|
+
placeholder: dep.placeholder,
|
|
238
|
+
},
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
else if (dep.type === 'url') {
|
|
242
|
+
asset.addURLDependency(dep.url, {
|
|
243
|
+
loc,
|
|
244
|
+
meta: {
|
|
245
|
+
placeholder: dep.placeholder,
|
|
246
|
+
},
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
let assets = [asset];
|
|
252
|
+
let buffer = Buffer.from(res.code);
|
|
253
|
+
// @ts-expect-error TS2339
|
|
254
|
+
if (res.exports != null) {
|
|
255
|
+
// @ts-expect-error TS2339
|
|
256
|
+
let exports = res.exports;
|
|
257
|
+
asset.symbols.ensure();
|
|
258
|
+
asset.symbols.set('default', 'default');
|
|
259
|
+
let dependencies = new Map();
|
|
260
|
+
let locals = new Map();
|
|
261
|
+
let c = 0;
|
|
262
|
+
let depjs = '';
|
|
263
|
+
let js = '';
|
|
264
|
+
let cssImports = '';
|
|
265
|
+
let jsDeps = [];
|
|
266
|
+
for (let key in exports) {
|
|
267
|
+
locals.set(exports[key].name, key);
|
|
268
|
+
}
|
|
269
|
+
asset.uniqueKey ?? (asset.uniqueKey = asset.id);
|
|
270
|
+
let seen = new Set();
|
|
271
|
+
let add = (key) => {
|
|
272
|
+
if (seen.has(key)) {
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
seen.add(key);
|
|
276
|
+
let e = exports[key];
|
|
277
|
+
let s = `module.exports[${JSON.stringify(key)}] = \`${e.name}`;
|
|
278
|
+
for (let ref of e.composes) {
|
|
279
|
+
s += ' ';
|
|
280
|
+
if (ref.type === 'local') {
|
|
281
|
+
let exported = (0, nullthrows_1.default)(locals.get(ref.name));
|
|
282
|
+
add(exported);
|
|
283
|
+
s += '${' + `module.exports[${JSON.stringify(exported)}]` + '}';
|
|
284
|
+
asset.addDependency({
|
|
285
|
+
specifier: (0, nullthrows_1.default)(asset.uniqueKey),
|
|
286
|
+
specifierType: 'esm',
|
|
287
|
+
symbols: new Map([
|
|
288
|
+
[exported, { local: ref.name, isWeak: false, loc: null }],
|
|
289
|
+
]),
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
else if (ref.type === 'global') {
|
|
293
|
+
s += ref.name;
|
|
294
|
+
}
|
|
295
|
+
else if (ref.type === 'dependency') {
|
|
296
|
+
let d = dependencies.get(ref.specifier);
|
|
297
|
+
if (d == null) {
|
|
298
|
+
d = `dep_${c++}`;
|
|
299
|
+
depjs += `import * as ${d} from ${JSON.stringify(ref.specifier)};\n`;
|
|
300
|
+
dependencies.set(ref.specifier, d);
|
|
301
|
+
cssImports += `@import "${ref.specifier}";\n`;
|
|
302
|
+
asset.addDependency({
|
|
303
|
+
specifier: ref.specifier,
|
|
304
|
+
specifierType: 'esm',
|
|
305
|
+
packageConditions: ['style'],
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
s += '${' + `${d}[${JSON.stringify(ref.name)}]` + '}';
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
s += '`;\n';
|
|
312
|
+
// If the export is referenced internally (e.g. used @keyframes), add a self-reference
|
|
313
|
+
// to the JS so the symbol is retained during tree-shaking.
|
|
314
|
+
if (e.isReferenced) {
|
|
315
|
+
s += `module.exports[${JSON.stringify(key)}];\n`;
|
|
316
|
+
asset.addDependency({
|
|
317
|
+
specifier: (0, nullthrows_1.default)(asset.uniqueKey),
|
|
318
|
+
specifierType: 'esm',
|
|
319
|
+
symbols: new Map([
|
|
320
|
+
[key, { local: exports[key].name, isWeak: false, loc: null }],
|
|
321
|
+
]),
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
js += s;
|
|
325
|
+
};
|
|
326
|
+
// It's possible that the exports can be ordered differently between builds.
|
|
327
|
+
// Sorting by key is safe as the order is irrelevant but needs to be deterministic.
|
|
328
|
+
for (let key of Object.keys(exports).sort()) {
|
|
329
|
+
asset.symbols.set(key, exports[key].name);
|
|
330
|
+
add(key);
|
|
331
|
+
}
|
|
332
|
+
if (res.dependencies) {
|
|
333
|
+
for (let dep of res.dependencies) {
|
|
334
|
+
if (dep.type === 'import') {
|
|
335
|
+
// TODO: Figure out how to treeshake this
|
|
336
|
+
let d = `dep_$${c++}`;
|
|
337
|
+
depjs += `import * as ${d} from ${JSON.stringify(dep.url)};\n`;
|
|
338
|
+
js += `for (let key in ${d}) { if (key in module.exports) module.exports[key] += ' ' + ${d}[key]; else module.exports[key] = ${d}[key]; }\n`;
|
|
339
|
+
asset.symbols.set('*', '*');
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
// @ts-expect-error TS2339
|
|
344
|
+
if (res.references != null) {
|
|
345
|
+
// @ts-expect-error TS2339
|
|
346
|
+
let references = res.references;
|
|
347
|
+
for (let symbol in references) {
|
|
348
|
+
let reference = references[symbol];
|
|
349
|
+
asset.addDependency({
|
|
350
|
+
specifier: reference.specifier,
|
|
351
|
+
specifierType: 'esm',
|
|
352
|
+
packageConditions: ['style'],
|
|
353
|
+
symbols: new Map([
|
|
354
|
+
[reference.name, { local: symbol, isWeak: false, loc: null }],
|
|
355
|
+
]),
|
|
356
|
+
});
|
|
357
|
+
asset.meta.hasReferences = true;
|
|
358
|
+
cssImports += `@import "${reference.specifier}";\n`;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
assets.push({
|
|
362
|
+
type: 'js',
|
|
363
|
+
// @ts-expect-error TS2353
|
|
364
|
+
content: depjs + js,
|
|
365
|
+
dependencies: jsDeps,
|
|
366
|
+
env,
|
|
367
|
+
});
|
|
368
|
+
// Prepend @import rules for each composes dependency so packager knows where to insert them.
|
|
369
|
+
if (cssImports.length > 0) {
|
|
370
|
+
buffer = Buffer.concat([Buffer.from(cssImports), buffer]);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
asset.setBuffer(buffer);
|
|
374
|
+
return assets;
|
|
375
|
+
},
|
|
376
|
+
});
|
|
377
|
+
let cache = new Map();
|
|
378
|
+
function getTargets(browsers) {
|
|
379
|
+
if (browsers == null) {
|
|
380
|
+
return undefined;
|
|
381
|
+
}
|
|
382
|
+
let cached = cache.get(browsers);
|
|
383
|
+
if (cached != null) {
|
|
384
|
+
return cached;
|
|
385
|
+
}
|
|
386
|
+
let targets = browserslistToTargets((0, browserslist_1.default)(browsers));
|
|
387
|
+
cache.set(browsers, targets);
|
|
388
|
+
return targets;
|
|
389
|
+
}
|
|
390
|
+
function convertLoc(loc) {
|
|
391
|
+
return {
|
|
392
|
+
filePath: loc.filePath,
|
|
393
|
+
start: { line: loc.start.line, column: loc.start.column },
|
|
394
|
+
end: { line: loc.end.line, column: loc.end.column + 1 },
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
async function handleCompiledCssAsset(asset) {
|
|
398
|
+
const code = await asset.getCode();
|
|
399
|
+
const rules = code.split('\n').map((line) => line.trim());
|
|
400
|
+
// styleRules will be consumed by the optimiser in @compiled/parcel-optimizer
|
|
401
|
+
asset.meta.styleRules = rules;
|
|
402
|
+
// Empty the code because we only use compiled CSS assets for their metadata
|
|
403
|
+
asset.setCode('');
|
|
404
|
+
return [asset];
|
|
405
|
+
}
|