@atlaspack/packager-js 2.14.5-canary.19 → 2.14.5-canary.191

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.
@@ -12,12 +12,12 @@
12
12
  typeof globalThis !== 'undefined'
13
13
  ? globalThis
14
14
  : typeof self !== 'undefined'
15
- ? self
16
- : typeof window !== 'undefined'
17
- ? window
18
- : typeof global !== 'undefined'
19
- ? global
20
- : {};
15
+ ? self
16
+ : typeof window !== 'undefined'
17
+ ? window
18
+ : typeof global !== 'undefined'
19
+ ? global
20
+ : {};
21
21
  /* eslint-enable no-undef */
22
22
 
23
23
  // Save the require from previous bundle to this closure if any
@@ -1,7 +1,6 @@
1
- // @flow strict-local
2
1
  import type {Environment} from '@atlaspack/types';
3
2
 
4
- export const prelude = (parcelRequireName: string): string => `
3
+ export const preludeOld = (parcelRequireName: string): string => `
5
4
  var $parcel$modules = {};
6
5
  var $parcel$inits = {};
7
6
 
@@ -35,6 +34,41 @@ if (parcelRequire == null) {
35
34
  var parcelRegister = parcelRequire.register;
36
35
  `;
37
36
 
37
+ export const preludeNew = (parcelRequireName: string): string => `
38
+ var $parcel$modules = {};
39
+ var $parcel$inits = {};
40
+
41
+ var parcelRequire = $parcel$global[${JSON.stringify(parcelRequireName)}];
42
+
43
+ if (parcelRequire == null) {
44
+ parcelRequire = function(id) {
45
+ var mod = $parcel$modules[id];
46
+ if (mod !== undefined) {
47
+ return mod.exports;
48
+ }
49
+ var init = $parcel$inits[id];
50
+ if (init !== undefined) {
51
+ delete $parcel$inits[id];
52
+ var module = {id: id, exports: {}};
53
+ $parcel$modules[id] = module;
54
+ init.call(module.exports, module, module.exports);
55
+ return module.exports;
56
+ }
57
+ var err = new Error("Cannot find module '" + id + "'");
58
+ err.code = 'MODULE_NOT_FOUND';
59
+ throw err;
60
+ };
61
+
62
+ parcelRequire.register = function register(id, init) {
63
+ $parcel$inits[id] = init;
64
+ };
65
+
66
+ $parcel$global[${JSON.stringify(parcelRequireName)}] = parcelRequire;
67
+ }
68
+
69
+ var parcelRegister = parcelRequire.register;
70
+ `;
71
+
38
72
  export const fnExpr = (
39
73
  env: Environment,
40
74
  params: Array<string>,
@@ -166,4 +200,4 @@ export const helpers = {
166
200
  $parcel$interopDefault,
167
201
  $parcel$global,
168
202
  $parcel$defineInteropFlag,
169
- };
203
+ } as const;
@@ -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,11 +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
- unstable_forceSkipWrapAssets: Array<string>,
21
- |};
16
+ type JSPackagerConfig = {
17
+ parcelRequireName: string;
18
+ unstable_asyncBundleRuntime: boolean;
19
+ };
22
20
 
23
21
  const CONFIG_SCHEMA: SchemaEntity = {
24
22
  type: 'object',
@@ -26,17 +24,11 @@ const CONFIG_SCHEMA: SchemaEntity = {
26
24
  unstable_asyncBundleRuntime: {
27
25
  type: 'boolean',
28
26
  },
29
- unstable_forceSkipWrapAssets: {
30
- type: 'array',
31
- items: {
32
- type: 'string',
33
- },
34
- },
35
27
  },
36
28
  additionalProperties: false,
37
29
  };
38
30
 
39
- export default (new Packager({
31
+ export default new Packager({
40
32
  async loadConfig({config, options}): Promise<JSPackagerConfig> {
41
33
  let packageKey = '@atlaspack/packager-js';
42
34
  let conf = await config.getConfigFrom(options.projectRoot + '/index', [], {
@@ -69,12 +61,12 @@ export default (new Packager({
69
61
 
70
62
  let name = packageName?.contents ?? '';
71
63
  return {
64
+ // @ts-expect-error TS2345
72
65
  parcelRequireName: 'parcelRequire' + hashString(name).slice(-4),
73
66
  unstable_asyncBundleRuntime: Boolean(
67
+ // @ts-expect-error TS2339
74
68
  conf?.contents?.unstable_asyncBundleRuntime,
75
69
  ),
76
- unstable_forceSkipWrapAssets:
77
- conf?.contents?.unstable_forceSkipWrapAssets ?? [],
78
70
  };
79
71
  },
80
72
  async package({
@@ -108,7 +100,6 @@ export default (new Packager({
108
100
  bundle,
109
101
  nullthrows(config).parcelRequireName,
110
102
  nullthrows(config).unstable_asyncBundleRuntime,
111
- nullthrows(config).unstable_forceSkipWrapAssets,
112
103
  logger,
113
104
  )
114
105
  : new DevPackager(
@@ -147,11 +138,13 @@ export default (new Packager({
147
138
  map,
148
139
  });
149
140
  },
150
- }): Packager);
141
+ }) as Packager<unknown, unknown>;
151
142
 
152
143
  async function getSourceMapSuffix(
153
- getSourceMapReference: (?SourceMap) => Async<?string>,
154
- map: ?SourceMap,
144
+ getSourceMapReference: (
145
+ arg1?: SourceMap | null | undefined,
146
+ ) => Async<string | null | undefined>,
147
+ map?: SourceMap | null,
155
148
  ): Promise<string> {
156
149
  let sourcemapReference = await getSourceMapReference(map);
157
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
+ }