@atlaspack/packager-css 2.14.5-canary.25 → 2.14.5-canary.250

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/packager-css",
3
- "version": "2.14.5-canary.25+b8a4ae8f8",
3
+ "version": "2.14.5-canary.250+9cd952197",
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.93+b8a4ae8f8",
19
- "@atlaspack/plugin": "2.14.5-canary.25+b8a4ae8f8",
20
- "@atlaspack/utils": "2.14.5-canary.25+b8a4ae8f8",
19
+ "@atlaspack/diagnostic": "2.14.1-canary.318+9cd952197",
20
+ "@atlaspack/plugin": "2.14.5-canary.250+9cd952197",
21
+ "@atlaspack/types-internal": "2.14.1-canary.318+9cd952197",
22
+ "@atlaspack/utils": "2.14.5-canary.250+9cd952197",
21
23
  "@parcel/source-map": "^2.1.1",
22
24
  "lightningcss": "^1.28.2",
23
25
  "nullthrows": "^1.1.1"
@@ -30,5 +32,8 @@
30
32
  "lightningcss": "lightningcss-wasm"
31
33
  },
32
34
  "type": "commonjs",
33
- "gitHead": "b8a4ae8f83dc0a83d8b145c5f729936ce52080a3"
34
- }
35
+ "scripts": {
36
+ "build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
37
+ },
38
+ "gitHead": "9cd9521978f783046e2ae4ce78f2de7aeb07d073"
39
+ }
@@ -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
  );
@@ -349,9 +372,10 @@ async function processCSSModule(
349
372
  return [asset, content, sourceMap];
350
373
  }
351
374
 
352
- function escapeDashedIdent(name) {
375
+ function escapeDashedIdent(name: symbol | string) {
353
376
  // https://drafts.csswg.org/cssom/#serialize-an-identifier
354
377
  let res = '';
378
+ // @ts-expect-error TS2488
355
379
  for (let c of name) {
356
380
  let code = c.codePointAt(0);
357
381
  if (code === 0) {
package/tsconfig.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "extends": "../../../tsconfig.base.json",
3
+ "include": ["src"],
4
+ "compilerOptions": {
5
+ "composite": true
6
+ },
7
+ "references": [
8
+ {
9
+ "path": "../../core/diagnostic/tsconfig.json"
10
+ },
11
+ {
12
+ "path": "../../core/plugin/tsconfig.json"
13
+ },
14
+ {
15
+ "path": "../../core/types-internal/tsconfig.json"
16
+ },
17
+ {
18
+ "path": "../../core/utils/tsconfig.json"
19
+ }
20
+ ]
21
+ }