@parcel/core
Advanced tools
Comparing version 2.0.0-nightly.248 to 2.0.0-nightly.250
@@ -33,3 +33,3 @@ "use strict"; | ||
function createAsset(options) { | ||
var _options$committed; | ||
var _options$committed, _options$isIsolated, _options$isInline, _options$sideEffects; | ||
@@ -43,4 +43,4 @@ let idBase = options.idBase != null ? options.idBase : options.filePath; | ||
filePath: options.filePath, | ||
isIsolated: options.isIsolated == null ? false : options.isIsolated, | ||
isInline: options.isInline == null ? false : options.isInline, | ||
isIsolated: (_options$isIsolated = options.isIsolated) !== null && _options$isIsolated !== void 0 ? _options$isIsolated : false, | ||
isInline: (_options$isInline = options.isInline) !== null && _options$isInline !== void 0 ? _options$isInline : false, | ||
isSplittable: options.isSplittable, | ||
@@ -61,3 +61,3 @@ type: options.type, | ||
symbols: options.symbols || new Map(), | ||
sideEffects: options.sideEffects != null ? options.sideEffects : true, | ||
sideEffects: (_options$sideEffects = options.sideEffects) !== null && _options$sideEffects !== void 0 ? _options$sideEffects : true, | ||
uniqueKey: uniqueKey, | ||
@@ -64,0 +64,0 @@ plugin: options.plugin, |
@@ -561,10 +561,15 @@ "use strict"; | ||
resolveSymbol(asset, symbol, boundary) { | ||
var _asset$symbols$get, _asset$symbols$get4; | ||
let assetOutside = boundary && !this.bundleHasAsset(boundary, asset); | ||
let identifier = asset.symbols.get(symbol); | ||
let identifier = (_asset$symbols$get = asset.symbols.get(symbol)) === null || _asset$symbols$get === void 0 ? void 0 : _asset$symbols$get.local; | ||
if (symbol === '*') { | ||
var _asset$symbols$get2; | ||
return { | ||
asset, | ||
exportSymbol: '*', | ||
symbol: identifier | ||
symbol: identifier, | ||
loc: (_asset$symbols$get2 = asset.symbols.get(symbol)) === null || _asset$symbols$get2 === void 0 ? void 0 : _asset$symbols$get2.loc | ||
}; | ||
@@ -576,4 +581,6 @@ } | ||
for (let dep of deps) { | ||
var _dep$symbols$get; | ||
// If this is a re-export, find the original module. | ||
let symbolLookup = new Map([...dep.symbols].map(([key, val]) => [val, key])); | ||
let symbolLookup = new Map([...dep.symbols].map(([key, val]) => [val.local, key])); | ||
let depSymbol = symbolLookup.get(identifier); | ||
@@ -597,5 +604,14 @@ | ||
symbol: resolvedSymbol, | ||
exportSymbol | ||
} = this.resolveSymbol(resolved, depSymbol, boundary); // If it didn't resolve to anything (likely CommonJS), pass through where we got to | ||
exportSymbol, | ||
loc | ||
} = this.resolveSymbol(resolved, depSymbol, boundary); | ||
if (!loc) { | ||
var _asset$symbols$get3; | ||
// the recursive call didn't actually do anything | ||
loc = (_asset$symbols$get3 = asset.symbols.get(symbol)) === null || _asset$symbols$get3 === void 0 ? void 0 : _asset$symbols$get3.loc; | ||
} // If it didn't resolve to anything (likely CommonJS), pass through where we got to | ||
if (resolvedSymbol == null) { | ||
@@ -605,3 +621,4 @@ return { | ||
symbol: resolvedSymbol, | ||
exportSymbol | ||
exportSymbol, | ||
loc | ||
}; | ||
@@ -614,3 +631,4 @@ } // Otherwise, keep the original symbol name along with the resolved symbol | ||
symbol: resolvedSymbol, | ||
exportSymbol: symbol | ||
exportSymbol: symbol, | ||
loc | ||
}; | ||
@@ -621,3 +639,3 @@ } // If this module exports wildcards, resolve the original module. | ||
if (dep.symbols.get('*') === '*' && symbol !== 'default') { | ||
if (((_dep$symbols$get = dep.symbols.get('*')) === null || _dep$symbols$get === void 0 ? void 0 : _dep$symbols$get.local) === '*' && symbol !== 'default') { | ||
let resolved = this.getDependencyResolution(dep); | ||
@@ -628,2 +646,4 @@ if (!resolved) continue; | ||
if (result.symbol != undefined) { | ||
var _resolved$symbols$get; | ||
if (assetOutside) { | ||
@@ -637,3 +657,4 @@ // We found the symbol, but `asset` is outside, return `asset` and the original symbol | ||
symbol: result.symbol, | ||
exportSymbol: symbol | ||
exportSymbol: symbol, | ||
loc: (_resolved$symbols$get = resolved.symbols.get(symbol)) === null || _resolved$symbols$get === void 0 ? void 0 : _resolved$symbols$get.loc | ||
}; | ||
@@ -647,3 +668,4 @@ } | ||
exportSymbol: symbol, | ||
symbol: identifier | ||
symbol: identifier, | ||
loc: (_asset$symbols$get4 = asset.symbols.get(symbol)) === null || _asset$symbols$get4 === void 0 ? void 0 : _asset$symbols$get4.loc | ||
}; | ||
@@ -662,3 +684,5 @@ } | ||
for (let dep of deps) { | ||
if (dep.symbols.get('*') === '*') { | ||
var _dep$symbols$get2; | ||
if (((_dep$symbols$get2 = dep.symbols.get('*')) === null || _dep$symbols$get2 === void 0 ? void 0 : _dep$symbols$get2.local) === '*') { | ||
let resolved = this.getDependencyResolution(dep); | ||
@@ -665,0 +689,0 @@ if (!resolved) continue; |
@@ -17,2 +17,4 @@ "use strict"; | ||
var _Symbols = require("./Symbols"); | ||
var _UncommittedAsset = _interopRequireDefault(require("../UncommittedAsset")); | ||
@@ -116,3 +118,3 @@ | ||
get symbols() { | ||
return _classPrivateFieldGet(this, _asset).value.symbols; | ||
return new _Symbols.Symbols(_classPrivateFieldGet(this, _asset).value.symbols); | ||
} | ||
@@ -262,2 +264,6 @@ | ||
get symbols() { | ||
return new _Symbols.MutableSymbols(_classPrivateFieldGet(this, _asset3).value.symbols); | ||
} | ||
addDependency(dep) { | ||
@@ -264,0 +270,0 @@ return _classPrivateFieldGet(this, _asset3).addDependency(dep); |
@@ -160,3 +160,4 @@ "use strict"; | ||
exportSymbol: res.exportSymbol, | ||
symbol: res.symbol | ||
symbol: res.symbol, | ||
loc: res.loc | ||
}; | ||
@@ -171,3 +172,4 @@ } | ||
exportSymbol: e.exportSymbol, | ||
symbol: e.symbol | ||
symbol: e.symbol, | ||
loc: e.loc | ||
})); | ||
@@ -174,0 +176,0 @@ } |
@@ -13,2 +13,4 @@ "use strict"; | ||
var _Symbols = require("./Symbols"); | ||
var _nullthrows = _interopRequireDefault(require("nullthrows")); | ||
@@ -101,2 +103,6 @@ | ||
get symbols() { | ||
return new _Symbols.MutableSymbols(_classPrivateFieldGet(this, _dep).symbols); | ||
} | ||
get target() { | ||
@@ -118,6 +124,2 @@ let target = _classPrivateFieldGet(this, _dep).target; | ||
get symbols() { | ||
return _classPrivateFieldGet(this, _dep).symbols; | ||
} | ||
get pipeline() { | ||
@@ -124,0 +126,0 @@ return _classPrivateFieldGet(this, _dep).pipeline; |
@@ -20,4 +20,2 @@ "use strict"; | ||
const invertMap = map => new Map([...map].map(([key, val]) => [val, key])); | ||
class DepPathRequestRunner extends _RequestTracker.RequestRunner { | ||
@@ -115,3 +113,3 @@ constructor(opts) { | ||
let assets = this.assetGraph.getNodesConnectedTo(depNode); | ||
let symbols = invertMap(dependency.symbols); | ||
let symbols = new Map([...dependency.symbols].map(([key, val]) => [val.local, key])); | ||
(0, _assert.default)(assets.length === 1); | ||
@@ -123,3 +121,5 @@ let firstAsset = assets[0]; | ||
defer = deps.every(d => !(d.env.isLibrary && d.isEntry) && !d.symbols.has('*') && ![...d.symbols.keys()].some(symbol => { | ||
let assetSymbol = resolvedAsset.symbols.get(symbol); | ||
var _resolvedAsset$symbol; | ||
let assetSymbol = (_resolvedAsset$symbol = resolvedAsset.symbols.get(symbol)) === null || _resolvedAsset$symbol === void 0 ? void 0 : _resolvedAsset$symbol.local; | ||
return assetSymbol != null && symbols.has(assetSymbol); | ||
@@ -126,0 +126,0 @@ })); |
@@ -168,2 +168,3 @@ "use strict"; | ||
publicUrl: (_this$options$publicU = this.options.publicUrl) !== null && _this$options$publicU !== void 0 ? _this$options$publicU : '/', | ||
sourceMap: this.options.sourceMaps ? {} : undefined, | ||
env: (0, _Environment.createEnvironment)({ | ||
@@ -170,0 +171,0 @@ context: 'browser', |
@@ -213,5 +213,8 @@ "use strict"; | ||
target, | ||
symbols, | ||
...rest | ||
} = opts; | ||
let dep = (0, _Dependency.createDependency)({ ...rest, | ||
// $FlowFixMe "convert" the $ReadOnlyMaps to the interal mutable one | ||
symbols, | ||
env: (0, _Environment.mergeEnvironments)(this.value.env, env), | ||
@@ -218,0 +221,0 @@ sourceAssetId: this.value.id, |
{ | ||
"name": "@parcel/core", | ||
"version": "2.0.0-nightly.248+d3e9d809", | ||
"version": "2.0.0-nightly.250+3c1c7db9", | ||
"license": "MIT", | ||
@@ -19,13 +19,13 @@ "publishConfig": { | ||
"dependencies": { | ||
"@parcel/cache": "2.0.0-nightly.250+d3e9d809", | ||
"@parcel/diagnostic": "2.0.0-nightly.250+d3e9d809", | ||
"@parcel/events": "2.0.0-nightly.250+d3e9d809", | ||
"@parcel/fs": "2.0.0-nightly.250+d3e9d809", | ||
"@parcel/logger": "2.0.0-nightly.250+d3e9d809", | ||
"@parcel/package-manager": "2.0.0-nightly.250+d3e9d809", | ||
"@parcel/plugin": "2.0.0-nightly.250+d3e9d809", | ||
"@parcel/cache": "2.0.0-nightly.252+3c1c7db9", | ||
"@parcel/diagnostic": "2.0.0-nightly.252+3c1c7db9", | ||
"@parcel/events": "2.0.0-nightly.252+3c1c7db9", | ||
"@parcel/fs": "2.0.0-nightly.252+3c1c7db9", | ||
"@parcel/logger": "2.0.0-nightly.252+3c1c7db9", | ||
"@parcel/package-manager": "2.0.0-nightly.252+3c1c7db9", | ||
"@parcel/plugin": "2.0.0-nightly.252+3c1c7db9", | ||
"@parcel/source-map": "2.0.0-alpha.4.9", | ||
"@parcel/types": "2.0.0-nightly.250+d3e9d809", | ||
"@parcel/utils": "2.0.0-nightly.250+d3e9d809", | ||
"@parcel/workers": "2.0.0-nightly.250+d3e9d809", | ||
"@parcel/types": "2.0.0-nightly.252+3c1c7db9", | ||
"@parcel/utils": "2.0.0-nightly.252+3c1c7db9", | ||
"@parcel/workers": "2.0.0-nightly.252+3c1c7db9", | ||
"abortcontroller-polyfill": "^1.1.9", | ||
@@ -46,3 +46,3 @@ "browserslist": "^4.6.6", | ||
}, | ||
"gitHead": "d3e9d8093c0d5848d1a01469ffa9f0ff77b604e4" | ||
"gitHead": "3c1c7db9559771af7df9f39ead4513b56afd3c9b" | ||
} |
@@ -13,2 +13,3 @@ // @flow strict-local | ||
Symbol, | ||
SourceLocation, | ||
Transformer, | ||
@@ -51,3 +52,3 @@ } from '@parcel/types'; | ||
stats: Stats, | ||
symbols?: Map<Symbol, Symbol>, | ||
symbols?: Map<Symbol, {|local: Symbol, loc: ?SourceLocation|}>, | ||
sideEffects?: boolean, | ||
@@ -72,4 +73,4 @@ uniqueKey?: ?string, | ||
filePath: options.filePath, | ||
isIsolated: options.isIsolated == null ? false : options.isIsolated, | ||
isInline: options.isInline == null ? false : options.isInline, | ||
isIsolated: options.isIsolated ?? false, | ||
isInline: options.isInline ?? false, | ||
isSplittable: options.isSplittable, | ||
@@ -90,3 +91,3 @@ type: options.type, | ||
symbols: options.symbols || new Map(), | ||
sideEffects: options.sideEffects != null ? options.sideEffects : true, | ||
sideEffects: options.sideEffects ?? true, | ||
uniqueKey: uniqueKey, | ||
@@ -93,0 +94,0 @@ plugin: options.plugin, |
@@ -742,5 +742,10 @@ // @flow strict-local | ||
let identifier = asset.symbols.get(symbol); | ||
let identifier = asset.symbols.get(symbol)?.local; | ||
if (symbol === '*') { | ||
return {asset, exportSymbol: '*', symbol: identifier}; | ||
return { | ||
asset, | ||
exportSymbol: '*', | ||
symbol: identifier, | ||
loc: asset.symbols.get(symbol)?.loc, | ||
}; | ||
} | ||
@@ -752,3 +757,3 @@ | ||
let symbolLookup = new Map( | ||
[...dep.symbols].map(([key, val]) => [val, key]), | ||
[...dep.symbols].map(([key, val]) => [val.local, key]), | ||
); | ||
@@ -772,7 +777,18 @@ let depSymbol = symbolLookup.get(identifier); | ||
exportSymbol, | ||
loc, | ||
} = this.resolveSymbol(resolved, depSymbol, boundary); | ||
if (!loc) { | ||
// the recursive call didn't actually do anything | ||
loc = asset.symbols.get(symbol)?.loc; | ||
} | ||
// If it didn't resolve to anything (likely CommonJS), pass through where we got to | ||
if (resolvedSymbol == null) { | ||
return {asset: resolvedAsset, symbol: resolvedSymbol, exportSymbol}; | ||
return { | ||
asset: resolvedAsset, | ||
symbol: resolvedSymbol, | ||
exportSymbol, | ||
loc, | ||
}; | ||
} | ||
@@ -785,2 +801,3 @@ | ||
exportSymbol: symbol, | ||
loc, | ||
}; | ||
@@ -791,3 +808,3 @@ } | ||
// Default exports are excluded from wildcard exports. | ||
if (dep.symbols.get('*') === '*' && symbol !== 'default') { | ||
if (dep.symbols.get('*')?.local === '*' && symbol !== 'default') { | ||
let resolved = this.getDependencyResolution(dep); | ||
@@ -806,2 +823,3 @@ if (!resolved) continue; | ||
exportSymbol: symbol, | ||
loc: resolved.symbols.get(symbol)?.loc, | ||
}; | ||
@@ -812,3 +830,8 @@ } | ||
return {asset, exportSymbol: symbol, symbol: identifier}; | ||
return { | ||
asset, | ||
exportSymbol: symbol, | ||
symbol: identifier, | ||
loc: asset.symbols.get(symbol)?.loc, | ||
}; | ||
} | ||
@@ -825,3 +848,3 @@ | ||
for (let dep of deps) { | ||
if (dep.symbols.get('*') === '*') { | ||
if (dep.symbols.get('*')?.local === '*') { | ||
let resolved = this.getDependencyResolution(dep); | ||
@@ -828,0 +851,0 @@ if (!resolved) continue; |
@@ -26,3 +26,3 @@ // @flow | ||
target?: Target, | ||
symbols?: Map<Symbol, Symbol>, | ||
symbols?: Map<Symbol, {|local: Symbol, loc: ?SourceLocation|}>, | ||
pipeline?: ?string, | ||
@@ -29,0 +29,0 @@ |}; |
@@ -23,3 +23,4 @@ // @flow strict-local | ||
Stats, | ||
Symbol as ISymbol, | ||
MutableSymbols as IMutableSymbols, | ||
Symbols as ISymbols, | ||
} from '@parcel/types'; | ||
@@ -31,2 +32,3 @@ import type {Asset as AssetValue, ParcelOptions} from '../types'; | ||
import Dependency from './Dependency'; | ||
import {Symbols, MutableSymbols} from './Symbols'; | ||
import UncommittedAsset from '../UncommittedAsset'; | ||
@@ -132,4 +134,4 @@ import CommittedAsset from '../CommittedAsset'; | ||
get symbols(): Map<ISymbol, ISymbol> { | ||
return this.#asset.value.symbols; | ||
get symbols(): ISymbols { | ||
return new Symbols(this.#asset.value.symbols); | ||
} | ||
@@ -262,2 +264,6 @@ | ||
get symbols(): IMutableSymbols { | ||
return new MutableSymbols(this.#asset.value.symbols); | ||
} | ||
addDependency(dep: DependencyOptions): string { | ||
@@ -264,0 +270,0 @@ return this.#asset.addDependency(dep); |
@@ -202,2 +202,3 @@ // @flow strict-local | ||
symbol: res.symbol, | ||
loc: res.loc, | ||
}; | ||
@@ -212,2 +213,3 @@ } | ||
symbol: e.symbol, | ||
loc: e.loc, | ||
})); | ||
@@ -214,0 +216,0 @@ } |
@@ -7,7 +7,9 @@ // @flow | ||
Meta, | ||
Symbol as ISymbol, | ||
MutableSymbols as IMutableSymbols, | ||
} from '@parcel/types'; | ||
import type {Dependency as InternalDependency} from '../types'; | ||
import Environment from './Environment'; | ||
import Target from './Target'; | ||
import {MutableSymbols} from './Symbols'; | ||
import nullthrows from 'nullthrows'; | ||
@@ -94,2 +96,6 @@ | ||
get symbols(): IMutableSymbols { | ||
return new MutableSymbols(this.#dep.symbols); | ||
} | ||
get target(): ?Target { | ||
@@ -110,6 +116,2 @@ let target = this.#dep.target; | ||
get symbols(): Map<ISymbol, ISymbol> { | ||
return this.#dep.symbols; | ||
} | ||
get pipeline(): ?string { | ||
@@ -116,0 +118,0 @@ return this.#dep.pipeline; |
@@ -21,5 +21,2 @@ // @flow strict-local | ||
const invertMap = <K, V>(map: Map<K, V>): Map<V, K> => | ||
new Map([...map].map(([key, val]) => [val, key])); | ||
export default class DepPathRequestRunner extends RequestRunner< | ||
@@ -129,3 +126,5 @@ Dependency, | ||
let assets = this.assetGraph.getNodesConnectedTo(depNode); | ||
let symbols = invertMap(dependency.symbols); | ||
let symbols = new Map( | ||
[...dependency.symbols].map(([key, val]) => [val.local, key]), | ||
); | ||
invariant(assets.length === 1); | ||
@@ -141,3 +140,3 @@ let firstAsset = assets[0]; | ||
![...d.symbols.keys()].some(symbol => { | ||
let assetSymbol = resolvedAsset.symbols.get(symbol); | ||
let assetSymbol = resolvedAsset.symbols.get(symbol)?.local; | ||
return assetSymbol != null && symbols.has(assetSymbol); | ||
@@ -144,0 +143,0 @@ }), |
@@ -178,2 +178,3 @@ // @flow | ||
publicUrl: this.options.publicUrl ?? '/', | ||
sourceMap: this.options.sourceMaps ? {} : undefined, | ||
env: createEnvironment({ | ||
@@ -180,0 +181,0 @@ context: 'browser', |
@@ -98,3 +98,3 @@ // @flow strict-local | ||
sourcePath: ?string, | ||
symbols: Map<Symbol, Symbol>, | ||
symbols: Map<Symbol, {|local: Symbol, loc: ?SourceLocation|}>, | ||
pipeline?: ?string, | ||
@@ -124,3 +124,3 @@ |}; | ||
astGenerator: ?ASTGenerator, | ||
symbols: Map<Symbol, Symbol>, | ||
symbols: Map<Symbol, {|local: Symbol, loc: ?SourceLocation|}>, | ||
sideEffects: boolean, | ||
@@ -127,0 +127,0 @@ uniqueKey: ?string, |
@@ -234,5 +234,7 @@ // @flow strict-local | ||
// eslint-disable-next-line no-unused-vars | ||
let {env, target, ...rest} = opts; | ||
let {env, target, symbols, ...rest} = opts; | ||
let dep = createDependency({ | ||
...rest, | ||
// $FlowFixMe "convert" the $ReadOnlyMaps to the interal mutable one | ||
symbols, | ||
env: mergeEnvironments(this.value.env, env), | ||
@@ -239,0 +241,0 @@ sourceAssetId: this.value.id, |
@@ -550,2 +550,40 @@ // @flow | ||
it('generates a default target in serve mode', async () => { | ||
let targetResolver = new TargetResolver({ | ||
...DEFAULT_OPTIONS, | ||
serve: {port: 1234}, | ||
}); | ||
assert.deepEqual( | ||
await targetResolver.resolve(COMMON_TARGETS_FIXTURE_PATH), | ||
{ | ||
targets: [ | ||
{ | ||
name: 'default', | ||
distDir: DEFAULT_OPTIONS.distDir, | ||
publicUrl: '/', | ||
env: { | ||
context: 'browser', | ||
engines: { | ||
browsers: [ | ||
'last 1 Chrome version', | ||
'last 1 Safari version', | ||
'last 1 Firefox version', | ||
'last 1 Edge version', | ||
], | ||
}, | ||
includeNodeModules: true, | ||
outputFormat: 'global', | ||
isLibrary: false, | ||
minify: false, | ||
scopeHoist: false, | ||
}, | ||
sourceMap: {}, | ||
}, | ||
], | ||
files: [], | ||
}, | ||
); | ||
}); | ||
it('rejects invalid or unknown fields', async () => { | ||
@@ -552,0 +590,0 @@ let code = |
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
719229
139
21023