@atlaspack/packager-js 2.19.0 → 2.19.1-typescript-5ad950d33.0

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.
@@ -1,4 +1,3 @@
1
- // @flow strict-local
2
1
  import type {Async} from '@atlaspack/types';
3
2
  import type SourceMap from '@parcel/source-map';
4
3
  import {Packager} from '@atlaspack/plugin';
@@ -6,7 +5,7 @@ import {
6
5
  replaceInlineReferences,
7
6
  replaceURLReferences,
8
7
  validateSchema,
9
- type SchemaEntity,
8
+ SchemaEntity,
10
9
  } from '@atlaspack/utils';
11
10
  import {encodeJSONKeyComponent} from '@atlaspack/diagnostic';
12
11
  import {hashString} from '@atlaspack/rust';
@@ -14,10 +13,10 @@ import nullthrows from 'nullthrows';
14
13
  import {DevPackager} from './DevPackager';
15
14
  import {ScopeHoistingPackager} from './ScopeHoistingPackager';
16
15
 
17
- type JSPackagerConfig = {|
18
- parcelRequireName: string,
19
- unstable_asyncBundleRuntime: boolean,
20
- |};
16
+ type JSPackagerConfig = {
17
+ parcelRequireName: string;
18
+ unstable_asyncBundleRuntime: boolean;
19
+ };
21
20
 
22
21
  const CONFIG_SCHEMA: SchemaEntity = {
23
22
  type: 'object',
@@ -29,7 +28,7 @@ const CONFIG_SCHEMA: SchemaEntity = {
29
28
  additionalProperties: false,
30
29
  };
31
30
 
32
- export default (new Packager({
31
+ export default new Packager({
33
32
  async loadConfig({config, options}): Promise<JSPackagerConfig> {
34
33
  let packageKey = '@atlaspack/packager-js';
35
34
  let conf = await config.getConfigFrom(options.projectRoot + '/index', [], {
@@ -62,8 +61,10 @@ export default (new Packager({
62
61
 
63
62
  let name = packageName?.contents ?? '';
64
63
  return {
64
+ // @ts-expect-error TS2345
65
65
  parcelRequireName: 'parcelRequire' + hashString(name).slice(-4),
66
66
  unstable_asyncBundleRuntime: Boolean(
67
+ // @ts-expect-error TS2339
67
68
  conf?.contents?.unstable_asyncBundleRuntime,
68
69
  ),
69
70
  };
@@ -97,10 +98,7 @@ export default (new Packager({
97
98
  options,
98
99
  bundleGraph,
99
100
  bundle,
100
- // $FlowFixMe
101
- // $FlowFixMe
102
101
  nullthrows(config).parcelRequireName,
103
- // $FlowFixMe
104
102
  nullthrows(config).unstable_asyncBundleRuntime,
105
103
  logger,
106
104
  )
@@ -108,8 +106,6 @@ export default (new Packager({
108
106
  options,
109
107
  bundleGraph,
110
108
  bundle,
111
- // $FlowFixMe
112
- // $FlowFixMe
113
109
  nullthrows(config).parcelRequireName,
114
110
  );
115
111
 
@@ -142,11 +138,13 @@ export default (new Packager({
142
138
  map,
143
139
  });
144
140
  },
145
- }): Packager<mixed, mixed>);
141
+ }) as Packager<unknown, unknown>;
146
142
 
147
143
  async function getSourceMapSuffix(
148
- getSourceMapReference: (?SourceMap) => Async<?string>,
149
- map: ?SourceMap,
144
+ getSourceMapReference: (
145
+ arg1?: SourceMap | null | undefined,
146
+ ) => Async<string | null | undefined>,
147
+ map?: SourceMap | null,
150
148
  ): Promise<string> {
151
149
  let sourcemapReference = await getSourceMapReference(map);
152
150
  if (sourcemapReference != null) {
@@ -1,4 +1,3 @@
1
- // @flow
2
1
  import type {BundleGraph, Dependency, NamedBundle} from '@atlaspack/types';
3
2
  import type SourceMap from '@parcel/source-map';
4
3
  import nullthrows from 'nullthrows';
@@ -10,7 +9,7 @@ export function replaceScriptDependencies(
10
9
  bundleGraph: BundleGraph<NamedBundle>,
11
10
  bundle: NamedBundle,
12
11
  code: string,
13
- map: ?SourceMap,
12
+ map: SourceMap | null | undefined,
14
13
  parcelRequireName: string,
15
14
  ): string {
16
15
  let entry = nullthrows(bundle.getMainEntry());
package/tsconfig.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "../../../tsconfig.json",
3
+ "include": ["src"]
4
+ }