@atlaspack/transformer-css 2.14.5-canary.17 → 2.14.5-canary.171

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