@atlaspack/packager-js 2.23.3 → 2.23.5-dev-af891f2f6.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.
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type {Async} from '@atlaspack/types';
2
- import type SourceMap from '@parcel/source-map';
2
+ import type SourceMap from '@atlaspack/source-map';
3
3
  import {Packager} from '@atlaspack/plugin';
4
4
  import {
5
5
  replaceInlineReferences,
@@ -16,6 +16,7 @@ import {ScopeHoistingPackager} from './ScopeHoistingPackager';
16
16
  type JSPackagerConfig = {
17
17
  parcelRequireName: string;
18
18
  unstable_asyncBundleRuntime: boolean;
19
+ unstable_manualStaticBindingExports: string[] | null;
19
20
  };
20
21
 
21
22
  const CONFIG_SCHEMA: SchemaEntity = {
@@ -24,6 +25,12 @@ const CONFIG_SCHEMA: SchemaEntity = {
24
25
  unstable_asyncBundleRuntime: {
25
26
  type: 'boolean',
26
27
  },
28
+ unstable_manualStaticBindingExports: {
29
+ type: 'array',
30
+ items: {
31
+ type: 'string',
32
+ },
33
+ },
27
34
  },
28
35
  additionalProperties: false,
29
36
  };
@@ -31,7 +38,10 @@ const CONFIG_SCHEMA: SchemaEntity = {
31
38
  export default new Packager({
32
39
  async loadConfig({config, options}): Promise<JSPackagerConfig> {
33
40
  let packageKey = '@atlaspack/packager-js';
34
- let conf = await config.getConfigFrom(options.projectRoot + '/index', [], {
41
+ let conf = await config.getConfigFrom<{
42
+ unstable_asyncBundleRuntime?: boolean;
43
+ unstable_manualStaticBindingExports?: string[];
44
+ }>(options.projectRoot + '/index', [], {
35
45
  packageKey,
36
46
  });
37
47
 
@@ -51,7 +61,7 @@ export default new Packager({
51
61
 
52
62
  // Generate a name for the global parcelRequire function that is unique to this project.
53
63
  // This allows multiple parcel builds to coexist on the same page.
54
- let packageName = await config.getConfigFrom(
64
+ let packageName = await config.getConfigFrom<string>(
55
65
  options.projectRoot + '/index',
56
66
  [],
57
67
  {
@@ -61,12 +71,12 @@ export default new Packager({
61
71
 
62
72
  let name = packageName?.contents ?? '';
63
73
  return {
64
- // @ts-expect-error TS2345
65
74
  parcelRequireName: 'parcelRequire' + hashString(name).slice(-4),
66
75
  unstable_asyncBundleRuntime: Boolean(
67
- // @ts-expect-error TS2339
68
76
  conf?.contents?.unstable_asyncBundleRuntime,
69
77
  ),
78
+ unstable_manualStaticBindingExports:
79
+ conf?.contents?.unstable_manualStaticBindingExports ?? null,
70
80
  };
71
81
  },
72
82
  async package({
@@ -100,6 +110,7 @@ export default new Packager({
100
110
  bundle,
101
111
  nullthrows(config).parcelRequireName,
102
112
  nullthrows(config).unstable_asyncBundleRuntime,
113
+ nullthrows(config).unstable_manualStaticBindingExports,
103
114
  logger,
104
115
  )
105
116
  : new DevPackager(
package/src/utils.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type {BundleGraph, Dependency, NamedBundle} from '@atlaspack/types';
2
- import type SourceMap from '@parcel/source-map';
2
+ import type SourceMap from '@atlaspack/source-map';
3
3
  import nullthrows from 'nullthrows';
4
4
 
5
5
  // This replaces __parcel__require__ references left by the transformer with