@atlaspack/transformer-postcss 2.14.5-canary.16 → 2.14.5-canary.161
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 +168 -0
- package/lib/PostCSSTransformer.js +14 -7
- package/lib/loadConfig.js +2 -0
- package/lib/loadPlugins.js +5 -2
- package/lib/types/PostCSSTransformer.d.ts +3 -0
- package/lib/types/constants.d.ts +1 -0
- package/lib/types/loadConfig.d.ts +17 -0
- package/lib/types/loadPlugins.d.ts +4 -0
- package/package.json +14 -8
- package/src/{PostCSSTransformer.js → PostCSSTransformer.ts} +25 -15
- package/src/{constants.js → constants.ts} +0 -2
- package/src/{loadConfig.js → loadConfig.ts} +19 -19
- package/src/{loadPlugins.js → loadPlugins.ts} +15 -9
- package/tsconfig.json +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,173 @@
|
|
|
1
1
|
# @atlaspack/transformer-postcss
|
|
2
2
|
|
|
3
|
+
## 2.14.25
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies []:
|
|
8
|
+
- @atlaspack/types-internal@2.19.1
|
|
9
|
+
- @atlaspack/utils@2.18.2
|
|
10
|
+
- @atlaspack/plugin@2.14.25
|
|
11
|
+
|
|
12
|
+
## 2.14.24
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- 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)]:
|
|
17
|
+
- @atlaspack/rust@3.6.0
|
|
18
|
+
- @atlaspack/types-internal@2.19.0
|
|
19
|
+
- @atlaspack/utils@2.18.1
|
|
20
|
+
- @atlaspack/plugin@2.14.24
|
|
21
|
+
|
|
22
|
+
## 2.14.23
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- Updated dependencies [[`23d561e`](https://github.com/atlassian-labs/atlaspack/commit/23d561e51e68b0c38fd1ff4e4fb173e5e7b01cf2)]:
|
|
27
|
+
- @atlaspack/utils@2.18.0
|
|
28
|
+
- @atlaspack/rust@3.5.0
|
|
29
|
+
- @atlaspack/plugin@2.14.23
|
|
30
|
+
|
|
31
|
+
## 2.14.22
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- [#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
|
|
36
|
+
|
|
37
|
+
- Updated dependencies [[`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94)]:
|
|
38
|
+
- @atlaspack/diagnostic@2.14.2
|
|
39
|
+
- @atlaspack/plugin@2.14.22
|
|
40
|
+
- @atlaspack/utils@2.17.4
|
|
41
|
+
- @atlaspack/rust@3.4.2
|
|
42
|
+
|
|
43
|
+
## 2.14.21
|
|
44
|
+
|
|
45
|
+
### Patch Changes
|
|
46
|
+
|
|
47
|
+
- Updated dependencies []:
|
|
48
|
+
- @atlaspack/utils@2.17.3
|
|
49
|
+
- @atlaspack/plugin@2.14.21
|
|
50
|
+
|
|
51
|
+
## 2.14.20
|
|
52
|
+
|
|
53
|
+
### Patch Changes
|
|
54
|
+
|
|
55
|
+
- [#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
|
|
56
|
+
|
|
57
|
+
- Updated dependencies [[`daaa768`](https://github.com/atlassian-labs/atlaspack/commit/daaa7688786772d7e3713b71c5bba6b89ec704aa)]:
|
|
58
|
+
- @atlaspack/plugin@2.14.20
|
|
59
|
+
- @atlaspack/utils@2.17.2
|
|
60
|
+
|
|
61
|
+
## 2.14.19
|
|
62
|
+
|
|
63
|
+
### Patch Changes
|
|
64
|
+
|
|
65
|
+
- Updated dependencies []:
|
|
66
|
+
- @atlaspack/utils@2.17.1
|
|
67
|
+
- @atlaspack/plugin@2.14.19
|
|
68
|
+
|
|
69
|
+
## 2.14.18
|
|
70
|
+
|
|
71
|
+
### Patch Changes
|
|
72
|
+
|
|
73
|
+
- 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)]:
|
|
74
|
+
- @atlaspack/utils@2.17.0
|
|
75
|
+
- @atlaspack/rust@3.4.1
|
|
76
|
+
- @atlaspack/plugin@2.14.18
|
|
77
|
+
|
|
78
|
+
## 2.14.17
|
|
79
|
+
|
|
80
|
+
### Patch Changes
|
|
81
|
+
|
|
82
|
+
- Updated dependencies [[`c75bf55`](https://github.com/atlassian-labs/atlaspack/commit/c75bf553fff4decc285b5fd499a275853b18f8f2)]:
|
|
83
|
+
- @atlaspack/rust@3.4.0
|
|
84
|
+
- @atlaspack/utils@2.16.1
|
|
85
|
+
- @atlaspack/plugin@2.14.17
|
|
86
|
+
|
|
87
|
+
## 2.14.16
|
|
88
|
+
|
|
89
|
+
### Patch Changes
|
|
90
|
+
|
|
91
|
+
- Updated dependencies [[`30ee2cf`](https://github.com/atlassian-labs/atlaspack/commit/30ee2cfcd34cf2646ded0eda13fdb80a2a5de529)]:
|
|
92
|
+
- @atlaspack/utils@2.16.0
|
|
93
|
+
- @atlaspack/plugin@2.14.16
|
|
94
|
+
|
|
95
|
+
## 2.14.15
|
|
96
|
+
|
|
97
|
+
### Patch Changes
|
|
98
|
+
|
|
99
|
+
- Updated dependencies []:
|
|
100
|
+
- @atlaspack/utils@2.15.3
|
|
101
|
+
- @atlaspack/plugin@2.14.15
|
|
102
|
+
|
|
103
|
+
## 2.14.14
|
|
104
|
+
|
|
105
|
+
### Patch Changes
|
|
106
|
+
|
|
107
|
+
- Updated dependencies []:
|
|
108
|
+
- @atlaspack/utils@2.15.2
|
|
109
|
+
- @atlaspack/plugin@2.14.14
|
|
110
|
+
|
|
111
|
+
## 2.14.13
|
|
112
|
+
|
|
113
|
+
### Patch Changes
|
|
114
|
+
|
|
115
|
+
- Updated dependencies []:
|
|
116
|
+
- @atlaspack/utils@2.15.1
|
|
117
|
+
- @atlaspack/plugin@2.14.13
|
|
118
|
+
|
|
119
|
+
## 2.14.12
|
|
120
|
+
|
|
121
|
+
### Patch Changes
|
|
122
|
+
|
|
123
|
+
- Updated dependencies [[`e39c6cf`](https://github.com/atlassian-labs/atlaspack/commit/e39c6cf05f7e95ce5420dbcea66f401b1cbd397c)]:
|
|
124
|
+
- @atlaspack/utils@2.15.0
|
|
125
|
+
- @atlaspack/plugin@2.14.12
|
|
126
|
+
|
|
127
|
+
## 2.14.11
|
|
128
|
+
|
|
129
|
+
### Patch Changes
|
|
130
|
+
|
|
131
|
+
- Updated dependencies []:
|
|
132
|
+
- @atlaspack/utils@2.14.11
|
|
133
|
+
- @atlaspack/plugin@2.14.11
|
|
134
|
+
|
|
135
|
+
## 2.14.10
|
|
136
|
+
|
|
137
|
+
### Patch Changes
|
|
138
|
+
|
|
139
|
+
- Updated dependencies [[`35fdd4b`](https://github.com/atlassian-labs/atlaspack/commit/35fdd4b52da0af20f74667f7b8adfb2f90279b7c), [`6dd4ccb`](https://github.com/atlassian-labs/atlaspack/commit/6dd4ccb753541de32322d881f973d571dd57e4ca)]:
|
|
140
|
+
- @atlaspack/rust@3.3.5
|
|
141
|
+
- @atlaspack/plugin@2.14.10
|
|
142
|
+
- @atlaspack/utils@2.14.10
|
|
143
|
+
|
|
144
|
+
## 2.14.9
|
|
145
|
+
|
|
146
|
+
### Patch Changes
|
|
147
|
+
|
|
148
|
+
- 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)]:
|
|
149
|
+
- @atlaspack/rust@3.3.4
|
|
150
|
+
- @atlaspack/utils@2.14.9
|
|
151
|
+
- @atlaspack/plugin@2.14.9
|
|
152
|
+
|
|
153
|
+
## 2.14.8
|
|
154
|
+
|
|
155
|
+
### Patch Changes
|
|
156
|
+
|
|
157
|
+
- Updated dependencies [[`1ab0a27`](https://github.com/atlassian-labs/atlaspack/commit/1ab0a275aeca40350415e2b03e7440d1dddc6228), [`b8a4ae8`](https://github.com/atlassian-labs/atlaspack/commit/b8a4ae8f83dc0a83d8b145c5f729936ce52080a3)]:
|
|
158
|
+
- @atlaspack/rust@3.3.3
|
|
159
|
+
- @atlaspack/utils@2.14.8
|
|
160
|
+
- @atlaspack/plugin@2.14.8
|
|
161
|
+
|
|
162
|
+
## 2.14.7
|
|
163
|
+
|
|
164
|
+
### Patch Changes
|
|
165
|
+
|
|
166
|
+
- Updated dependencies [[`556d6ab`](https://github.com/atlassian-labs/atlaspack/commit/556d6ab8ede759fa7f37fcd3f4da336ef1c55e8f)]:
|
|
167
|
+
- @atlaspack/rust@3.3.2
|
|
168
|
+
- @atlaspack/utils@2.14.7
|
|
169
|
+
- @atlaspack/plugin@2.14.7
|
|
170
|
+
|
|
3
171
|
## 2.14.6
|
|
4
172
|
|
|
5
173
|
### Patch Changes
|
|
@@ -129,6 +129,8 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
129
129
|
if (!config) {
|
|
130
130
|
return [asset];
|
|
131
131
|
}
|
|
132
|
+
|
|
133
|
+
// @ts-expect-error TS2709
|
|
132
134
|
const postcss = await loadPostcss(options, asset.filePath);
|
|
133
135
|
let ast = (0, _nullthrows().default)(await asset.getAST());
|
|
134
136
|
let program = postcss.fromJSON(ast.program);
|
|
@@ -203,12 +205,15 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
203
205
|
shouldAutoInstall: options.shouldAutoInstall
|
|
204
206
|
});
|
|
205
207
|
plugins.push(postcssModules({
|
|
208
|
+
// @ts-expect-error TS7006
|
|
206
209
|
getJSON: (filename, json) => cssModules = json,
|
|
207
210
|
Loader: await createLoader(asset, resolve, options),
|
|
211
|
+
// @ts-expect-error TS7006
|
|
208
212
|
generateScopedName: (name, filename) => `${name}_${(0, _rust().hashString)(_path().default.relative(options.projectRoot, filename)).substr(0, 6)}`,
|
|
209
213
|
...config.hydrated.modules
|
|
210
214
|
}));
|
|
211
215
|
if (code == null || COMPOSES_RE.test(code)) {
|
|
216
|
+
// @ts-expect-error TS7006
|
|
212
217
|
program.walkDecls(decl => {
|
|
213
218
|
let [, importPath] = FROM_IMPORT_RE.exec(decl.value) || [];
|
|
214
219
|
if (decl.prop === 'composes' && importPath != null) {
|
|
@@ -233,8 +238,6 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
233
238
|
});
|
|
234
239
|
}
|
|
235
240
|
}
|
|
236
|
-
|
|
237
|
-
// $FlowFixMe Added in Flow 0.121.0 upgrade in #4381
|
|
238
241
|
let {
|
|
239
242
|
messages,
|
|
240
243
|
root
|
|
@@ -262,7 +265,6 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
262
265
|
}
|
|
263
266
|
let assets = [asset];
|
|
264
267
|
if (cssModules) {
|
|
265
|
-
// $FlowFixMe
|
|
266
268
|
let cssModulesList = Object.entries(cssModules);
|
|
267
269
|
let deps = asset.getDependencies().filter(dep => dep.priority === 'sync');
|
|
268
270
|
let code;
|
|
@@ -277,11 +279,14 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
277
279
|
}
|
|
278
280
|
asset.symbols.ensure();
|
|
279
281
|
for (let [k, v] of cssModulesList) {
|
|
282
|
+
// @ts-expect-error TS2345
|
|
280
283
|
asset.symbols.set(k, v);
|
|
281
284
|
}
|
|
285
|
+
// @ts-expect-error TS2345
|
|
282
286
|
asset.symbols.set('default', 'default');
|
|
283
287
|
assets.push({
|
|
284
288
|
type: 'js',
|
|
289
|
+
// @ts-expect-error TS2353
|
|
285
290
|
content: code
|
|
286
291
|
});
|
|
287
292
|
}
|
|
@@ -292,8 +297,10 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
292
297
|
ast,
|
|
293
298
|
options
|
|
294
299
|
}) {
|
|
300
|
+
// @ts-expect-error TS2709
|
|
295
301
|
const postcss = await loadPostcss(options, asset.filePath);
|
|
296
302
|
let code = '';
|
|
303
|
+
// @ts-expect-error TS7006
|
|
297
304
|
postcss.stringify(postcss.fromJSON(ast.program), c => {
|
|
298
305
|
code += c;
|
|
299
306
|
});
|
|
@@ -306,7 +313,7 @@ async function createLoader(asset, resolve, options) {
|
|
|
306
313
|
let {
|
|
307
314
|
default: FileSystemLoader
|
|
308
315
|
} = await options.packageManager.require('postcss-modules/build/css-loader-core/loader', asset.filePath);
|
|
309
|
-
return class extends FileSystemLoader {
|
|
316
|
+
return class AtlaspackFileSystemLoader extends FileSystemLoader {
|
|
310
317
|
async fetch(composesPath, relativeTo) {
|
|
311
318
|
let importPath = composesPath.replace(/^["']|["']$/g, '');
|
|
312
319
|
let resolved = await resolve(relativeTo, importPath);
|
|
@@ -320,9 +327,7 @@ async function createLoader(asset, resolve, options) {
|
|
|
320
327
|
let source = await asset.fs.readFile(resolved, 'utf-8');
|
|
321
328
|
let {
|
|
322
329
|
exportTokens
|
|
323
|
-
} = await this.core.load(source, rootRelativePath, undefined,
|
|
324
|
-
// $FlowFixMe[method-unbinding]
|
|
325
|
-
this.fetch.bind(this));
|
|
330
|
+
} = await this.core.load(source, rootRelativePath, undefined, this.fetch.bind(this));
|
|
326
331
|
return exportTokens;
|
|
327
332
|
}
|
|
328
333
|
get finalSource() {
|
|
@@ -330,6 +335,8 @@ async function createLoader(asset, resolve, options) {
|
|
|
330
335
|
}
|
|
331
336
|
};
|
|
332
337
|
}
|
|
338
|
+
|
|
339
|
+
// @ts-expect-error TS2709
|
|
333
340
|
function loadPostcss(options, from) {
|
|
334
341
|
return options.packageManager.require('postcss', from, {
|
|
335
342
|
range: _constants.POSTCSS_RANGE,
|
package/lib/loadConfig.js
CHANGED
|
@@ -35,6 +35,8 @@ function _clone() {
|
|
|
35
35
|
var _constants = require("./constants");
|
|
36
36
|
var _loadPlugins = _interopRequireDefault(require("./loadPlugins"));
|
|
37
37
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
38
|
+
// @ts-expect-error TS7016
|
|
39
|
+
|
|
38
40
|
async function configHydrator(configFile, config, resolveFrom, options, logger) {
|
|
39
41
|
if (configFile == null) {
|
|
40
42
|
return;
|
package/lib/loadPlugins.js
CHANGED
|
@@ -8,13 +8,16 @@ async function loadExternalPlugins(plugins, relative, options) {
|
|
|
8
8
|
if (Array.isArray(plugins)) {
|
|
9
9
|
return Promise.all(plugins.map(p => loadPlugin(p, relative, null, options.packageManager, options.shouldAutoInstall)).filter(Boolean));
|
|
10
10
|
} else if (typeof plugins === 'object') {
|
|
11
|
-
let
|
|
11
|
+
let _plugins = plugins;
|
|
12
|
+
let mapPlugins = await Promise.all(Object.keys(plugins).map(p => loadPlugin(p, relative, _plugins[p], options.packageManager, options.shouldAutoInstall)));
|
|
12
13
|
return mapPlugins.filter(Boolean);
|
|
13
14
|
} else {
|
|
14
15
|
return [];
|
|
15
16
|
}
|
|
16
17
|
}
|
|
17
|
-
async function loadPlugin(pluginArg, relative, options = {}, packageManager, shouldAutoInstall
|
|
18
|
+
async function loadPlugin(pluginArg, relative, options = {}, packageManager, shouldAutoInstall
|
|
19
|
+
// @ts-expect-error TS1064
|
|
20
|
+
) {
|
|
18
21
|
if (typeof pluginArg !== 'string') {
|
|
19
22
|
return pluginArg;
|
|
20
23
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const POSTCSS_RANGE = "^8.2.1";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Config, FilePath, PluginOptions, PluginLogger } from '@atlaspack/types-internal';
|
|
2
|
+
type ConfigResult = {
|
|
3
|
+
raw: any;
|
|
4
|
+
filePath: string;
|
|
5
|
+
hydrated: {
|
|
6
|
+
plugins: Array<any>;
|
|
7
|
+
from: FilePath;
|
|
8
|
+
to: FilePath;
|
|
9
|
+
modules: any;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export declare function load({ config, options, logger, }: {
|
|
13
|
+
config: Config;
|
|
14
|
+
options: PluginOptions;
|
|
15
|
+
logger: PluginLogger;
|
|
16
|
+
}): Promise<ConfigResult | null | undefined>;
|
|
17
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/transformer-postcss",
|
|
3
|
-
"version": "2.14.5-canary.
|
|
3
|
+
"version": "2.14.5-canary.161+ee040bb64",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -9,16 +9,18 @@
|
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "https://github.com/atlassian-labs/atlaspack.git"
|
|
11
11
|
},
|
|
12
|
-
"main": "lib/PostCSSTransformer.js",
|
|
13
|
-
"source": "src/PostCSSTransformer.
|
|
12
|
+
"main": "./lib/PostCSSTransformer.js",
|
|
13
|
+
"source": "./src/PostCSSTransformer.ts",
|
|
14
|
+
"types": "./lib/types/PostCSSTransformer.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/rust": "3.2.1-canary.
|
|
21
|
-
"@atlaspack/
|
|
19
|
+
"@atlaspack/diagnostic": "2.14.1-canary.229+ee040bb64",
|
|
20
|
+
"@atlaspack/plugin": "2.14.5-canary.161+ee040bb64",
|
|
21
|
+
"@atlaspack/rust": "3.2.1-canary.161+ee040bb64",
|
|
22
|
+
"@atlaspack/types-internal": "2.14.1-canary.229+ee040bb64",
|
|
23
|
+
"@atlaspack/utils": "2.14.5-canary.161+ee040bb64",
|
|
22
24
|
"clone": "^2.1.1",
|
|
23
25
|
"nullthrows": "^1.1.1",
|
|
24
26
|
"postcss-value-parser": "^4.2.0",
|
|
@@ -29,5 +31,9 @@
|
|
|
29
31
|
"postcss-modules": "^4.3.1"
|
|
30
32
|
},
|
|
31
33
|
"type": "commonjs",
|
|
32
|
-
"
|
|
34
|
+
"scripts": {
|
|
35
|
+
"check-ts": "tsc --emitDeclarationOnly --rootDir src",
|
|
36
|
+
"build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
|
|
37
|
+
},
|
|
38
|
+
"gitHead": "ee040bb6428f29b57d892ddd8107e29077d08ffd"
|
|
33
39
|
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
1
|
import type {
|
|
4
2
|
FilePath,
|
|
5
3
|
Asset,
|
|
6
4
|
MutableAsset,
|
|
7
5
|
PluginOptions,
|
|
8
|
-
} from '@atlaspack/types';
|
|
6
|
+
} from '@atlaspack/types-internal';
|
|
9
7
|
|
|
10
8
|
import {hashString} from '@atlaspack/rust';
|
|
11
9
|
import {glob} from '@atlaspack/utils';
|
|
@@ -14,7 +12,7 @@ import nullthrows from 'nullthrows';
|
|
|
14
12
|
import path from 'path';
|
|
15
13
|
import semver from 'semver';
|
|
16
14
|
import valueParser from 'postcss-value-parser';
|
|
17
|
-
import
|
|
15
|
+
import * as Postcss from 'postcss';
|
|
18
16
|
|
|
19
17
|
import {load} from './loadConfig';
|
|
20
18
|
import {POSTCSS_RANGE} from './constants';
|
|
@@ -25,7 +23,7 @@ const FROM_IMPORT_RE = /.+from\s*(?:"|')(.*)(?:"|')\s*;?/;
|
|
|
25
23
|
const LEGACY_MODULE_RE = /@value|:export|(:global|:local|:import)(?!\s*\()/i;
|
|
26
24
|
const MODULE_BY_NAME_RE = /\.module\./;
|
|
27
25
|
|
|
28
|
-
export default
|
|
26
|
+
export default new Transformer({
|
|
29
27
|
loadConfig({config, options, logger}) {
|
|
30
28
|
return load({config, options, logger});
|
|
31
29
|
},
|
|
@@ -77,12 +75,18 @@ export default (new Transformer({
|
|
|
77
75
|
return [asset];
|
|
78
76
|
}
|
|
79
77
|
|
|
78
|
+
// @ts-expect-error TS2709
|
|
80
79
|
const postcss: Postcss = await loadPostcss(options, asset.filePath);
|
|
81
80
|
let ast = nullthrows(await asset.getAST());
|
|
82
81
|
let program = postcss.fromJSON(ast.program);
|
|
83
82
|
|
|
84
83
|
let plugins = [...config.hydrated.plugins];
|
|
85
|
-
let cssModules:
|
|
84
|
+
let cssModules:
|
|
85
|
+
| {
|
|
86
|
+
[key: string]: string;
|
|
87
|
+
}
|
|
88
|
+
| null
|
|
89
|
+
| undefined = null;
|
|
86
90
|
if (config.hydrated.modules) {
|
|
87
91
|
asset.meta.cssModulesCompiled = 'postcss';
|
|
88
92
|
|
|
@@ -172,8 +176,10 @@ export default (new Transformer({
|
|
|
172
176
|
|
|
173
177
|
plugins.push(
|
|
174
178
|
postcssModules({
|
|
179
|
+
// @ts-expect-error TS7006
|
|
175
180
|
getJSON: (filename, json) => (cssModules = json),
|
|
176
181
|
Loader: await createLoader(asset, resolve, options),
|
|
182
|
+
// @ts-expect-error TS7006
|
|
177
183
|
generateScopedName: (name, filename) =>
|
|
178
184
|
`${name}_${hashString(
|
|
179
185
|
path.relative(options.projectRoot, filename),
|
|
@@ -183,6 +189,7 @@ export default (new Transformer({
|
|
|
183
189
|
);
|
|
184
190
|
|
|
185
191
|
if (code == null || COMPOSES_RE.test(code)) {
|
|
192
|
+
// @ts-expect-error TS7006
|
|
186
193
|
program.walkDecls((decl) => {
|
|
187
194
|
let [, importPath] = FROM_IMPORT_RE.exec(decl.value) || [];
|
|
188
195
|
if (decl.prop === 'composes' && importPath != null) {
|
|
@@ -209,7 +216,6 @@ export default (new Transformer({
|
|
|
209
216
|
}
|
|
210
217
|
}
|
|
211
218
|
|
|
212
|
-
// $FlowFixMe Added in Flow 0.121.0 upgrade in #4381
|
|
213
219
|
let {messages, root} = await postcss(plugins).process(
|
|
214
220
|
program,
|
|
215
221
|
config.hydrated,
|
|
@@ -234,10 +240,9 @@ export default (new Transformer({
|
|
|
234
240
|
|
|
235
241
|
let assets = [asset];
|
|
236
242
|
if (cssModules) {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
>);
|
|
243
|
+
let cssModulesList = Object.entries(cssModules) as Array<
|
|
244
|
+
[string, string]
|
|
245
|
+
>;
|
|
241
246
|
let deps = asset
|
|
242
247
|
.getDependencies()
|
|
243
248
|
.filter((dep) => dep.priority === 'sync');
|
|
@@ -252,7 +257,7 @@ export default (new Transformer({
|
|
|
252
257
|
code = cssModulesList
|
|
253
258
|
.map(
|
|
254
259
|
// This syntax enables shaking the invidual statements, so that unused classes don't even exist in JS.
|
|
255
|
-
([className, classNameHashed]) =>
|
|
260
|
+
([className, classNameHashed]: [any, any]) =>
|
|
256
261
|
`module.exports[${JSON.stringify(className)}] = ${JSON.stringify(
|
|
257
262
|
classNameHashed,
|
|
258
263
|
)};`,
|
|
@@ -262,12 +267,15 @@ export default (new Transformer({
|
|
|
262
267
|
|
|
263
268
|
asset.symbols.ensure();
|
|
264
269
|
for (let [k, v] of cssModulesList) {
|
|
270
|
+
// @ts-expect-error TS2345
|
|
265
271
|
asset.symbols.set(k, v);
|
|
266
272
|
}
|
|
273
|
+
// @ts-expect-error TS2345
|
|
267
274
|
asset.symbols.set('default', 'default');
|
|
268
275
|
|
|
269
276
|
assets.push({
|
|
270
277
|
type: 'js',
|
|
278
|
+
// @ts-expect-error TS2353
|
|
271
279
|
content: code,
|
|
272
280
|
});
|
|
273
281
|
}
|
|
@@ -275,9 +283,11 @@ export default (new Transformer({
|
|
|
275
283
|
},
|
|
276
284
|
|
|
277
285
|
async generate({asset, ast, options}) {
|
|
286
|
+
// @ts-expect-error TS2709
|
|
278
287
|
const postcss: Postcss = await loadPostcss(options, asset.filePath);
|
|
279
288
|
|
|
280
289
|
let code = '';
|
|
290
|
+
// @ts-expect-error TS7006
|
|
281
291
|
postcss.stringify(postcss.fromJSON(ast.program), (c) => {
|
|
282
292
|
code += c;
|
|
283
293
|
});
|
|
@@ -286,7 +296,7 @@ export default (new Transformer({
|
|
|
286
296
|
content: code,
|
|
287
297
|
};
|
|
288
298
|
},
|
|
289
|
-
})
|
|
299
|
+
}) as Transformer<unknown>;
|
|
290
300
|
|
|
291
301
|
async function createLoader(
|
|
292
302
|
asset: MutableAsset,
|
|
@@ -298,7 +308,7 @@ async function createLoader(
|
|
|
298
308
|
asset.filePath,
|
|
299
309
|
);
|
|
300
310
|
return class AtlaspackFileSystemLoader extends FileSystemLoader {
|
|
301
|
-
async fetch(composesPath, relativeTo) {
|
|
311
|
+
async fetch(composesPath: any, relativeTo: any) {
|
|
302
312
|
let importPath = composesPath.replace(/^["']|["']$/g, '');
|
|
303
313
|
let resolved = await resolve(relativeTo, importPath);
|
|
304
314
|
let rootRelativePath = path.resolve(path.dirname(relativeTo), resolved);
|
|
@@ -314,7 +324,6 @@ async function createLoader(
|
|
|
314
324
|
source,
|
|
315
325
|
rootRelativePath,
|
|
316
326
|
undefined,
|
|
317
|
-
// $FlowFixMe[method-unbinding]
|
|
318
327
|
this.fetch.bind(this),
|
|
319
328
|
);
|
|
320
329
|
return exportTokens;
|
|
@@ -326,6 +335,7 @@ async function createLoader(
|
|
|
326
335
|
};
|
|
327
336
|
}
|
|
328
337
|
|
|
338
|
+
// @ts-expect-error TS2709
|
|
329
339
|
function loadPostcss(options: PluginOptions, from: FilePath): Promise<Postcss> {
|
|
330
340
|
return options.packageManager.require('postcss', from, {
|
|
331
341
|
range: POSTCSS_RANGE,
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
import type {
|
|
3
2
|
Config,
|
|
4
3
|
FilePath,
|
|
5
4
|
PluginOptions,
|
|
6
5
|
PluginLogger,
|
|
7
|
-
} from '@atlaspack/types';
|
|
6
|
+
} from '@atlaspack/types-internal';
|
|
8
7
|
import path from 'path';
|
|
9
8
|
import {md, generateJSONCodeHighlights} from '@atlaspack/diagnostic';
|
|
10
9
|
import nullthrows from 'nullthrows';
|
|
10
|
+
// @ts-expect-error TS7016
|
|
11
11
|
import clone from 'clone';
|
|
12
12
|
import {POSTCSS_RANGE} from './constants';
|
|
13
13
|
|
|
14
14
|
import loadExternalPlugins from './loadPlugins';
|
|
15
15
|
|
|
16
|
-
type ConfigResult = {
|
|
17
|
-
raw: any
|
|
18
|
-
filePath: string
|
|
19
|
-
hydrated: {
|
|
20
|
-
plugins: Array<any
|
|
21
|
-
from: FilePath
|
|
22
|
-
to: FilePath
|
|
23
|
-
modules: any
|
|
24
|
-
|
|
25
|
-
|
|
16
|
+
type ConfigResult = {
|
|
17
|
+
raw: any;
|
|
18
|
+
filePath: string;
|
|
19
|
+
hydrated: {
|
|
20
|
+
plugins: Array<any>;
|
|
21
|
+
from: FilePath;
|
|
22
|
+
to: FilePath;
|
|
23
|
+
modules: any;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
26
|
|
|
27
27
|
async function configHydrator(
|
|
28
28
|
configFile: any,
|
|
@@ -30,7 +30,7 @@ async function configHydrator(
|
|
|
30
30
|
resolveFrom: FilePath,
|
|
31
31
|
options: PluginOptions,
|
|
32
32
|
logger: PluginLogger,
|
|
33
|
-
): Promise
|
|
33
|
+
): Promise<ConfigResult | null | undefined> {
|
|
34
34
|
if (configFile == null) {
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
@@ -80,7 +80,7 @@ async function configHydrator(
|
|
|
80
80
|
let filename = path.basename(resolveFrom);
|
|
81
81
|
let isPackageJson = filename === 'package.json';
|
|
82
82
|
let message;
|
|
83
|
-
let hints = [];
|
|
83
|
+
let hints: Array<string> = [];
|
|
84
84
|
if (!isPackageJson && redundantPlugins.length === pluginArray.length) {
|
|
85
85
|
message = md`Parcel includes CSS transpilation and vendor prefixing by default. PostCSS config __${filename}__ contains only redundant plugins. Deleting it may significantly improve build performance.`;
|
|
86
86
|
hints.push(md`Delete __${filename}__`);
|
|
@@ -149,11 +149,11 @@ export async function load({
|
|
|
149
149
|
config,
|
|
150
150
|
options,
|
|
151
151
|
logger,
|
|
152
|
-
}: {
|
|
153
|
-
config: Config
|
|
154
|
-
options: PluginOptions
|
|
155
|
-
logger: PluginLogger
|
|
156
|
-
|
|
152
|
+
}: {
|
|
153
|
+
config: Config;
|
|
154
|
+
options: PluginOptions;
|
|
155
|
+
logger: PluginLogger;
|
|
156
|
+
}): Promise<ConfigResult | null | undefined> {
|
|
157
157
|
if (!config.isSource) {
|
|
158
158
|
return;
|
|
159
159
|
}
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import type {
|
|
2
|
+
FilePath,
|
|
3
|
+
PluginOptions,
|
|
4
|
+
PackageManager,
|
|
5
|
+
} from '@atlaspack/types-internal';
|
|
5
6
|
|
|
6
7
|
export default async function loadExternalPlugins(
|
|
7
|
-
plugins:
|
|
8
|
+
plugins:
|
|
9
|
+
| Array<string>
|
|
10
|
+
| {
|
|
11
|
+
readonly [pluginName: string]: unknown;
|
|
12
|
+
},
|
|
8
13
|
relative: FilePath,
|
|
9
14
|
options: PluginOptions,
|
|
10
|
-
): Promise<Array<
|
|
15
|
+
): Promise<Array<unknown>> {
|
|
11
16
|
if (Array.isArray(plugins)) {
|
|
12
17
|
return Promise.all(
|
|
13
18
|
plugins
|
|
@@ -42,12 +47,13 @@ export default async function loadExternalPlugins(
|
|
|
42
47
|
}
|
|
43
48
|
|
|
44
49
|
async function loadPlugin(
|
|
45
|
-
pluginArg: string |
|
|
50
|
+
pluginArg: string | any,
|
|
46
51
|
relative: FilePath,
|
|
47
|
-
options:
|
|
52
|
+
options: unknown | null | undefined = {},
|
|
48
53
|
packageManager: PackageManager,
|
|
49
54
|
shouldAutoInstall: boolean,
|
|
50
|
-
|
|
55
|
+
// @ts-expect-error TS1064
|
|
56
|
+
): unknown {
|
|
51
57
|
if (typeof pluginArg !== 'string') {
|
|
52
58
|
return pluginArg;
|
|
53
59
|
}
|
package/tsconfig.json
ADDED