@atlaspack/packager-js 2.18.3-typescript-5b4d3ad41.0 → 2.19.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 +26 -0
- package/lib/DevPackager.js +1 -8
- package/lib/ScopeHoistingPackager.js +24 -128
- package/lib/dev-prelude.js +6 -6
- package/lib/index.js +10 -4
- package/package.json +11 -16
- package/src/{CJSOutputFormat.ts → CJSOutputFormat.js} +1 -0
- package/src/{DevPackager.ts → DevPackager.js} +5 -18
- package/src/{ESMOutputFormat.ts → ESMOutputFormat.js} +3 -2
- package/src/{GlobalOutputFormat.ts → GlobalOutputFormat.js} +1 -0
- package/src/{ScopeHoistingPackager.ts → ScopeHoistingPackager.js} +46 -124
- package/src/dev-prelude.js +6 -6
- package/src/{helpers.ts → helpers.js} +2 -1
- package/src/{index.ts → index.js} +15 -13
- package/src/{utils.ts → utils.js} +2 -1
- package/LICENSE +0 -201
- package/lib/CJSOutputFormat.d.ts +0 -7
- package/lib/DevPackager.d.ts +0 -15
- package/lib/ESMOutputFormat.d.ts +0 -7
- package/lib/GlobalOutputFormat.d.ts +0 -7
- package/lib/ScopeHoistingPackager.d.ts +0 -65
- package/lib/helpers.d.ts +0 -11
- package/lib/index.d.ts +0 -3
- package/lib/utils.d.ts +0 -6
- package/tsconfig.json +0 -4
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @flow strict-local
|
|
1
2
|
import type {BundleGraph, PluginOptions, NamedBundle} from '@atlaspack/types';
|
|
2
3
|
|
|
3
4
|
import {
|
|
@@ -36,10 +37,7 @@ export class DevPackager {
|
|
|
36
37
|
this.parcelRequireName = parcelRequireName;
|
|
37
38
|
}
|
|
38
39
|
|
|
39
|
-
async package(): Promise<{
|
|
40
|
-
contents: string;
|
|
41
|
-
map: SourceMap | null | undefined;
|
|
42
|
-
}> {
|
|
40
|
+
async package(): Promise<{|contents: string, map: ?SourceMap|}> {
|
|
43
41
|
// Load assets
|
|
44
42
|
let queue = new PromiseQueue({maxConcurrent: 32});
|
|
45
43
|
this.bundle.traverseAssets((asset) => {
|
|
@@ -61,13 +59,7 @@ export class DevPackager {
|
|
|
61
59
|
|
|
62
60
|
let prefix = this.getPrefix();
|
|
63
61
|
let lineOffset = countLines(prefix);
|
|
64
|
-
let script:
|
|
65
|
-
| {
|
|
66
|
-
code: string;
|
|
67
|
-
mapBuffer: Buffer | null | undefined;
|
|
68
|
-
}
|
|
69
|
-
| null
|
|
70
|
-
| undefined = null;
|
|
62
|
+
let script: ?{|code: string, mapBuffer: ?Buffer|} = null;
|
|
71
63
|
|
|
72
64
|
this.bundle.traverse((node) => {
|
|
73
65
|
let wrapped = first ? '' : ',';
|
|
@@ -102,12 +94,11 @@ export class DevPackager {
|
|
|
102
94
|
this.bundle.env.sourceType === 'script' &&
|
|
103
95
|
asset === this.bundle.getMainEntry()
|
|
104
96
|
) {
|
|
105
|
-
// @ts-expect-error TS2322
|
|
106
97
|
script = results[i++];
|
|
107
98
|
return;
|
|
108
99
|
}
|
|
109
100
|
|
|
110
|
-
let deps
|
|
101
|
+
let deps = {};
|
|
111
102
|
let dependencies = this.bundleGraph.getDependencies(asset);
|
|
112
103
|
for (let dep of dependencies) {
|
|
113
104
|
let resolved = this.bundleGraph.getResolvedAsset(dep, this.bundle);
|
|
@@ -134,7 +125,6 @@ export class DevPackager {
|
|
|
134
125
|
}
|
|
135
126
|
}
|
|
136
127
|
|
|
137
|
-
// @ts-expect-error TS2339
|
|
138
128
|
let {code, mapBuffer} = results[i];
|
|
139
129
|
let output = code || '';
|
|
140
130
|
wrapped +=
|
|
@@ -215,7 +205,6 @@ export class DevPackager {
|
|
|
215
205
|
// runtimes with a parcelRequire call.
|
|
216
206
|
if (this.bundle.env.sourceType === 'script' && script) {
|
|
217
207
|
let entryMap;
|
|
218
|
-
// @ts-expect-error TS2339
|
|
219
208
|
let mapBuffer = script.mapBuffer;
|
|
220
209
|
if (mapBuffer) {
|
|
221
210
|
entryMap = new SourceMap(this.options.projectRoot, mapBuffer);
|
|
@@ -223,13 +212,11 @@ export class DevPackager {
|
|
|
223
212
|
contents += replaceScriptDependencies(
|
|
224
213
|
this.bundleGraph,
|
|
225
214
|
this.bundle,
|
|
226
|
-
// @ts-expect-error TS2339
|
|
227
215
|
script.code,
|
|
228
216
|
entryMap,
|
|
229
217
|
this.parcelRequireName,
|
|
230
218
|
);
|
|
231
219
|
if (this.bundle.env.sourceMap && entryMap) {
|
|
232
|
-
// @ts-expect-error TS2551
|
|
233
220
|
map.addSourceMap(entryMap, lineOffset);
|
|
234
221
|
}
|
|
235
222
|
}
|
|
@@ -241,7 +228,7 @@ export class DevPackager {
|
|
|
241
228
|
}
|
|
242
229
|
|
|
243
230
|
getPrefix(): string {
|
|
244
|
-
let interpreter: string
|
|
231
|
+
let interpreter: ?string;
|
|
245
232
|
let mainEntry = this.bundle.getMainEntry();
|
|
246
233
|
if (mainEntry && this.isEntry() && !this.bundle.target.env.isBrowser()) {
|
|
247
234
|
let _interpreter = mainEntry.meta.interpreter;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @flow
|
|
1
2
|
import type {
|
|
2
3
|
ScopeHoistingPackager,
|
|
3
4
|
OutputFormat,
|
|
@@ -17,7 +18,7 @@ export class ESMOutputFormat implements OutputFormat {
|
|
|
17
18
|
for (let [source, specifiers] of this.packager.externals) {
|
|
18
19
|
let defaultSpecifier = null;
|
|
19
20
|
let namespaceSpecifier = null;
|
|
20
|
-
let namedSpecifiers
|
|
21
|
+
let namedSpecifiers = [];
|
|
21
22
|
for (let [imported, symbol] of specifiers) {
|
|
22
23
|
if (imported === 'default' /* || isCommonJS*/) {
|
|
23
24
|
defaultSpecifier = symbol;
|
|
@@ -76,7 +77,7 @@ export class ESMOutputFormat implements OutputFormat {
|
|
|
76
77
|
buildBundlePostlude(): [string, number] {
|
|
77
78
|
let res = '';
|
|
78
79
|
let lines = 0;
|
|
79
|
-
let exportSpecifiers
|
|
80
|
+
let exportSpecifiers = [];
|
|
80
81
|
for (let {
|
|
81
82
|
asset,
|
|
82
83
|
exportSymbol,
|