@atlaspack/packager-js 2.18.2 → 2.18.3-typescript-08dcc1c9b.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/CHANGELOG.md +0 -1
- package/LICENSE +201 -0
- package/lib/DevPackager.js +8 -1
- package/lib/ScopeHoistingPackager.js +124 -16
- package/lib/dev-prelude.js +6 -6
- package/lib/index.js +4 -10
- package/package.json +14 -9
- package/src/{CJSOutputFormat.js → CJSOutputFormat.ts} +0 -1
- package/src/{DevPackager.js → DevPackager.ts} +18 -5
- package/src/{ESMOutputFormat.js → ESMOutputFormat.ts} +2 -3
- package/src/{GlobalOutputFormat.js → GlobalOutputFormat.ts} +0 -1
- package/src/{ScopeHoistingPackager.js → ScopeHoistingPackager.ts} +123 -41
- package/src/dev-prelude.js +6 -6
- package/src/{helpers.js → helpers.ts} +1 -2
- package/src/{index.js → index.ts} +13 -15
- package/src/{utils.js → utils.ts} +1 -2
- package/tsconfig.json +4 -0
|
@@ -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
|
-
|
|
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
|
|
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
|
-
})
|
|
141
|
+
}) as Packager<unknown, unknown>;
|
|
146
142
|
|
|
147
143
|
async function getSourceMapSuffix(
|
|
148
|
-
getSourceMapReference: (
|
|
149
|
-
|
|
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:
|
|
12
|
+
map: SourceMap | null | undefined,
|
|
14
13
|
parcelRequireName: string,
|
|
15
14
|
): string {
|
|
16
15
|
let entry = nullthrows(bundle.getMainEntry());
|
package/tsconfig.json
ADDED