@atlaspack/packager-css 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 CHANGED
@@ -1,5 +1,164 @@
1
1
  # @atlaspack/packager-css
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 [[`7f5841c`](https://github.com/atlassian-labs/atlaspack/commit/7f5841c39df049f9546cccbeea2a7337e0337b45)]:
17
+ - @atlaspack/types-internal@2.19.0
18
+ - @atlaspack/utils@2.18.1
19
+ - @atlaspack/plugin@2.14.24
20
+
21
+ ## 2.14.23
22
+
23
+ ### Patch Changes
24
+
25
+ - Updated dependencies [[`23d561e`](https://github.com/atlassian-labs/atlaspack/commit/23d561e51e68b0c38fd1ff4e4fb173e5e7b01cf2)]:
26
+ - @atlaspack/utils@2.18.0
27
+ - @atlaspack/plugin@2.14.23
28
+
29
+ ## 2.14.22
30
+
31
+ ### Patch Changes
32
+
33
+ - [#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
34
+
35
+ - Updated dependencies [[`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94)]:
36
+ - @atlaspack/diagnostic@2.14.2
37
+ - @atlaspack/plugin@2.14.22
38
+ - @atlaspack/utils@2.17.4
39
+
40
+ ## 2.14.21
41
+
42
+ ### Patch Changes
43
+
44
+ - Updated dependencies []:
45
+ - @atlaspack/utils@2.17.3
46
+ - @atlaspack/plugin@2.14.21
47
+
48
+ ## 2.14.20
49
+
50
+ ### Patch Changes
51
+
52
+ - [#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
53
+
54
+ - Updated dependencies [[`daaa768`](https://github.com/atlassian-labs/atlaspack/commit/daaa7688786772d7e3713b71c5bba6b89ec704aa)]:
55
+ - @atlaspack/plugin@2.14.20
56
+ - @atlaspack/utils@2.17.2
57
+
58
+ ## 2.14.19
59
+
60
+ ### Patch Changes
61
+
62
+ - Updated dependencies []:
63
+ - @atlaspack/utils@2.17.1
64
+ - @atlaspack/plugin@2.14.19
65
+
66
+ ## 2.14.18
67
+
68
+ ### Patch Changes
69
+
70
+ - 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)]:
71
+ - @atlaspack/utils@2.17.0
72
+ - @atlaspack/plugin@2.14.18
73
+
74
+ ## 2.14.17
75
+
76
+ ### Patch Changes
77
+
78
+ - Updated dependencies []:
79
+ - @atlaspack/utils@2.16.1
80
+ - @atlaspack/plugin@2.14.17
81
+
82
+ ## 2.14.16
83
+
84
+ ### Patch Changes
85
+
86
+ - Updated dependencies [[`30ee2cf`](https://github.com/atlassian-labs/atlaspack/commit/30ee2cfcd34cf2646ded0eda13fdb80a2a5de529)]:
87
+ - @atlaspack/utils@2.16.0
88
+ - @atlaspack/plugin@2.14.16
89
+
90
+ ## 2.14.15
91
+
92
+ ### Patch Changes
93
+
94
+ - Updated dependencies []:
95
+ - @atlaspack/utils@2.15.3
96
+ - @atlaspack/plugin@2.14.15
97
+
98
+ ## 2.14.14
99
+
100
+ ### Patch Changes
101
+
102
+ - Updated dependencies []:
103
+ - @atlaspack/utils@2.15.2
104
+ - @atlaspack/plugin@2.14.14
105
+
106
+ ## 2.14.13
107
+
108
+ ### Patch Changes
109
+
110
+ - Updated dependencies []:
111
+ - @atlaspack/utils@2.15.1
112
+ - @atlaspack/plugin@2.14.13
113
+
114
+ ## 2.14.12
115
+
116
+ ### Patch Changes
117
+
118
+ - Updated dependencies [[`e39c6cf`](https://github.com/atlassian-labs/atlaspack/commit/e39c6cf05f7e95ce5420dbcea66f401b1cbd397c)]:
119
+ - @atlaspack/utils@2.15.0
120
+ - @atlaspack/plugin@2.14.12
121
+
122
+ ## 2.14.11
123
+
124
+ ### Patch Changes
125
+
126
+ - Updated dependencies []:
127
+ - @atlaspack/utils@2.14.11
128
+ - @atlaspack/plugin@2.14.11
129
+
130
+ ## 2.14.10
131
+
132
+ ### Patch Changes
133
+
134
+ - Updated dependencies []:
135
+ - @atlaspack/plugin@2.14.10
136
+ - @atlaspack/utils@2.14.10
137
+
138
+ ## 2.14.9
139
+
140
+ ### Patch Changes
141
+
142
+ - Updated dependencies []:
143
+ - @atlaspack/utils@2.14.9
144
+ - @atlaspack/plugin@2.14.9
145
+
146
+ ## 2.14.8
147
+
148
+ ### Patch Changes
149
+
150
+ - Updated dependencies []:
151
+ - @atlaspack/utils@2.14.8
152
+ - @atlaspack/plugin@2.14.8
153
+
154
+ ## 2.14.7
155
+
156
+ ### Patch Changes
157
+
158
+ - Updated dependencies []:
159
+ - @atlaspack/utils@2.14.7
160
+ - @atlaspack/plugin@2.14.7
161
+
3
162
  ## 2.14.6
4
163
 
5
164
  ### Patch Changes
@@ -57,7 +57,6 @@ function _utils() {
57
57
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
58
58
  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); }
59
59
  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; }
60
- // $FlowFixMe - init for browser build.
61
60
  var _default = exports.default = new (_plugin().Packager)({
62
61
  async package({
63
62
  bundle,
@@ -77,8 +76,10 @@ var _default = exports.default = new (_plugin().Packager)({
77
76
  let queue = new (_utils().PromiseQueue)({
78
77
  maxConcurrent: 32
79
78
  });
79
+ // @ts-expect-error TS2304
80
80
  let hoistedImports = [];
81
81
  let assetsByPlaceholder = new Map();
82
+ // @ts-expect-error TS7034
82
83
  let entry = null;
83
84
  let entryContents = '';
84
85
  bundle.traverse({
@@ -86,6 +87,7 @@ var _default = exports.default = new (_plugin().Packager)({
86
87
  if (node.type === 'asset' && !context) {
87
88
  // If there is only one entry, we'll use it directly.
88
89
  // Otherwise, we'll create a fake bundle entry with @import rules for each root asset.
90
+ // @ts-expect-error TS7005
89
91
  if (entry == null) {
90
92
  entry = node.value.id;
91
93
  } else {
@@ -144,14 +146,18 @@ var _default = exports.default = new (_plugin().Packager)({
144
146
  });
145
147
  }
146
148
  });
147
- let outputs = new Map((await queue.run()).map(([asset, code, map]) => [asset, [code, map]]));
149
+ let outputs = new Map(
150
+ // @ts-expect-error TS2345
151
+ (await queue.run()).map(([asset, code, map]) => [asset, [code, map]]));
148
152
  let map = new (_sourceMap().default)(options.projectRoot);
149
153
 
150
- // $FlowFixMe
154
+ // @ts-expect-error TS2339
151
155
  if (process.browser) {
156
+ // @ts-expect-error TS2349
152
157
  await (0, _lightningcss().default)();
153
158
  }
154
159
  let res = await (0, _lightningcss().bundleAsync)({
160
+ // @ts-expect-error TS2322
155
161
  filename: (0, _nullthrows().default)(entry),
156
162
  sourceMap: !!bundle.env.sourceMap,
157
163
  resolver: {
@@ -204,7 +210,13 @@ var _default = exports.default = new (_plugin().Packager)({
204
210
  return replaceReferences(bundle, bundleGraph, contents, map, getInlineBundleContents);
205
211
  }
206
212
  });
207
- function replaceReferences(bundle, bundleGraph, contents, map, getInlineBundleContents) {
213
+ function replaceReferences(
214
+ // @ts-expect-error TS2304
215
+ bundle,
216
+ // @ts-expect-error TS2304
217
+ bundleGraph, contents,
218
+ // @ts-expect-error TS2552
219
+ map, getInlineBundleContents) {
208
220
  ({
209
221
  contents,
210
222
  map
@@ -236,8 +248,17 @@ function getSpecifier(dep) {
236
248
  function escapeString(contents) {
237
249
  return contents.replace(/(["\\])/g, '\\$1');
238
250
  }
239
- async function processCSSModule(options, logger, bundleGraph, bundle, asset) {
251
+ async function processCSSModule(
252
+ // @ts-expect-error TS2552
253
+ options,
254
+ // @ts-expect-error TS2304
255
+ logger,
256
+ // @ts-expect-error TS2304
257
+ bundleGraph,
258
+ // @ts-expect-error TS2304
259
+ bundle, asset) {
240
260
  var _await$asset$getAST;
261
+ // @ts-expect-error TS2709
241
262
  let postcss = await options.packageManager.require('postcss', options.projectRoot + '/index', {
242
263
  range: '^8.4.5',
243
264
  saveDev: true,
@@ -252,6 +273,7 @@ async function processCSSModule(options, logger, bundleGraph, bundle, asset) {
252
273
  let defaultImport = null;
253
274
  if (usedSymbols.has('default')) {
254
275
  let incoming = bundleGraph.getIncomingDependencies(asset);
276
+ // @ts-expect-error TS7006
255
277
  defaultImport = incoming.find(d => d.symbols.hasExportSymbol('default'));
256
278
  if (defaultImport) {
257
279
  var _defaultImport$symbol;
@@ -270,7 +292,9 @@ async function processCSSModule(options, logger, bundleGraph, bundle, asset) {
270
292
  }
271
293
  }
272
294
  if (!defaultImport && !usedSymbols.has('*')) {
273
- let usedLocalSymbols = new Set([...usedSymbols].map(exportSymbol => `.${(0, _nullthrows().default)(asset.symbols.get(exportSymbol)).local}`));
295
+ let usedLocalSymbols = new Set([...usedSymbols].map(exportSymbol =>
296
+ // @ts-expect-error TS2731
297
+ `.${(0, _nullthrows().default)(asset.symbols.get(exportSymbol)).local}`));
274
298
  ast.walkRules(rule => {
275
299
  if (localSymbols.has(rule.selector) && !usedLocalSymbols.has(rule.selector)) {
276
300
  rule.remove();
@@ -302,6 +326,7 @@ async function processCSSModule(options, logger, bundleGraph, bundle, asset) {
302
326
  function escapeDashedIdent(name) {
303
327
  // https://drafts.csswg.org/cssom/#serialize-an-identifier
304
328
  let res = '';
329
+ // @ts-expect-error TS2488
305
330
  for (let c of name) {
306
331
  let code = c.codePointAt(0);
307
332
  if (code === 0) {
@@ -0,0 +1,5 @@
1
+ import type { Dependency } from '@atlaspack/types-internal';
2
+ import { Packager } from '@atlaspack/plugin';
3
+ declare const _default: Packager<unknown, unknown>;
4
+ export default _default;
5
+ export declare function getSpecifier(dep: Dependency): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/packager-css",
3
- "version": "2.14.5-canary.16+4b2b575b9",
3
+ "version": "2.14.5-canary.161+ee040bb64",
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/CSSPackager.js",
13
- "source": "src/CSSPackager.js",
12
+ "main": "./lib/CSSPackager.js",
13
+ "source": "./src/CSSPackager.ts",
14
+ "types": "./lib/types/CSSPackager.d.ts",
14
15
  "engines": {
15
16
  "node": ">= 16.0.0"
16
17
  },
17
18
  "dependencies": {
18
- "@atlaspack/diagnostic": "2.14.1-canary.84+4b2b575b9",
19
- "@atlaspack/plugin": "2.14.5-canary.16+4b2b575b9",
20
- "@atlaspack/utils": "2.14.5-canary.16+4b2b575b9",
19
+ "@atlaspack/diagnostic": "2.14.1-canary.229+ee040bb64",
20
+ "@atlaspack/plugin": "2.14.5-canary.161+ee040bb64",
21
+ "@atlaspack/types-internal": "2.14.1-canary.229+ee040bb64",
22
+ "@atlaspack/utils": "2.14.5-canary.161+ee040bb64",
21
23
  "@parcel/source-map": "^2.1.1",
22
24
  "lightningcss": "^1.28.2",
23
25
  "nullthrows": "^1.1.1"
@@ -30,5 +32,9 @@
30
32
  "lightningcss": "lightningcss-wasm"
31
33
  },
32
34
  "type": "commonjs",
33
- "gitHead": "4b2b575b98951f2dcf0c45ed8e94359b23b43815"
35
+ "scripts": {
36
+ "check-ts": "tsc --emitDeclarationOnly --rootDir src",
37
+ "build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
38
+ },
39
+ "gitHead": "ee040bb6428f29b57d892ddd8107e29077d08ffd"
34
40
  }
@@ -1,9 +1,6 @@
1
- // @flow
2
-
3
1
  import type {Root} from 'postcss';
4
- import type {Asset, Dependency} from '@atlaspack/types';
5
- import typeof PostCSS from 'postcss';
6
- // $FlowFixMe - init for browser build.
2
+ import type {Asset, Dependency} from '@atlaspack/types-internal';
3
+ import PostCSS from 'postcss';
7
4
  import init, {bundleAsync} from 'lightningcss';
8
5
 
9
6
  import invariant from 'assert';
@@ -17,7 +14,7 @@ import {
17
14
  replaceURLReferences,
18
15
  } from '@atlaspack/utils';
19
16
 
20
- export default (new Packager({
17
+ export default new Packager({
21
18
  async package({
22
19
  bundle,
23
20
  bundleGraph,
@@ -43,8 +40,10 @@ export default (new Packager({
43
40
  let queue = new PromiseQueue({
44
41
  maxConcurrent: 32,
45
42
  });
46
- let hoistedImports = [];
43
+ // @ts-expect-error TS2304
44
+ let hoistedImports: Array<DependencySpecifier> = [];
47
45
  let assetsByPlaceholder = new Map();
46
+ // @ts-expect-error TS7034
48
47
  let entry = null;
49
48
  let entryContents = '';
50
49
 
@@ -53,6 +52,7 @@ export default (new Packager({
53
52
  if (node.type === 'asset' && !context) {
54
53
  // If there is only one entry, we'll use it directly.
55
54
  // Otherwise, we'll create a fake bundle entry with @import rules for each root asset.
55
+ // @ts-expect-error TS7005
56
56
  if (entry == null) {
57
57
  entry = node.value.id;
58
58
  } else {
@@ -145,23 +145,29 @@ export default (new Packager({
145
145
  });
146
146
 
147
147
  let outputs = new Map(
148
- (await queue.run()).map(([asset, code, map]) => [asset, [code, map]]),
148
+ // @ts-expect-error TS2345
149
+ (await queue.run()).map(([asset, code, map]: [any, any, any]) => [
150
+ asset,
151
+ [code, map],
152
+ ]),
149
153
  );
150
154
  let map = new SourceMap(options.projectRoot);
151
155
 
152
- // $FlowFixMe
156
+ // @ts-expect-error TS2339
153
157
  if (process.browser) {
158
+ // @ts-expect-error TS2349
154
159
  await init();
155
160
  }
156
161
 
157
162
  let res = await bundleAsync({
163
+ // @ts-expect-error TS2322
158
164
  filename: nullthrows(entry),
159
165
  sourceMap: !!bundle.env.sourceMap,
160
166
  resolver: {
161
- resolve(specifier) {
167
+ resolve(specifier: string) {
162
168
  return specifier;
163
169
  },
164
- async read(file) {
170
+ async read(file: string) {
165
171
  if (file === bundle.id) {
166
172
  return entryContents;
167
173
  }
@@ -216,14 +222,25 @@ export default (new Packager({
216
222
  getInlineBundleContents,
217
223
  );
218
224
  },
219
- }): Packager);
225
+ }) as Packager<unknown, unknown>;
220
226
 
221
227
  function replaceReferences(
222
- bundle,
223
- bundleGraph,
224
- contents,
225
- map,
226
- getInlineBundleContents,
228
+ // @ts-expect-error TS2304
229
+ bundle: NamedBundle,
230
+ // @ts-expect-error TS2304
231
+ bundleGraph: BundleGraph<NamedBundle>,
232
+ contents: string,
233
+ // @ts-expect-error TS2552
234
+ map: NodeSourceMap | null | undefined,
235
+ getInlineBundleContents: (
236
+ // @ts-expect-error TS2304
237
+ arg1: Bundle,
238
+ // @ts-expect-error TS2304
239
+ arg2: BundleGraph<NamedBundle>,
240
+ // @ts-expect-error TS2304
241
+ ) => Async<{
242
+ contents: Blob;
243
+ }>,
227
244
  ) {
228
245
  ({contents, map} = replaceURLReferences({
229
246
  bundle,
@@ -259,12 +276,17 @@ function escapeString(contents: string): string {
259
276
  }
260
277
 
261
278
  async function processCSSModule(
262
- options,
263
- logger,
264
- bundleGraph,
265
- bundle,
266
- asset,
267
- ): Promise<[Asset, string, ?SourceMap]> {
279
+ // @ts-expect-error TS2552
280
+ options: PluginOptions,
281
+ // @ts-expect-error TS2304
282
+ logger: PluginLogger,
283
+ // @ts-expect-error TS2304
284
+ bundleGraph: BundleGraph<NamedBundle>,
285
+ // @ts-expect-error TS2304
286
+ bundle: NamedBundle,
287
+ asset: Asset,
288
+ ): Promise<[Asset, string, SourceMap | null | undefined]> {
289
+ // @ts-expect-error TS2709
268
290
  let postcss: PostCSS = await options.packageManager.require(
269
291
  'postcss',
270
292
  options.projectRoot + '/index',
@@ -280,12 +302,13 @@ async function processCSSModule(
280
302
  let usedSymbols = bundleGraph.getUsedSymbols(asset);
281
303
  if (usedSymbols != null) {
282
304
  let localSymbols = new Set(
283
- [...asset.symbols].map(([, {local}]) => `.${local}`),
305
+ [...asset.symbols].map(([, {local}]: [any, any]) => `.${local}`),
284
306
  );
285
307
 
286
308
  let defaultImport = null;
287
309
  if (usedSymbols.has('default')) {
288
310
  let incoming = bundleGraph.getIncomingDependencies(asset);
311
+ // @ts-expect-error TS7006
289
312
  defaultImport = incoming.find((d) =>
290
313
  d.symbols.hasExportSymbol('default'),
291
314
  );
@@ -314,6 +337,7 @@ async function processCSSModule(
314
337
  let usedLocalSymbols = new Set(
315
338
  [...usedSymbols].map(
316
339
  (exportSymbol) =>
340
+ // @ts-expect-error TS2731
317
341
  `.${nullthrows(asset.symbols.get(exportSymbol)).local}`,
318
342
  ),
319
343
  );
@@ -349,9 +373,10 @@ async function processCSSModule(
349
373
  return [asset, content, sourceMap];
350
374
  }
351
375
 
352
- function escapeDashedIdent(name) {
376
+ function escapeDashedIdent(name: symbol | string) {
353
377
  // https://drafts.csswg.org/cssom/#serialize-an-identifier
354
378
  let res = '';
379
+ // @ts-expect-error TS2488
355
380
  for (let c of name) {
356
381
  let code = c.codePointAt(0);
357
382
  if (code === 0) {
package/tsconfig.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "../../../tsconfig.json",
3
+ "include": ["src"]
4
+ }