@atlaspack/transformer-compiled 0.3.2-canary.4182 → 0.3.2-canary.4183
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/CompiledTransformer.js +15 -0
- package/lib/types/CompiledTransformer.d.ts +3 -0
- package/lib/types/types.d.ts +12 -0
- package/package.json +7 -6
- package/src/CompiledTransformer.ts +21 -0
- package/src/types.ts +11 -0
|
@@ -16,6 +16,7 @@ const generator_1 = __importDefault(require("@babel/generator"));
|
|
|
16
16
|
const plugin_1 = require("@atlaspack/plugin");
|
|
17
17
|
const source_map_1 = __importDefault(require("@atlaspack/source-map"));
|
|
18
18
|
const utils_1 = require("@atlaspack/utils");
|
|
19
|
+
const browserslist_1 = __importDefault(require("browserslist"));
|
|
19
20
|
const utils_2 = require("./utils");
|
|
20
21
|
const babel_plugin_1 = __importDefault(require("@compiled/babel-plugin"));
|
|
21
22
|
const babel_plugin_strip_runtime_1 = __importDefault(require("@compiled/babel-plugin-strip-runtime"));
|
|
@@ -46,6 +47,14 @@ exports.default = new plugin_1.Transformer({
|
|
|
46
47
|
ssr: false,
|
|
47
48
|
importSources: utils_2.DEFAULT_IMPORT_SOURCES,
|
|
48
49
|
};
|
|
50
|
+
// Pre-load the browserslist config during setup().
|
|
51
|
+
// If we don't do this, calling transformAsync() will cause Babel's
|
|
52
|
+
// @babel/helper-compilation-targets to walk up the directory
|
|
53
|
+
// tree reading package.json files on every transform, causing
|
|
54
|
+
// cache bailouts for every file.
|
|
55
|
+
let browserslistConfig = browserslist_1.default.loadConfig({
|
|
56
|
+
path: options.projectRoot,
|
|
57
|
+
});
|
|
49
58
|
if (conf) {
|
|
50
59
|
if (conf.filePath.endsWith('.js')) {
|
|
51
60
|
config.invalidateOnStartup();
|
|
@@ -81,6 +90,7 @@ exports.default = new plugin_1.Transformer({
|
|
|
81
90
|
compiledConfig: contents,
|
|
82
91
|
mode: options.mode,
|
|
83
92
|
projectRoot: options.projectRoot,
|
|
93
|
+
browserslist: browserslistConfig,
|
|
84
94
|
},
|
|
85
95
|
conditions: {
|
|
86
96
|
codeMatch: contents.importSources,
|
|
@@ -105,6 +115,7 @@ exports.default = new plugin_1.Transformer({
|
|
|
105
115
|
'NODE_DEBUG',
|
|
106
116
|
'CI',
|
|
107
117
|
'COLORTERM',
|
|
118
|
+
'TERM',
|
|
108
119
|
],
|
|
109
120
|
disableCache: hasExternalBabelPlugins,
|
|
110
121
|
};
|
|
@@ -141,6 +152,10 @@ exports.default = new plugin_1.Transformer({
|
|
|
141
152
|
filename: asset.filePath,
|
|
142
153
|
babelrc: false,
|
|
143
154
|
configFile: false,
|
|
155
|
+
// Disable browserslistConfigFile because we pass the browserslist config via the targets option
|
|
156
|
+
// to prevent FS reads while resolving browserslist config.
|
|
157
|
+
browserslistConfigFile: false,
|
|
158
|
+
targets: config.browserslist ?? {},
|
|
144
159
|
sourceMaps: !!asset.env.sourceMap,
|
|
145
160
|
compact: false,
|
|
146
161
|
plugins: [
|
package/lib/types/types.d.ts
CHANGED
|
@@ -69,5 +69,17 @@ export interface CompiledTransformerOpts extends BabelPluginOpts {
|
|
|
69
69
|
* This will throw an error if used alongside extraction or `extract: true`.
|
|
70
70
|
*/
|
|
71
71
|
classHashPrefix?: string;
|
|
72
|
+
/**
|
|
73
|
+
* Browserslist configuration for Babel's target resolution.
|
|
74
|
+
* If not specified, the transformer will try to read it from the nearest package.json.
|
|
75
|
+
*
|
|
76
|
+
* This can be a string array of browser queries, or an object mapping environment names
|
|
77
|
+
* to query arrays (e.g., { production: ["..."], development: ["..."] }).
|
|
78
|
+
*
|
|
79
|
+
* Example: ["last 2 Chrome versions", "last 2 Firefox versions"]
|
|
80
|
+
*/
|
|
81
|
+
browserslist?: string[] | {
|
|
82
|
+
[env: string]: string[];
|
|
83
|
+
};
|
|
72
84
|
}
|
|
73
85
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/transformer-compiled",
|
|
3
|
-
"version": "0.3.2-canary.
|
|
3
|
+
"version": "0.3.2-canary.4183+47658d4d2",
|
|
4
4
|
"description": "Atlaspack transformer for Compiled CSS-in-JS (insourced from @compiled/parcel-transformer)",
|
|
5
5
|
"license": "(MIT OR Apache-2.0)",
|
|
6
6
|
"publishConfig": {
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"src"
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@atlaspack/plugin": "2.14.5-canary.
|
|
25
|
-
"@atlaspack/source-map": "3.2.9-canary.
|
|
26
|
-
"@atlaspack/utils": "2.14.5-canary.
|
|
24
|
+
"@atlaspack/plugin": "2.14.5-canary.404+47658d4d2",
|
|
25
|
+
"@atlaspack/source-map": "3.2.9-canary.4183+47658d4d2",
|
|
26
|
+
"@atlaspack/utils": "2.14.5-canary.404+47658d4d2",
|
|
27
27
|
"@babel/core": "7.24.9",
|
|
28
28
|
"@babel/generator": "^7.22.10",
|
|
29
29
|
"@babel/plugin-syntax-jsx": "^7.27.1",
|
|
@@ -31,14 +31,15 @@
|
|
|
31
31
|
"@compiled/babel-plugin": "^0.36.0",
|
|
32
32
|
"@compiled/babel-plugin-strip-runtime": "^0.36.0",
|
|
33
33
|
"@compiled/utils": "^0.13.1",
|
|
34
|
+
"browserslist": "^4.28.1",
|
|
34
35
|
"enhanced-resolve": "^5.18.1"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
|
-
"@atlaspack/types": "2.14.5-canary.
|
|
38
|
+
"@atlaspack/types": "2.14.5-canary.404+47658d4d2"
|
|
38
39
|
},
|
|
39
40
|
"type": "commonjs",
|
|
40
41
|
"scripts": {
|
|
41
42
|
"build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
|
|
42
43
|
},
|
|
43
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "47658d4d250edfa8c45db8048778547025c673a3"
|
|
44
45
|
}
|
|
@@ -17,6 +17,7 @@ import type {
|
|
|
17
17
|
import {Transformer} from '@atlaspack/plugin';
|
|
18
18
|
import SourceMap from '@atlaspack/source-map';
|
|
19
19
|
import {relativeUrl} from '@atlaspack/utils';
|
|
20
|
+
import browserslist from 'browserslist';
|
|
20
21
|
|
|
21
22
|
import type {CompiledTransformerOpts} from './types';
|
|
22
23
|
import {
|
|
@@ -47,6 +48,11 @@ interface Config {
|
|
|
47
48
|
compiledConfig: CompiledTransformerOpts;
|
|
48
49
|
mode: BuildMode;
|
|
49
50
|
projectRoot: string;
|
|
51
|
+
browserslist?:
|
|
52
|
+
| Array<string>
|
|
53
|
+
| {
|
|
54
|
+
[key: string]: Array<string>;
|
|
55
|
+
};
|
|
50
56
|
}
|
|
51
57
|
|
|
52
58
|
/**
|
|
@@ -69,6 +75,15 @@ export default new Transformer<Config>({
|
|
|
69
75
|
importSources: DEFAULT_IMPORT_SOURCES,
|
|
70
76
|
};
|
|
71
77
|
|
|
78
|
+
// Pre-load the browserslist config during setup().
|
|
79
|
+
// If we don't do this, calling transformAsync() will cause Babel's
|
|
80
|
+
// @babel/helper-compilation-targets to walk up the directory
|
|
81
|
+
// tree reading package.json files on every transform, causing
|
|
82
|
+
// cache bailouts for every file.
|
|
83
|
+
let browserslistConfig: string[] | undefined = browserslist.loadConfig({
|
|
84
|
+
path: options.projectRoot,
|
|
85
|
+
});
|
|
86
|
+
|
|
72
87
|
if (conf) {
|
|
73
88
|
if (conf.filePath.endsWith('.js')) {
|
|
74
89
|
config.invalidateOnStartup();
|
|
@@ -117,6 +132,7 @@ export default new Transformer<Config>({
|
|
|
117
132
|
compiledConfig: contents,
|
|
118
133
|
mode: options.mode,
|
|
119
134
|
projectRoot: options.projectRoot,
|
|
135
|
+
browserslist: browserslistConfig,
|
|
120
136
|
},
|
|
121
137
|
conditions: {
|
|
122
138
|
codeMatch: contents.importSources,
|
|
@@ -141,6 +157,7 @@ export default new Transformer<Config>({
|
|
|
141
157
|
'NODE_DEBUG',
|
|
142
158
|
'CI',
|
|
143
159
|
'COLORTERM',
|
|
160
|
+
'TERM',
|
|
144
161
|
],
|
|
145
162
|
disableCache: hasExternalBabelPlugins,
|
|
146
163
|
};
|
|
@@ -190,6 +207,10 @@ export default new Transformer<Config>({
|
|
|
190
207
|
filename: asset.filePath,
|
|
191
208
|
babelrc: false,
|
|
192
209
|
configFile: false,
|
|
210
|
+
// Disable browserslistConfigFile because we pass the browserslist config via the targets option
|
|
211
|
+
// to prevent FS reads while resolving browserslist config.
|
|
212
|
+
browserslistConfigFile: false,
|
|
213
|
+
targets: config.browserslist ?? {},
|
|
193
214
|
sourceMaps: !!asset.env.sourceMap,
|
|
194
215
|
compact: false,
|
|
195
216
|
plugins: [
|
package/src/types.ts
CHANGED
|
@@ -80,4 +80,15 @@ export interface CompiledTransformerOpts extends BabelPluginOpts {
|
|
|
80
80
|
* This will throw an error if used alongside extraction or `extract: true`.
|
|
81
81
|
*/
|
|
82
82
|
classHashPrefix?: string;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Browserslist configuration for Babel's target resolution.
|
|
86
|
+
* If not specified, the transformer will try to read it from the nearest package.json.
|
|
87
|
+
*
|
|
88
|
+
* This can be a string array of browser queries, or an object mapping environment names
|
|
89
|
+
* to query arrays (e.g., { production: ["..."], development: ["..."] }).
|
|
90
|
+
*
|
|
91
|
+
* Example: ["last 2 Chrome versions", "last 2 Firefox versions"]
|
|
92
|
+
*/
|
|
93
|
+
browserslist?: string[] | {[env: string]: string[]};
|
|
83
94
|
}
|