@atlaspack/transformer-css 2.14.5-canary.19 → 2.14.5-canary.190

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