@atlaspack/transformer-postcss 2.14.5-canary.30 → 2.14.5-canary.301

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 CHANGED
@@ -1,5 +1,298 @@
1
1
  # @atlaspack/transformer-postcss
2
2
 
3
+ ## 2.14.39
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`7dd5bd8`](https://github.com/atlassian-labs/atlaspack/commit/7dd5bd89ff60c7b324347d772729eb4c3314f01e), [`c8a0e51`](https://github.com/atlassian-labs/atlaspack/commit/c8a0e51b1096d038a64644ad02fe68383f58682a), [`8eb84ee`](https://github.com/atlassian-labs/atlaspack/commit/8eb84ee61a42bfe87c58079b610802b07a6a13e4), [`71900f3`](https://github.com/atlassian-labs/atlaspack/commit/71900f3508d53c3882ca8ea71501ba3069687d4e), [`73168c2`](https://github.com/atlassian-labs/atlaspack/commit/73168c275a5d9abff9907bcf536b340bca1ed5f0), [`617a318`](https://github.com/atlassian-labs/atlaspack/commit/617a318ddc9419b38360257353fec50b9051ee13), [`2c4953e`](https://github.com/atlassian-labs/atlaspack/commit/2c4953e20dc1a6b012792081667aefeb9340505e), [`3fe7d4e`](https://github.com/atlassian-labs/atlaspack/commit/3fe7d4e821bee162fcbbaf9278b107a5eead944f)]:
8
+ - @atlaspack/rust@3.11.0
9
+ - @atlaspack/types-internal@2.21.0
10
+ - @atlaspack/utils@3.2.0
11
+ - @atlaspack/plugin@2.14.39
12
+
13
+ ## 2.14.38
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies [[`ec3abe4`](https://github.com/atlassian-labs/atlaspack/commit/ec3abe4dffc98560a850fd2f71fb566577e6c99c), [`c7fe3f7`](https://github.com/atlassian-labs/atlaspack/commit/c7fe3f76f247e9e20299e205e2df0a16c418eaf2), [`cfb4707`](https://github.com/atlassian-labs/atlaspack/commit/cfb4707087498e4fa4dcf10753fe984a248d196b), [`1468695`](https://github.com/atlassian-labs/atlaspack/commit/1468695fc0c9d06f060a6da9e9b0e154f11dff34), [`f31b041`](https://github.com/atlassian-labs/atlaspack/commit/f31b04107e9077c9946aadb99f6f91bb69703bb7), [`8180981`](https://github.com/atlassian-labs/atlaspack/commit/8180981be14c00f9570adb70d3f350bd91d6ec0a), [`ae77e74`](https://github.com/atlassian-labs/atlaspack/commit/ae77e7452a466b43b3fa5bed24d4ba26345ed765), [`f0a496f`](https://github.com/atlassian-labs/atlaspack/commit/f0a496f70fc8652e090cf1b3f6260e8cfbb796e2), [`7d7a55d`](https://github.com/atlassian-labs/atlaspack/commit/7d7a55dd6395ec391a2e4c33b3dec0d1ea477d4c), [`540f253`](https://github.com/atlassian-labs/atlaspack/commit/540f253dfdcd1a5caebbdc0b197319d439404aae)]:
18
+ - @atlaspack/rust@3.10.0
19
+ - @atlaspack/utils@3.1.2
20
+ - @atlaspack/types-internal@2.20.8
21
+ - @atlaspack/plugin@2.14.38
22
+
23
+ ## 2.14.37
24
+
25
+ ### Patch Changes
26
+
27
+ - Updated dependencies [[`339b600`](https://github.com/atlassian-labs/atlaspack/commit/339b60095d755742cea50f811d08ccc44a4ae521), [`373ee2d`](https://github.com/atlassian-labs/atlaspack/commit/373ee2d3b5cc315df1e90e647619f915892e2b87)]:
28
+ - @atlaspack/rust@3.9.1
29
+ - @atlaspack/utils@3.1.1
30
+ - @atlaspack/types-internal@2.20.7
31
+ - @atlaspack/plugin@2.14.37
32
+
33
+ ## 2.14.36
34
+
35
+ ### Patch Changes
36
+
37
+ - Updated dependencies [[`02f6aa1`](https://github.com/atlassian-labs/atlaspack/commit/02f6aa1906953fc184d2b49c905c2ef815cb878d), [`58527ee`](https://github.com/atlassian-labs/atlaspack/commit/58527eec15c1aebaaadbeb63586f3082c16beae3), [`525898e`](https://github.com/atlassian-labs/atlaspack/commit/525898e33cc229a4bc938ae853732be36d20c01a), [`cfb39a0`](https://github.com/atlassian-labs/atlaspack/commit/cfb39a0d729eb620cf2ca1611750a2bf7a080d08), [`d0c7bea`](https://github.com/atlassian-labs/atlaspack/commit/d0c7bea04458255b4c5d4299600e734b5f919fe1), [`1086c6a`](https://github.com/atlassian-labs/atlaspack/commit/1086c6a2c59271b63b3fb78e6acdb9d3a0dbf354), [`9cd9521`](https://github.com/atlassian-labs/atlaspack/commit/9cd9521978f783046e2ae4ce78f2de7aeb07d073), [`5776be2`](https://github.com/atlassian-labs/atlaspack/commit/5776be21f70a3f2b9471ba33da3ba1a883f21f1a)]:
38
+ - @atlaspack/rust@3.9.0
39
+ - @atlaspack/utils@3.1.0
40
+ - @atlaspack/types-internal@2.20.6
41
+ - @atlaspack/plugin@2.14.36
42
+
43
+ ## 2.14.35
44
+
45
+ ### Patch Changes
46
+
47
+ - Updated dependencies [[`79a7e22`](https://github.com/atlassian-labs/atlaspack/commit/79a7e22ef119891a2f4180a9d3cc66b38dd52092), [`c372f3f`](https://github.com/atlassian-labs/atlaspack/commit/c372f3fd6fce8200d5cf47f41bc7895c6cbb5558), [`17dfea9`](https://github.com/atlassian-labs/atlaspack/commit/17dfea9e9f3169807808520df9c09ebf70dc8b10), [`27fd73f`](https://github.com/atlassian-labs/atlaspack/commit/27fd73fa07d358653f1be6f2d15d72dc5d8fc2fd), [`3091fa3`](https://github.com/atlassian-labs/atlaspack/commit/3091fa36425ecffe3938e55247a035b08cda37a2)]:
48
+ - @atlaspack/rust@3.8.3
49
+ - @atlaspack/types-internal@2.20.5
50
+ - @atlaspack/utils@3.0.3
51
+ - @atlaspack/plugin@2.14.35
52
+
53
+ ## 2.14.34
54
+
55
+ ### Patch Changes
56
+
57
+ - Updated dependencies []:
58
+ - @atlaspack/types-internal@2.20.4
59
+ - @atlaspack/utils@3.0.2
60
+ - @atlaspack/plugin@2.14.34
61
+
62
+ ## 2.14.33
63
+
64
+ ### Patch Changes
65
+
66
+ - Updated dependencies [[`236e546`](https://github.com/atlassian-labs/atlaspack/commit/236e5465863dca6044a7191e05260a5b924c342e)]:
67
+ - @atlaspack/utils@3.0.1
68
+ - @atlaspack/types-internal@2.20.3
69
+ - @atlaspack/plugin@2.14.33
70
+
71
+ ## 2.14.32
72
+
73
+ ### Patch Changes
74
+
75
+ - Updated dependencies [[`0207171`](https://github.com/atlassian-labs/atlaspack/commit/0207171e59e985c51e105aec2e0a99de174374bd), [`bbe4e28`](https://github.com/atlassian-labs/atlaspack/commit/bbe4e28c89e5e9284bd730075d4d6f2a3cb37b21), [`1180103`](https://github.com/atlassian-labs/atlaspack/commit/118010351ed444f8178988afb3f77807154dd933)]:
76
+ - @atlaspack/rust@3.8.2
77
+ - @atlaspack/utils@3.0.0
78
+ - @atlaspack/types-internal@2.20.2
79
+ - @atlaspack/plugin@2.14.32
80
+
81
+ ## 2.14.31
82
+
83
+ ### Patch Changes
84
+
85
+ - [#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.
86
+
87
+ - Updated dependencies [[`0e7dd5e`](https://github.com/atlassian-labs/atlaspack/commit/0e7dd5ec6fbe05aa9e0bb5775a9d0975f206a922), [`686a398`](https://github.com/atlassian-labs/atlaspack/commit/686a398faa1f9e19cbf9274add2c46e246bafba8)]:
88
+ - @atlaspack/diagnostic@2.14.4
89
+ - @atlaspack/plugin@2.14.31
90
+ - @atlaspack/rust@3.8.1
91
+ - @atlaspack/types-internal@2.20.1
92
+ - @atlaspack/utils@2.19.3
93
+
94
+ ## 2.14.30
95
+
96
+ ### Patch Changes
97
+
98
+ - Updated dependencies [[`eedcbc4`](https://github.com/atlassian-labs/atlaspack/commit/eedcbc408fc1e86a2a8e25f1a41c57146d8529e1), [`5a0363f`](https://github.com/atlassian-labs/atlaspack/commit/5a0363f1086e81068959b87e92064bed5a11a9b4), [`038e87a`](https://github.com/atlassian-labs/atlaspack/commit/038e87a7858d39556d59d3a2d17db534d45f62c6), [`f6532d7`](https://github.com/atlassian-labs/atlaspack/commit/f6532d7a4f7f007bd4e5e36af04dd466f0b9f572), [`0684997`](https://github.com/atlassian-labs/atlaspack/commit/0684997c127a6204af1376b36e556fddd1ba5557), [`602f8ed`](https://github.com/atlassian-labs/atlaspack/commit/602f8ed9d8381301df8b2cc82c1d5cf6f2f94fec)]:
99
+ - @atlaspack/types-internal@2.20.0
100
+ - @atlaspack/rust@3.8.0
101
+ - @atlaspack/utils@2.19.2
102
+ - @atlaspack/plugin@2.14.30
103
+
104
+ ## 2.14.29
105
+
106
+ ### Patch Changes
107
+
108
+ - Updated dependencies [[`53dd47b`](https://github.com/atlassian-labs/atlaspack/commit/53dd47bd6d23cd47f87297347f03a609ab38a03d)]:
109
+ - @atlaspack/rust@3.7.0
110
+ - @atlaspack/types-internal@2.19.5
111
+ - @atlaspack/utils@2.19.1
112
+ - @atlaspack/plugin@2.14.29
113
+
114
+ ## 2.14.28
115
+
116
+ ### Patch Changes
117
+
118
+ - Updated dependencies [[`f0349a6`](https://github.com/atlassian-labs/atlaspack/commit/f0349a6b9b04755088f121095ca6301a2ada3767)]:
119
+ - @atlaspack/utils@2.19.0
120
+ - @atlaspack/types-internal@2.19.4
121
+ - @atlaspack/plugin@2.14.28
122
+
123
+ ## 2.14.27
124
+
125
+ ### Patch Changes
126
+
127
+ - Updated dependencies [[`3cfb7cf`](https://github.com/atlassian-labs/atlaspack/commit/3cfb7cfd90b78a5c48ce717e779ff789769825a3)]:
128
+ - @atlaspack/rust@3.6.2
129
+ - @atlaspack/types-internal@2.19.3
130
+ - @atlaspack/utils@2.18.4
131
+ - @atlaspack/plugin@2.14.27
132
+
133
+ ## 2.14.26
134
+
135
+ ### Patch Changes
136
+
137
+ - [#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
138
+
139
+ - Updated dependencies [[`ee040bb`](https://github.com/atlassian-labs/atlaspack/commit/ee040bb6428f29b57d892ddd8107e29077d08ffd), [`889c65c`](https://github.com/atlassian-labs/atlaspack/commit/889c65cd25b811045e26a117e7404f694dde77a2)]:
140
+ - @atlaspack/types-internal@2.19.2
141
+ - @atlaspack/diagnostic@2.14.3
142
+ - @atlaspack/plugin@2.14.26
143
+ - @atlaspack/utils@2.18.3
144
+ - @atlaspack/rust@3.6.1
145
+
146
+ ## 2.14.25
147
+
148
+ ### Patch Changes
149
+
150
+ - Updated dependencies []:
151
+ - @atlaspack/types-internal@2.19.1
152
+ - @atlaspack/utils@2.18.2
153
+ - @atlaspack/plugin@2.14.25
154
+
155
+ ## 2.14.24
156
+
157
+ ### Patch Changes
158
+
159
+ - Updated dependencies [[`ad26146`](https://github.com/atlassian-labs/atlaspack/commit/ad26146f13b4c1cc65d4a0f9c67060b90ef14ff3), [`f1b48e7`](https://github.com/atlassian-labs/atlaspack/commit/f1b48e7a04e005cef0f36a3e692087a9ecdb6f7a), [`7f5841c`](https://github.com/atlassian-labs/atlaspack/commit/7f5841c39df049f9546cccbeea2a7337e0337b45)]:
160
+ - @atlaspack/rust@3.6.0
161
+ - @atlaspack/types-internal@2.19.0
162
+ - @atlaspack/utils@2.18.1
163
+ - @atlaspack/plugin@2.14.24
164
+
165
+ ## 2.14.23
166
+
167
+ ### Patch Changes
168
+
169
+ - Updated dependencies [[`23d561e`](https://github.com/atlassian-labs/atlaspack/commit/23d561e51e68b0c38fd1ff4e4fb173e5e7b01cf2)]:
170
+ - @atlaspack/utils@2.18.0
171
+ - @atlaspack/rust@3.5.0
172
+ - @atlaspack/plugin@2.14.23
173
+
174
+ ## 2.14.22
175
+
176
+ ### Patch Changes
177
+
178
+ - [#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
179
+
180
+ - Updated dependencies [[`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94)]:
181
+ - @atlaspack/diagnostic@2.14.2
182
+ - @atlaspack/plugin@2.14.22
183
+ - @atlaspack/utils@2.17.4
184
+ - @atlaspack/rust@3.4.2
185
+
186
+ ## 2.14.21
187
+
188
+ ### Patch Changes
189
+
190
+ - Updated dependencies []:
191
+ - @atlaspack/utils@2.17.3
192
+ - @atlaspack/plugin@2.14.21
193
+
194
+ ## 2.14.20
195
+
196
+ ### Patch Changes
197
+
198
+ - [#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
199
+
200
+ - Updated dependencies [[`daaa768`](https://github.com/atlassian-labs/atlaspack/commit/daaa7688786772d7e3713b71c5bba6b89ec704aa)]:
201
+ - @atlaspack/plugin@2.14.20
202
+ - @atlaspack/utils@2.17.2
203
+
204
+ ## 2.14.19
205
+
206
+ ### Patch Changes
207
+
208
+ - Updated dependencies []:
209
+ - @atlaspack/utils@2.17.1
210
+ - @atlaspack/plugin@2.14.19
211
+
212
+ ## 2.14.18
213
+
214
+ ### Patch Changes
215
+
216
+ - Updated dependencies [[`dbb4072`](https://github.com/atlassian-labs/atlaspack/commit/dbb40721ebeb45990a14ba04e6b44e7f836fb32d), [`becf977`](https://github.com/atlassian-labs/atlaspack/commit/becf977f625d5ee46dae3d4c679f173bf5f40cc0), [`f0f7c71`](https://github.com/atlassian-labs/atlaspack/commit/f0f7c7168a1d3d18c6f30d2daed611275692b7c5), [`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)]:
217
+ - @atlaspack/utils@2.17.0
218
+ - @atlaspack/rust@3.4.1
219
+ - @atlaspack/plugin@2.14.18
220
+
221
+ ## 2.14.17
222
+
223
+ ### Patch Changes
224
+
225
+ - Updated dependencies [[`c75bf55`](https://github.com/atlassian-labs/atlaspack/commit/c75bf553fff4decc285b5fd499a275853b18f8f2)]:
226
+ - @atlaspack/rust@3.4.0
227
+ - @atlaspack/utils@2.16.1
228
+ - @atlaspack/plugin@2.14.17
229
+
230
+ ## 2.14.16
231
+
232
+ ### Patch Changes
233
+
234
+ - Updated dependencies [[`30ee2cf`](https://github.com/atlassian-labs/atlaspack/commit/30ee2cfcd34cf2646ded0eda13fdb80a2a5de529)]:
235
+ - @atlaspack/utils@2.16.0
236
+ - @atlaspack/plugin@2.14.16
237
+
238
+ ## 2.14.15
239
+
240
+ ### Patch Changes
241
+
242
+ - Updated dependencies []:
243
+ - @atlaspack/utils@2.15.3
244
+ - @atlaspack/plugin@2.14.15
245
+
246
+ ## 2.14.14
247
+
248
+ ### Patch Changes
249
+
250
+ - Updated dependencies []:
251
+ - @atlaspack/utils@2.15.2
252
+ - @atlaspack/plugin@2.14.14
253
+
254
+ ## 2.14.13
255
+
256
+ ### Patch Changes
257
+
258
+ - Updated dependencies []:
259
+ - @atlaspack/utils@2.15.1
260
+ - @atlaspack/plugin@2.14.13
261
+
262
+ ## 2.14.12
263
+
264
+ ### Patch Changes
265
+
266
+ - Updated dependencies [[`e39c6cf`](https://github.com/atlassian-labs/atlaspack/commit/e39c6cf05f7e95ce5420dbcea66f401b1cbd397c)]:
267
+ - @atlaspack/utils@2.15.0
268
+ - @atlaspack/plugin@2.14.12
269
+
270
+ ## 2.14.11
271
+
272
+ ### Patch Changes
273
+
274
+ - Updated dependencies []:
275
+ - @atlaspack/utils@2.14.11
276
+ - @atlaspack/plugin@2.14.11
277
+
278
+ ## 2.14.10
279
+
280
+ ### Patch Changes
281
+
282
+ - Updated dependencies [[`35fdd4b`](https://github.com/atlassian-labs/atlaspack/commit/35fdd4b52da0af20f74667f7b8adfb2f90279b7c), [`6dd4ccb`](https://github.com/atlassian-labs/atlaspack/commit/6dd4ccb753541de32322d881f973d571dd57e4ca)]:
283
+ - @atlaspack/rust@3.3.5
284
+ - @atlaspack/plugin@2.14.10
285
+ - @atlaspack/utils@2.14.10
286
+
287
+ ## 2.14.9
288
+
289
+ ### Patch Changes
290
+
291
+ - Updated dependencies [[`124b7ff`](https://github.com/atlassian-labs/atlaspack/commit/124b7fff44f71aac9fbad289a9a9509b3dfc9aaa), [`e052521`](https://github.com/atlassian-labs/atlaspack/commit/e0525210850ed1606146eb86991049cf567c5dec), [`15c6d70`](https://github.com/atlassian-labs/atlaspack/commit/15c6d7000bd89da876bc590aa75b17a619a41896), [`e4d966c`](https://github.com/atlassian-labs/atlaspack/commit/e4d966c3c9c4292c5013372ae65b10d19d4bacc6), [`42a775d`](https://github.com/atlassian-labs/atlaspack/commit/42a775de8eec638ad188f3271964170d8c04d84b), [`29c2f10`](https://github.com/atlassian-labs/atlaspack/commit/29c2f106de9679adfb5afa04e1910471dc65a427), [`1ef91fc`](https://github.com/atlassian-labs/atlaspack/commit/1ef91fcc863fdd2831511937083dbbc1263b3d9d)]:
292
+ - @atlaspack/rust@3.3.4
293
+ - @atlaspack/utils@2.14.9
294
+ - @atlaspack/plugin@2.14.9
295
+
3
296
  ## 2.14.8
4
297
 
5
298
  ### Patch Changes
@@ -0,0 +1,281 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const rust_1 = require("@atlaspack/rust");
7
+ const utils_1 = require("@atlaspack/utils");
8
+ const plugin_1 = require("@atlaspack/plugin");
9
+ const nullthrows_1 = __importDefault(require("nullthrows"));
10
+ const path_1 = __importDefault(require("path"));
11
+ const semver_1 = __importDefault(require("semver"));
12
+ const postcss_value_parser_1 = __importDefault(require("postcss-value-parser"));
13
+ const loadConfig_1 = require("./loadConfig");
14
+ const constants_1 = require("./constants");
15
+ const diagnostic_1 = require("@atlaspack/diagnostic");
16
+ const COMPOSES_RE = /composes:.+from\s*("|').*("|')\s*;?/;
17
+ const FROM_IMPORT_RE = /.+from\s*(?:"|')(.*)(?:"|')\s*;?/;
18
+ const LEGACY_MODULE_RE = /@value|:export|(:global|:local|:import)(?!\s*\()/i;
19
+ const MODULE_BY_NAME_RE = /\.module\./;
20
+ exports.default = new plugin_1.Transformer({
21
+ loadConfig({ config, options, logger }) {
22
+ return (0, loadConfig_1.load)({ config, options, logger });
23
+ },
24
+ canReuseAST({ ast }) {
25
+ return (ast.type === 'postcss' && semver_1.default.satisfies(ast.version, constants_1.POSTCSS_RANGE));
26
+ },
27
+ async parse({ asset, config, options }) {
28
+ let isLegacy = await isLegacyCssModule(asset);
29
+ if (!config && !isLegacy) {
30
+ return;
31
+ }
32
+ const postcss = await loadPostcss(options, asset.filePath);
33
+ return {
34
+ type: 'postcss',
35
+ version: '8.2.1',
36
+ program: postcss
37
+ .parse(await asset.getCode(), {
38
+ from: asset.filePath,
39
+ })
40
+ .toJSON(),
41
+ };
42
+ },
43
+ async transform({ asset, config, options, resolve, logger }) {
44
+ asset.type = 'css';
45
+ let isLegacy = await isLegacyCssModule(asset);
46
+ if (isLegacy && !config) {
47
+ config = {
48
+ raw: {},
49
+ filePath: '',
50
+ hydrated: {
51
+ plugins: [],
52
+ from: asset.filePath,
53
+ to: asset.filePath,
54
+ modules: {},
55
+ },
56
+ };
57
+ // TODO: warning?
58
+ }
59
+ if (!config) {
60
+ return [asset];
61
+ }
62
+ // @ts-expect-error TS2709
63
+ const postcss = await loadPostcss(options, asset.filePath);
64
+ let ast = (0, nullthrows_1.default)(await asset.getAST());
65
+ let program = postcss.fromJSON(ast.program);
66
+ let plugins = [...config.hydrated.plugins];
67
+ let cssModules = null;
68
+ if (config.hydrated.modules) {
69
+ asset.meta.cssModulesCompiled = 'postcss';
70
+ let code = asset.isASTDirty() ? null : await asset.getCode();
71
+ if (Object.keys(config.hydrated.modules).length === 0 &&
72
+ code &&
73
+ !isLegacy &&
74
+ !LEGACY_MODULE_RE.test(code)) {
75
+ let filename = path_1.default.basename(config.filePath);
76
+ let message;
77
+ let configKey;
78
+ let hint;
79
+ if (config.raw.modules) {
80
+ message = (0, diagnostic_1.md) `The "modules" option in __${filename}__ can be replaced with configuration for @atlaspack/transformer-css to improve build performance.`;
81
+ configKey = '/modules';
82
+ hint = (0, diagnostic_1.md) `Remove the "modules" option from __${filename}__`;
83
+ }
84
+ else {
85
+ message = (0, diagnostic_1.md) `The "postcss-modules" plugin in __${filename}__ can be replaced with configuration for @atlaspack/transformer-css to improve build performance.`;
86
+ configKey = '/plugins/postcss-modules';
87
+ hint = (0, diagnostic_1.md) `Remove the "postcss-modules" plugin from __${filename}__`;
88
+ }
89
+ if (filename === 'package.json') {
90
+ configKey = `/postcss${configKey}`;
91
+ }
92
+ let hints = [
93
+ 'Enable the "cssModules" option for "@atlaspack/transformer-css" in your package.json',
94
+ ];
95
+ if (plugins.length === 0) {
96
+ message += (0, diagnostic_1.md) ` Since there are no other plugins, __${filename}__ can be deleted safely.`;
97
+ hints.push((0, diagnostic_1.md) `Delete __${filename}__`);
98
+ }
99
+ else {
100
+ hints.push(hint);
101
+ }
102
+ let codeFrames;
103
+ if (path_1.default.extname(filename) !== '.js') {
104
+ let contents = await asset.fs.readFile(config.filePath, 'utf8');
105
+ codeFrames = [
106
+ {
107
+ language: 'json',
108
+ filePath: config.filePath,
109
+ code: contents,
110
+ codeHighlights: (0, diagnostic_1.generateJSONCodeHighlights)(contents, [
111
+ {
112
+ key: configKey,
113
+ type: 'key',
114
+ },
115
+ ]),
116
+ },
117
+ ];
118
+ }
119
+ else {
120
+ codeFrames = [
121
+ {
122
+ filePath: config.filePath,
123
+ codeHighlights: [
124
+ {
125
+ start: { line: 1, column: 1 },
126
+ end: { line: 1, column: 1 },
127
+ },
128
+ ],
129
+ },
130
+ ];
131
+ }
132
+ logger.warn({
133
+ message,
134
+ hints,
135
+ documentationURL: 'https://parceljs.org/languages/css/#enabling-css-modules-globally',
136
+ codeFrames,
137
+ });
138
+ }
139
+ // TODO: should this be resolved from the project root?
140
+ let postcssModules = await options.packageManager.require('postcss-modules', asset.filePath, {
141
+ range: '^4.3.0',
142
+ saveDev: true,
143
+ shouldAutoInstall: options.shouldAutoInstall,
144
+ });
145
+ plugins.push(postcssModules({
146
+ // @ts-expect-error TS7006
147
+ getJSON: (filename, json) => (cssModules = json),
148
+ Loader: await createLoader(asset, resolve, options),
149
+ // @ts-expect-error TS7006
150
+ generateScopedName: (name, filename) => `${name}_${(0, rust_1.hashString)(path_1.default.relative(options.projectRoot, filename)).substr(0, 6)}`,
151
+ ...config.hydrated.modules,
152
+ }));
153
+ if (code == null || COMPOSES_RE.test(code)) {
154
+ // @ts-expect-error TS7006
155
+ program.walkDecls((decl) => {
156
+ let [, importPath] = FROM_IMPORT_RE.exec(decl.value) || [];
157
+ if (decl.prop === 'composes' && importPath != null) {
158
+ let parsed = (0, postcss_value_parser_1.default)(decl.value);
159
+ parsed.walk((node) => {
160
+ if (node.type === 'string') {
161
+ asset.addDependency({
162
+ specifier: importPath,
163
+ specifierType: 'url',
164
+ loc: {
165
+ filePath: asset.filePath,
166
+ start: decl.source.start,
167
+ end: {
168
+ line: decl.source.start.line,
169
+ column: decl.source.start.column + importPath.length,
170
+ },
171
+ },
172
+ });
173
+ }
174
+ });
175
+ }
176
+ });
177
+ }
178
+ }
179
+ let { messages, root } = await postcss(plugins).process(program, config.hydrated);
180
+ asset.setAST({
181
+ type: 'postcss',
182
+ version: '8.2.1',
183
+ program: root.toJSON(),
184
+ });
185
+ for (let msg of messages) {
186
+ if (msg.type === 'dependency') {
187
+ asset.invalidateOnFileChange(msg.file);
188
+ }
189
+ else if (msg.type === 'dir-dependency') {
190
+ let pattern = `${msg.dir}/${msg.glob ?? '**/*'}`;
191
+ let files = await (0, utils_1.glob)(pattern, asset.fs, { onlyFiles: true });
192
+ for (let file of files) {
193
+ asset.invalidateOnFileChange(path_1.default.normalize(file));
194
+ }
195
+ asset.invalidateOnFileCreate({ glob: pattern });
196
+ }
197
+ }
198
+ let assets = [asset];
199
+ if (cssModules) {
200
+ let cssModulesList = Object.entries(cssModules);
201
+ let deps = asset
202
+ .getDependencies()
203
+ .filter((dep) => dep.priority === 'sync');
204
+ let code;
205
+ if (deps.length > 0) {
206
+ code = `
207
+ module.exports = Object.assign({}, ${deps
208
+ .map((dep) => `require(${JSON.stringify(dep.specifier)})`)
209
+ .join(', ')}, ${JSON.stringify(cssModules, null, 2)});
210
+ `;
211
+ }
212
+ else {
213
+ code = cssModulesList
214
+ .map(
215
+ // This syntax enables shaking the invidual statements, so that unused classes don't even exist in JS.
216
+ ([className, classNameHashed]) => `module.exports[${JSON.stringify(className)}] = ${JSON.stringify(classNameHashed)};`)
217
+ .join('\n');
218
+ }
219
+ asset.symbols.ensure();
220
+ for (let [k, v] of cssModulesList) {
221
+ asset.symbols.set(k, v);
222
+ }
223
+ asset.symbols.set('default', 'default');
224
+ assets.push({
225
+ type: 'js',
226
+ // @ts-expect-error TS2353
227
+ content: code,
228
+ });
229
+ }
230
+ return assets;
231
+ },
232
+ async generate({ asset, ast, options }) {
233
+ // @ts-expect-error TS2709
234
+ const postcss = await loadPostcss(options, asset.filePath);
235
+ let code = '';
236
+ // @ts-expect-error TS7006
237
+ postcss.stringify(postcss.fromJSON(ast.program), (c) => {
238
+ code += c;
239
+ });
240
+ return {
241
+ content: code,
242
+ };
243
+ },
244
+ });
245
+ async function createLoader(asset, resolve, options) {
246
+ let { default: FileSystemLoader } = await options.packageManager.require('postcss-modules/build/css-loader-core/loader', asset.filePath);
247
+ return class AtlaspackFileSystemLoader extends FileSystemLoader {
248
+ async fetch(composesPath, relativeTo) {
249
+ let importPath = composesPath.replace(/^["']|["']$/g, '');
250
+ let resolved = await resolve(relativeTo, importPath);
251
+ let rootRelativePath = path_1.default.resolve(path_1.default.dirname(relativeTo), resolved);
252
+ let root = path_1.default.resolve('/');
253
+ // fixes an issue on windows which is part of the css-modules-loader-core
254
+ // see https://github.com/css-modules/css-modules-loader-core/issues/230
255
+ if (rootRelativePath.startsWith(root)) {
256
+ rootRelativePath = rootRelativePath.substr(root.length);
257
+ }
258
+ let source = await asset.fs.readFile(resolved, 'utf-8');
259
+ let { exportTokens } = await this.core.load(source, rootRelativePath, undefined, this.fetch.bind(this));
260
+ return exportTokens;
261
+ }
262
+ get finalSource() {
263
+ return '';
264
+ }
265
+ };
266
+ }
267
+ // @ts-expect-error TS2709
268
+ function loadPostcss(options, from) {
269
+ return options.packageManager.require('postcss', from, {
270
+ range: constants_1.POSTCSS_RANGE,
271
+ saveDev: true,
272
+ shouldAutoInstall: options.shouldAutoInstall,
273
+ });
274
+ }
275
+ async function isLegacyCssModule(asset) {
276
+ if (!MODULE_BY_NAME_RE.test(asset.filePath)) {
277
+ return false;
278
+ }
279
+ let code = await asset.getCode();
280
+ return LEGACY_MODULE_RE.test(code);
281
+ }
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.POSTCSS_RANGE = void 0;
4
+ exports.POSTCSS_RANGE = '^8.2.1';