@parcel/packager-js
Advanced tools
Comparing version 2.0.0-nightly.173 to 2.0.0-nightly.177
@@ -10,2 +10,4 @@ "use strict"; | ||
var _nullthrows = _interopRequireDefault(require("nullthrows")); | ||
var _plugin = require("@parcel/plugin"); | ||
@@ -61,5 +63,9 @@ | ||
}); | ||
let { | ||
contents, | ||
map | ||
} = (0, _scopeHoisting.generate)(bundleGraph, bundle, ast, options); | ||
return replaceReferences({ | ||
contents: (0, _scopeHoisting.generate)(bundleGraph, bundle, ast).contents, | ||
map: null | ||
contents: contents + '\n' + (await getSourceMapSuffix(getSourceMapReference, map)), | ||
map | ||
}); | ||
@@ -74,15 +80,17 @@ } | ||
let codeQueue = new _utils.PromiseQueue({ | ||
let queue = new _utils.PromiseQueue({ | ||
maxConcurrent: 32 | ||
}); | ||
let mapQueue = new _utils.PromiseQueue({ | ||
maxConcurrent: 32 | ||
}); | ||
bundle.traverse(node => { | ||
if (node.type === 'asset') { | ||
codeQueue.add(() => node.value.getCode()); | ||
mapQueue.add(() => node.value.getMapBuffer()); | ||
queue.add(async () => { | ||
let [code, mapBuffer] = await Promise.all([node.value.getCode(), node.value.getMapBuffer()]); | ||
return { | ||
code, | ||
mapBuffer | ||
}; | ||
}); | ||
} | ||
}); | ||
let [code, maps] = await Promise.all([codeQueue.run(), mapQueue.run()]); | ||
let results = await queue.run(); | ||
let assets = ''; | ||
@@ -125,3 +133,7 @@ let i = 0; | ||
let output = code[i] || ''; | ||
let { | ||
code, | ||
mapBuffer | ||
} = results[i]; | ||
let output = code || ''; | ||
wrapped += JSON.stringify(asset.id) + ':[function(require,module,exports) {\n' + output + '\n},'; | ||
@@ -134,4 +146,4 @@ wrapped += JSON.stringify(deps); | ||
if (maps[i]) { | ||
map.addBufferMappings(maps[i], lineOffset); | ||
if (mapBuffer) { | ||
map.addBufferMappings(mapBuffer, lineOffset); | ||
} else { | ||
@@ -159,3 +171,3 @@ map.addEmptyMap(_path.default.relative(options.projectRoot, asset.filePath).replace(/\\+/g, '/'), output, lineOffset); | ||
return replaceReferences({ | ||
contents: prefix + '({' + assets + '},{},' + JSON.stringify(entries.map(asset => asset.id)) + ', ' + 'null' + ')' + '\n\n' + '//# sourceMappingURL=' + (await getSourceMapReference(map)) + '\n', | ||
contents: prefix + '({' + assets + '},{},' + JSON.stringify(entries.map(asset => asset.id)) + ', ' + 'null' + ')' + '\n\n' + (await getSourceMapSuffix(getSourceMapReference, map)), | ||
map | ||
@@ -170,9 +182,8 @@ }); | ||
function getPrefix(bundle, bundleGraph) { | ||
let interpreter = null; | ||
let interpreter; | ||
if (isEntry(bundle, bundleGraph)) { | ||
let entries = bundle.getEntryAssets(); | ||
let entryAsset = entries[entries.length - 1]; // $FlowFixMe | ||
interpreter = bundle.target.env.isBrowser() ? null : entryAsset.meta.interpreter; | ||
if (isEntry(bundle, bundleGraph) && !bundle.target.env.isBrowser()) { | ||
let _interpreter = (0, _nullthrows.default)(bundle.getMainEntry()).meta.interpreter; | ||
(0, _assert.default)(_interpreter == null || typeof _interpreter === 'string'); | ||
interpreter = _interpreter; | ||
} | ||
@@ -197,2 +208,10 @@ | ||
return !bundleGraph.hasParentBundleOfType(bundle, 'js') || bundle.env.isIsolated(); | ||
} | ||
async function getSourceMapSuffix(getSourceMapReference, map) { | ||
if (map == null) { | ||
return ''; | ||
} | ||
return '//# sourceMappingURL=' + (await getSourceMapReference(map)) + '\n'; | ||
} |
{ | ||
"name": "@parcel/packager-js", | ||
"version": "2.0.0-nightly.173+bac3f05f", | ||
"version": "2.0.0-nightly.177+db7e3a12", | ||
"license": "MIT", | ||
@@ -19,8 +19,9 @@ "publishConfig": { | ||
"dependencies": { | ||
"@parcel/plugin": "2.0.0-nightly.173+bac3f05f", | ||
"@parcel/scope-hoisting": "2.0.0-nightly.173+bac3f05f", | ||
"@parcel/plugin": "2.0.0-nightly.177+db7e3a12", | ||
"@parcel/scope-hoisting": "2.0.0-nightly.177+db7e3a12", | ||
"@parcel/source-map": "^2.0.0-alpha.4.3", | ||
"@parcel/utils": "2.0.0-nightly.173+bac3f05f" | ||
"@parcel/utils": "2.0.0-nightly.177+db7e3a12", | ||
"nullthrows": "^1.1.1" | ||
}, | ||
"gitHead": "bac3f05fa31574338f14ab9cd2c9bd78fb1c22ee" | ||
"gitHead": "db7e3a12105630abc44058bff7a88eb612f12e75" | ||
} |
@@ -6,2 +6,3 @@ // @flow strict-local | ||
import invariant from 'assert'; | ||
import nullthrows from 'nullthrows'; | ||
import {Packager} from '@parcel/plugin'; | ||
@@ -50,5 +51,10 @@ import fs from 'fs'; | ||
ast = link({bundle, bundleGraph, ast, options}); | ||
let {contents, map} = generate(bundleGraph, bundle, ast, options); | ||
return replaceReferences({ | ||
contents: generate(bundleGraph, bundle, ast).contents, | ||
map: null, | ||
contents: | ||
contents + | ||
'\n' + | ||
(await getSourceMapSuffix(getSourceMapReference, map)), | ||
map, | ||
}); | ||
@@ -65,12 +71,16 @@ } | ||
// rather then enabling scope hoisting, which would be too slow. | ||
let codeQueue = new PromiseQueue({maxConcurrent: 32}); | ||
let mapQueue = new PromiseQueue({maxConcurrent: 32}); | ||
let queue = new PromiseQueue({maxConcurrent: 32}); | ||
bundle.traverse(node => { | ||
if (node.type === 'asset') { | ||
codeQueue.add(() => node.value.getCode()); | ||
mapQueue.add(() => node.value.getMapBuffer()); | ||
queue.add(async () => { | ||
let [code, mapBuffer] = await Promise.all([ | ||
node.value.getCode(), | ||
node.value.getMapBuffer(), | ||
]); | ||
return {code, mapBuffer}; | ||
}); | ||
} | ||
}); | ||
let [code, maps] = await Promise.all([codeQueue.run(), mapQueue.run()]); | ||
let results = await queue.run(); | ||
@@ -121,3 +131,4 @@ let assets = ''; | ||
let output = code[i] || ''; | ||
let {code, mapBuffer} = results[i]; | ||
let output = code || ''; | ||
wrapped += | ||
@@ -133,4 +144,4 @@ JSON.stringify(asset.id) + | ||
let lineCount = countLines(output); | ||
if (maps[i]) { | ||
map.addBufferMappings(maps[i], lineOffset); | ||
if (mapBuffer) { | ||
map.addBufferMappings(mapBuffer, lineOffset); | ||
} else { | ||
@@ -173,5 +184,3 @@ map.addEmptyMap( | ||
'\n\n' + | ||
'//# sourceMappingURL=' + | ||
(await getSourceMapReference(map)) + | ||
'\n', | ||
(await getSourceMapSuffix(getSourceMapReference, map)), | ||
map, | ||
@@ -183,10 +192,7 @@ }); | ||
function getPrefix(bundle: Bundle, bundleGraph: BundleGraph): string { | ||
let interpreter: ?string = null; | ||
if (isEntry(bundle, bundleGraph)) { | ||
let entries = bundle.getEntryAssets(); | ||
let entryAsset = entries[entries.length - 1]; | ||
// $FlowFixMe | ||
interpreter = bundle.target.env.isBrowser() | ||
? null | ||
: entryAsset.meta.interpreter; | ||
let interpreter: ?string; | ||
if (isEntry(bundle, bundleGraph) && !bundle.target.env.isBrowser()) { | ||
let _interpreter = nullthrows(bundle.getMainEntry()).meta.interpreter; | ||
invariant(_interpreter == null || typeof _interpreter === 'string'); | ||
interpreter = _interpreter; | ||
} | ||
@@ -213,1 +219,12 @@ | ||
} | ||
async function getSourceMapSuffix( | ||
getSourceMapReference: SourceMap => Promise<string> | string, | ||
map: ?SourceMap, | ||
): Promise<string> { | ||
if (map == null) { | ||
return ''; | ||
} | ||
return '//# sourceMappingURL=' + (await getSourceMapReference(map)) + '\n'; | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
21933
590
5
+ Addednullthrows@^1.1.1
+ Addednullthrows@1.1.1(transitive)