diff --git a/flow-libs/posthtml.js.flow b/flow-libs/posthtml.js.flow
index 32ed17c10bf..1b2131653e9 100644
--- a/flow-libs/posthtml.js.flow
+++ b/flow-libs/posthtml.js.flow
@@ -11,6 +11,11 @@ declare module 'posthtml' {
tag: string,
attrs?: {[string]: string, ...},
content?: Array,
+ loc?: {
+ start: {|line: number, column: number|},
+ end: {|line: number, column: number|},
+ ...
+ },
...
};
@@ -26,7 +31,7 @@ declare module 'posthtml' {
...
};
- declare var walk: (fn: (node: PostHTMLNode) => PostHTMLNode) => void;
+ declare var walk: (fn: (node: PostHTMLNode) => PostHTMLNode | PostHTMLNode[]) => void;
declare var process: (
tree: PostHTMLTree | string,
options: ?PostHTMLOptions,
diff --git a/packages/configs/default/index.json b/packages/configs/default/index.json
index 4524fa2ba25..2daad6a34e5 100644
--- a/packages/configs/default/index.json
+++ b/packages/configs/default/index.json
@@ -37,18 +37,11 @@
"url:*": ["@parcel/transformer-raw"]
},
"namers": ["@parcel/namer-default"],
- "runtimes": {
- "browser": [
- "@parcel/runtime-js",
- "@parcel/runtime-browser-hmr",
- "@parcel/runtime-react-refresh"
- ],
- "service-worker": ["@parcel/runtime-js"],
- "web-worker": ["@parcel/runtime-js"],
- "node": ["@parcel/runtime-js"],
- "electron-renderer": ["@parcel/runtime-js"],
- "electron-main": ["@parcel/runtime-js"]
- },
+ "runtimes": [
+ "@parcel/runtime-js",
+ "@parcel/runtime-browser-hmr",
+ "@parcel/runtime-react-refresh"
+ ],
"optimizers": {
"data-url:*": ["...", "@parcel/optimizer-data-url"],
"*.css": ["@parcel/optimizer-cssnano"],
diff --git a/packages/core/core/src/AssetGraph.js b/packages/core/core/src/AssetGraph.js
index 941f94f7376..a107e7d0e0b 100644
--- a/packages/core/core/src/AssetGraph.js
+++ b/packages/core/core/src/AssetGraph.js
@@ -21,6 +21,7 @@ import {md5FromObject} from '@parcel/utils';
import nullthrows from 'nullthrows';
import Graph, {type GraphOpts} from './Graph';
import {createDependency} from './Dependency';
+import {getAssetGroupId} from './assetUtils';
type AssetGraphOpts = {|
...GraphOpts,
@@ -55,13 +56,7 @@ export function nodeFromDep(dep: Dependency): DependencyNode {
export function nodeFromAssetGroup(assetGroup: AssetGroup): AssetGroupNode {
return {
- id: md5FromObject({
- ...assetGroup,
- // only influences building the asset graph
- canDefer: undefined,
- // if only the isURL property is different, no need to re-run transformation.
- isURL: undefined,
- }),
+ id: getAssetGroupId(assetGroup),
type: 'asset_group',
value: assetGroup,
usedSymbolsDownDirty: true,
diff --git a/packages/core/core/src/BundleGraph.js b/packages/core/core/src/BundleGraph.js
index 65f93e3a3af..e29827d58da 100644
--- a/packages/core/core/src/BundleGraph.js
+++ b/packages/core/core/src/BundleGraph.js
@@ -23,7 +23,12 @@ import assert from 'assert';
import invariant from 'assert';
import crypto from 'crypto';
import nullthrows from 'nullthrows';
-import {flatMap, objectSortedEntriesDeep, unique} from '@parcel/utils';
+import {
+ flatMap,
+ objectSortedEntriesDeep,
+ unique,
+ isSubset,
+} from '@parcel/utils';
import {getBundleGroupId, getPublicId} from './utils';
import Graph, {ALL_EDGE_TYPES, mapVisitor, type GraphOpts} from './Graph';
@@ -615,7 +620,7 @@ export default class BundleGraph {
visitedBundles.add(descendant);
if (
descendant.type !== bundle.type ||
- descendant.env.context !== bundle.env.context
+ !isSubset(descendant.env.context, bundle.env.context)
) {
actions.skipChildren();
return;
@@ -630,7 +635,7 @@ export default class BundleGraph {
let similarSiblings = this.getSiblingBundles(descendant).filter(
sibling =>
sibling.type === bundle.type &&
- sibling.env.context === bundle.env.context,
+ isSubset(sibling.env.context, bundle.env.context),
);
if (
similarSiblings.some(
@@ -713,7 +718,7 @@ export default class BundleGraph {
// Don't deduplicate when context changes
if (
node.type === 'bundle' &&
- node.value.env.context !== bundle.env.context
+ !isSubset(node.value.env.context, bundle.env.context)
) {
actions.skipChildren();
}
@@ -766,7 +771,7 @@ export default class BundleGraph {
// Stop when context changes
if (
node.type === 'bundle' &&
- node.value.env.context !== bundle.env.context
+ !isSubset(node.value.env.context, bundle.env.context)
) {
actions.skipChildren();
}
diff --git a/packages/core/core/src/Environment.js b/packages/core/core/src/Environment.js
index 78a8316a579..30bef706695 100644
--- a/packages/core/core/src/Environment.js
+++ b/packages/core/core/src/Environment.js
@@ -17,6 +17,7 @@ export function createEnvironment({
isLibrary = false,
scopeHoist = false,
sourceMap,
+ loc,
}: EnvironmentOpts = {}): Environment {
if (context == null) {
if (engines?.node) {
@@ -28,58 +29,63 @@ export function createEnvironment({
}
}
+ let ctx = new Set(typeof context === 'string' ? [context] : context);
+
if (engines == null) {
- switch (context) {
- case 'node':
- case 'electron-main':
- engines = {
- node: DEFAULT_ENGINES.node,
- };
- break;
- case 'browser':
- case 'web-worker':
- case 'service-worker':
- case 'electron-renderer':
- engines = {
- browsers: DEFAULT_ENGINES.browsers,
- };
- break;
- default:
- engines = {};
+ engines = {};
+ for (let context of ctx) {
+ switch (context) {
+ case 'node':
+ case 'electron-main':
+ engines.node = DEFAULT_ENGINES.node;
+ break;
+ case 'browser':
+ case 'web-worker':
+ case 'service-worker':
+ case 'electron-renderer':
+ engines.browsers = DEFAULT_ENGINES.browsers;
+ break;
+ }
}
}
if (includeNodeModules == null) {
- switch (context) {
- case 'node':
- case 'electron-main':
- case 'electron-renderer':
- includeNodeModules = false;
- break;
- case 'browser':
- case 'web-worker':
- case 'service-worker':
- default:
- includeNodeModules = true;
- break;
+ includeNodeModules = true;
+ for (let context of ctx) {
+ switch (context) {
+ case 'node':
+ case 'electron-main':
+ case 'electron-renderer':
+ includeNodeModules = false;
+ break;
+ case 'browser':
+ case 'web-worker':
+ case 'service-worker':
+ default:
+ includeNodeModules = true;
+ break;
+ }
}
}
if (outputFormat == null) {
- switch (context) {
- case 'node':
- case 'electron-main':
- case 'electron-renderer':
- outputFormat = 'commonjs';
- break;
- default:
- outputFormat = 'global';
- break;
+ outputFormat = 'global';
+ for (let context of ctx) {
+ switch (context) {
+ case 'node':
+ case 'electron-main':
+ case 'electron-renderer':
+ outputFormat = 'commonjs';
+ break;
+ default:
+ outputFormat = 'global';
+ break;
+ }
}
}
return {
- context,
+ context: ctx,
engines,
includeNodeModules,
outputFormat,
@@ -87,6 +93,7 @@ export function createEnvironment({
minify,
scopeHoist,
sourceMap,
+ loc,
};
}
diff --git a/packages/core/core/src/PackagerRunner.js b/packages/core/core/src/PackagerRunner.js
index eae47bf4b9e..d02d53a03bf 100644
--- a/packages/core/core/src/PackagerRunner.js
+++ b/packages/core/core/src/PackagerRunner.js
@@ -421,7 +421,7 @@ export default class PackagerRunner {
sourceRoot = bundle.env.sourceMap.sourceRoot;
} else if (
this.options.serve &&
- bundle.target.env.context === 'browser'
+ bundle.target.env.context.has('browser')
) {
sourceRoot = '/__parcel_source_root';
}
@@ -431,7 +431,7 @@ export default class PackagerRunner {
bundle.env.sourceMap.inlineSources !== undefined
) {
inlineSources = bundle.env.sourceMap.inlineSources;
- } else if (bundle.target.env.context !== 'node') {
+ } else if (!bundle.target.env.context.has('node')) {
// inlining should only happen in production for browser targets by default
inlineSources = this.options.mode === 'production';
}
diff --git a/packages/core/core/src/ParcelConfig.js b/packages/core/core/src/ParcelConfig.js
index 400785cc5bc..ddb6524368d 100644
--- a/packages/core/core/src/ParcelConfig.js
+++ b/packages/core/core/src/ParcelConfig.js
@@ -7,7 +7,6 @@ import type {
Bundler,
Namer,
Runtime,
- EnvironmentContext,
PackageName,
Optimizer,
Packager,
@@ -52,7 +51,7 @@ export default class ParcelConfig {
transformers: GlobMap;
bundler: ?ParcelPluginNode;
namers: PureParcelConfigPipeline;
- runtimes: {[EnvironmentContext]: PureParcelConfigPipeline, ...};
+ runtimes: PureParcelConfigPipeline;
packagers: GlobMap;
validators: GlobMap;
optimizers: GlobMap;
@@ -71,7 +70,7 @@ export default class ParcelConfig {
this.filePath = config.filePath;
this.resolvers = config.resolvers || [];
this.transformers = config.transformers || {};
- this.runtimes = config.runtimes || {};
+ this.runtimes = config.runtimes || [];
this.bundler = config.bundler;
this.namers = config.namers || [];
this.packagers = config.packagers || {};
@@ -266,10 +265,8 @@ export default class ParcelConfig {
return this.loadPlugins(this.namers);
}
- getRuntimes(
- context: EnvironmentContext,
- ): Promise>> {
- let runtimes = this.runtimes[context];
+ getRuntimes(): Promise>> {
+ let runtimes = this.runtimes;
if (!runtimes) {
return Promise.resolve([]);
}
diff --git a/packages/core/core/src/ParcelConfig.schema.js b/packages/core/core/src/ParcelConfig.schema.js
index e0076de6a27..a54152577a2 100644
--- a/packages/core/core/src/ParcelConfig.schema.js
+++ b/packages/core/core/src/ParcelConfig.schema.js
@@ -122,7 +122,7 @@ export default {
packagers: (mapStringSchema('packager', 'packagers'): SchemaEntity),
optimizers: (mapPipelineSchema('optimizer', 'optimizers'): SchemaEntity),
reporters: (pipelineSchema('reporter', 'reporters'): SchemaEntity),
- runtimes: (mapPipelineSchema('runtime', 'runtimes'): SchemaEntity),
+ runtimes: (pipelineSchema('runtime', 'runtimes'): SchemaEntity),
filePath: {
type: 'string',
},
diff --git a/packages/core/core/src/Transformation.js b/packages/core/core/src/Transformation.js
index fdf493d9e93..b72b8061e70 100644
--- a/packages/core/core/src/Transformation.js
+++ b/packages/core/core/src/Transformation.js
@@ -402,7 +402,17 @@ export default class Transformation {
.filter(
asset =>
asset.ast != null &&
- !(asset.value.type === 'js' && asset.value.env.scopeHoist),
+ !(
+ asset.value.type === 'js' &&
+ asset.value.env.scopeHoist &&
+ // HACK: also handle global scripts with no dependencies.
+ // JSPackager calls getCode() for these even with scope hoisting, so we
+ // need to generate here until we find a way to make generate happen on demand.
+ !(
+ asset.value.env.context.has('script') &&
+ asset.value.dependencies.size === 0
+ )
+ ),
)
.map(async asset => {
if (asset.isASTDirty) {
diff --git a/packages/core/core/src/applyRuntimes.js b/packages/core/core/src/applyRuntimes.js
index 593e739d771..10e25b8e3c8 100644
--- a/packages/core/core/src/applyRuntimes.js
+++ b/packages/core/core/src/applyRuntimes.js
@@ -22,6 +22,7 @@ import {setDifference} from '@parcel/utils';
import {PluginLogger} from '@parcel/logger';
import ThrowableDiagnostic, {errorToDiagnostic} from '@parcel/diagnostic';
import {dependencyToInternalDependency} from './public/Dependency';
+import {mergeEnvironments} from './Environment';
type RuntimeConnection = {|
bundle: InternalBundle,
@@ -46,7 +47,7 @@ export default async function applyRuntimes({
let connections: Array = [];
for (let bundle of bundleGraph.getBundles()) {
- let runtimes = await config.getRuntimes(bundle.env.context);
+ let runtimes = await config.getRuntimes();
for (let runtime of runtimes) {
try {
let applied = await runtime.plugin.apply({
@@ -62,11 +63,17 @@ export default async function applyRuntimes({
if (applied) {
let runtimeAssets = Array.isArray(applied) ? applied : [applied];
- for (let {code, dependency, filePath, isEntry} of runtimeAssets) {
+ for (let {
+ code,
+ dependency,
+ filePath,
+ isEntry,
+ env,
+ } of runtimeAssets) {
let assetGroup = {
code,
filePath,
- env: bundle.env,
+ env: mergeEnvironments(bundle.env, env),
// Runtime assets should be considered source, as they should be
// e.g. compiled to run in the target environment
isSource: true,
diff --git a/packages/core/core/src/assetUtils.js b/packages/core/core/src/assetUtils.js
index fd6e45ed935..f332eb019ff 100644
--- a/packages/core/core/src/assetUtils.js
+++ b/packages/core/core/src/assetUtils.js
@@ -14,6 +14,7 @@ import type {
} from '@parcel/types';
import type {
Asset,
+ AssetGroup,
RequestInvalidation,
Dependency,
Environment,
@@ -24,6 +25,7 @@ import type {ConfigOutput} from '@parcel/utils';
import {Readable} from 'stream';
import crypto from 'crypto';
import {PluginLogger} from '@parcel/logger';
+import {md5FromObject} from '@parcel/utils';
import nullthrows from 'nullthrows';
import CommittedAsset from './CommittedAsset';
import UncommittedAsset from './UncommittedAsset';
@@ -251,3 +253,14 @@ export async function getInvalidationHash(
return hash.digest('hex');
}
+
+export function getAssetGroupId(assetGroup: AssetGroup): string {
+ return md5FromObject({
+ ...assetGroup,
+ env: getEnvironmentHash(assetGroup.env),
+ // only influences building the asset graph
+ canDefer: undefined,
+ // if only the isURL property is different, no need to re-run transformation.
+ isURL: undefined,
+ });
+}
diff --git a/packages/core/core/src/dumpGraphToGraphViz.js b/packages/core/core/src/dumpGraphToGraphViz.js
index f98f0dbf979..6f7799835cb 100644
--- a/packages/core/core/src/dumpGraphToGraphViz.js
+++ b/packages/core/core/src/dumpGraphToGraphViz.js
@@ -138,10 +138,11 @@ export default async function dumpGraphToGraphViz(
function getEnvDescription(env: Environment) {
let description;
+ let context = [...env.context].join(', ');
if (typeof env.engines.browsers === 'string') {
- description = `${env.context}: ${env.engines.browsers}`;
+ description = `${context}: ${env.engines.browsers}`;
} else if (Array.isArray(env.engines.browsers)) {
- description = `${env.context}: ${env.engines.browsers.join(', ')}`;
+ description = `${context}: ${env.engines.browsers.join(', ')}`;
} else if (env.engines.node) {
description = `node: ${env.engines.node}`;
} else if (env.engines.electron) {
diff --git a/packages/core/core/src/public/Environment.js b/packages/core/core/src/public/Environment.js
index 9f1283b93e2..d1bcd892471 100644
--- a/packages/core/core/src/public/Environment.js
+++ b/packages/core/core/src/public/Environment.js
@@ -2,26 +2,35 @@
import type {
Environment as IEnvironment,
EnvironmentContext,
+ EnvironmentFeature,
Engines,
OutputFormat,
PackageName,
VersionMap,
TargetSourceMapOptions,
+ SourceLocation,
} from '@parcel/types';
import type {Environment as InternalEnvironment} from '../types';
import nullthrows from 'nullthrows';
import browserslist from 'browserslist';
import semver from 'semver';
+import {setIntersects} from '@parcel/utils';
-export const BROWSER_ENVS: Set = new Set([
+export const BROWSER_ENVS: Set = new Set([
'browser',
'web-worker',
'service-worker',
'electron-renderer',
]);
-const ELECTRON_ENVS = new Set(['electron-main', 'electron-renderer']);
-const NODE_ENVS = new Set(['node', ...ELECTRON_ENVS]);
-const WORKER_ENVS = new Set(['web-worker', 'service-worker']);
+const ELECTRON_ENVS = new Set([
+ 'electron-main',
+ 'electron-renderer',
+]);
+const NODE_ENVS = new Set(['node', ...ELECTRON_ENVS]);
+const WORKER_ENVS = new Set([
+ 'web-worker',
+ 'service-worker',
+]);
const ISOLATED_ENVS = WORKER_ENVS;
const ALL_BROWSERS = [
@@ -45,17 +54,39 @@ const ALL_BROWSERS = [
'kaios',
];
-const ESMODULE_BROWSERS = {
- edge: '16',
- firefox: '60',
- chrome: '61',
- safari: '11',
- opera: '48',
- ios: '11',
- android: '76',
- and_chr: '76',
- and_ff: '68',
- samsung: '8.2',
+const supportData = {
+ esmodules: {
+ edge: '16',
+ firefox: '60',
+ chrome: '61',
+ safari: '11',
+ opera: '48',
+ ios: '11',
+ android: '76',
+ and_chr: '76',
+ and_ff: '68',
+ samsung: '8.2',
+ },
+ 'dynamic-import': {
+ edge: '76',
+ firefox: '67',
+ chrome: '63',
+ safari: '11.1',
+ opera: '50',
+ ios: '11.3',
+ android: '63',
+ and_chr: '63',
+ and_ff: '67',
+ samsung: '8',
+ },
+ 'worker-type': {
+ edge: '80',
+ chrome: '80',
+ opera: '67',
+ android: '81',
+ and_chr: '86',
+ },
+ 'service-worker-type': {},
};
const internalEnvironmentToEnvironment: WeakMap<
@@ -87,7 +118,7 @@ export default class Environment implements IEnvironment {
return this;
}
- get context(): EnvironmentContext {
+ get context(): Set {
return this.#environment.context;
}
@@ -122,24 +153,28 @@ export default class Environment implements IEnvironment {
return this.#environment.sourceMap;
}
+ get loc(): ?SourceLocation {
+ return this.#environment.loc;
+ }
+
isBrowser(): boolean {
- return BROWSER_ENVS.has(this.#environment.context);
+ return setIntersects(this.#environment.context, BROWSER_ENVS);
}
isNode(): boolean {
- return NODE_ENVS.has(this.#environment.context);
+ return setIntersects(this.#environment.context, NODE_ENVS);
}
isElectron(): boolean {
- return ELECTRON_ENVS.has(this.#environment.context);
+ return setIntersects(this.#environment.context, ELECTRON_ENVS);
}
isIsolated(): boolean {
- return ISOLATED_ENVS.has(this.#environment.context);
+ return setIntersects(this.#environment.context, ISOLATED_ENVS);
}
isWorker(): boolean {
- return WORKER_ENVS.has(this.#environment.context);
+ return setIntersects(this.#environment.context, WORKER_ENVS);
}
matchesEngines(minVersions: VersionMap): boolean {
@@ -155,7 +190,7 @@ export default class Environment implements IEnvironment {
// If outputting esmodules, exclude browsers without support.
if (this.outputFormat === 'esmodule') {
- browsers = [...browsers, ...getExcludedBrowsers(ESMODULE_BROWSERS)];
+ browsers = [...browsers, ...getExcludedBrowsers(supportData.esmodules)];
}
let matchedBrowsers = browserslist(browsers);
@@ -168,6 +203,15 @@ export default class Environment implements IEnvironment {
return false;
}
+
+ supports(feature: EnvironmentFeature): boolean {
+ let engines = supportData[feature];
+ if (!engines) {
+ throw new Error('Unknown environment feature: ' + feature);
+ }
+
+ return this.matchesEngines(engines);
+ }
}
function getExcludedBrowsers(minVersions: VersionMap) {
diff --git a/packages/core/core/src/requests/AssetRequest.js b/packages/core/core/src/requests/AssetRequest.js
index 0a06b35928b..2b84a9a0a8c 100644
--- a/packages/core/core/src/requests/AssetRequest.js
+++ b/packages/core/core/src/requests/AssetRequest.js
@@ -9,6 +9,7 @@ import type {TransformationResult} from '../Transformation';
import {md5FromObject} from '@parcel/utils';
import nullthrows from 'nullthrows';
import createParcelConfigRequest from './ParcelConfigRequest';
+import {getAssetGroupId} from '../assetUtils';
type RunInput = {|
input: AssetRequestInput,
@@ -42,7 +43,7 @@ const type = 'asset_request';
function getId(input: AssetRequestInput) {
// eslint-disable-next-line no-unused-vars
let {optionsRef, ...hashInput} = input;
- return `${type}:${md5FromObject(hashInput)}`;
+ return `${type}:${getAssetGroupId(hashInput)}`;
}
async function run({input, api, options, farm}: RunInput) {
diff --git a/packages/core/core/src/requests/ParcelConfigRequest.js b/packages/core/core/src/requests/ParcelConfigRequest.js
index 0f1e5ca120c..d41b6132715 100644
--- a/packages/core/core/src/requests/ParcelConfigRequest.js
+++ b/packages/core/core/src/requests/ParcelConfigRequest.js
@@ -269,7 +269,11 @@ export function processConfig(
}
: undefined,
namers: processPipeline(configFile.namers, '/namers', configFile.filePath),
- runtimes: processMap(configFile.runtimes, '/runtimes', configFile.filePath),
+ runtimes: processPipeline(
+ configFile.runtimes,
+ '/runtimes',
+ configFile.filePath,
+ ),
packagers: processMap(
configFile.packagers,
'/packagers',
@@ -491,7 +495,7 @@ export function mergeConfigs(
validators: mergeMaps(base.validators, ext.validators, mergePipelines),
bundler: ext.bundler || base.bundler,
namers: mergePipelines(base.namers, ext.namers),
- runtimes: mergeMaps(base.runtimes, ext.runtimes, mergePipelines),
+ runtimes: mergePipelines(base.runtimes, ext.runtimes),
packagers: mergeMaps(base.packagers, ext.packagers),
optimizers: mergeMaps(base.optimizers, ext.optimizers, mergePipelines),
reporters: mergePipelines(base.reporters, ext.reporters),
diff --git a/packages/core/core/src/requests/TargetRequest.js b/packages/core/core/src/requests/TargetRequest.js
index 8c88cfe044c..cc5cba9e392 100644
--- a/packages/core/core/src/requests/TargetRequest.js
+++ b/packages/core/core/src/requests/TargetRequest.js
@@ -24,6 +24,7 @@ import {
resolveConfig,
md5FromObject,
validateSchema,
+ setIntersects,
} from '@parcel/utils';
import {createEnvironment} from '../Environment';
import createParcelConfigRequest from './ParcelConfigRequest';
@@ -199,7 +200,7 @@ export class TargetResolver {
},
});
}
- if (!BROWSER_ENVS.has(targets[0].env.context)) {
+ if (!setIntersects(BROWSER_ENVS, targets[0].env.context)) {
throw new ThrowableDiagnostic({
diagnostic: {
message: `Only browser targets are supported in serve mode`,
diff --git a/packages/core/core/src/types.js b/packages/core/core/src/types.js
index 70a819fcaaf..9b0a3e98364 100644
--- a/packages/core/core/src/types.js
+++ b/packages/core/core/src/types.js
@@ -50,7 +50,7 @@ export type ProcessedParcelConfig = {|
transformers?: {[Glob]: ExtendableParcelConfigPipeline, ...},
bundler: ?ParcelPluginNode,
namers?: PureParcelConfigPipeline,
- runtimes?: {[EnvironmentContext]: PureParcelConfigPipeline, ...},
+ runtimes?: PureParcelConfigPipeline,
packagers?: {[Glob]: ParcelPluginNode, ...},
optimizers?: {[Glob]: ExtendableParcelConfigPipeline, ...},
reporters?: PureParcelConfigPipeline,
@@ -60,7 +60,7 @@ export type ProcessedParcelConfig = {|
|};
export type Environment = {|
- context: EnvironmentContext,
+ context: Set,
engines: Engines,
includeNodeModules:
| boolean
@@ -71,6 +71,7 @@ export type Environment = {|
minify: boolean,
scopeHoist: boolean,
sourceMap: ?TargetSourceMapOptions,
+ loc: ?SourceLocation,
|};
export type Target = {|
diff --git a/packages/core/core/test/Environment.test.js b/packages/core/core/test/Environment.test.js
index 40dd9b048f9..733097e4bfd 100644
--- a/packages/core/core/test/Environment.test.js
+++ b/packages/core/core/test/Environment.test.js
@@ -6,7 +6,7 @@ import {createEnvironment} from '../src/Environment';
describe('Environment', () => {
it('assigns a default environment with nothing passed', () => {
assert.deepEqual(createEnvironment(), {
- context: 'browser',
+ context: new Set(['browser']),
engines: {
browsers: ['> 0.25%'],
},
@@ -16,12 +16,13 @@ describe('Environment', () => {
minify: false,
scopeHoist: false,
sourceMap: undefined,
+ loc: undefined,
});
});
it('assigns a node context if a node engine is given', () => {
assert.deepEqual(createEnvironment({engines: {node: '>= 10.0.0'}}), {
- context: 'node',
+ context: new Set(['node']),
engines: {
node: '>= 10.0.0',
},
@@ -31,6 +32,7 @@ describe('Environment', () => {
minify: false,
scopeHoist: false,
sourceMap: undefined,
+ loc: undefined,
});
});
@@ -38,7 +40,7 @@ describe('Environment', () => {
assert.deepEqual(
createEnvironment({engines: {browsers: ['last 1 version']}}),
{
- context: 'browser',
+ context: new Set(['browser']),
engines: {
browsers: ['last 1 version'],
},
@@ -48,13 +50,14 @@ describe('Environment', () => {
minify: false,
scopeHoist: false,
sourceMap: undefined,
+ loc: undefined,
},
);
});
it('assigns default engines for node', () => {
assert.deepEqual(createEnvironment({context: 'node'}), {
- context: 'node',
+ context: new Set(['node']),
engines: {
node: '>= 8.0.0',
},
@@ -64,12 +67,13 @@ describe('Environment', () => {
minify: false,
scopeHoist: false,
sourceMap: undefined,
+ loc: undefined,
});
});
it('assigns default engines for browsers', () => {
assert.deepEqual(createEnvironment({context: 'browser'}), {
- context: 'browser',
+ context: new Set(['browser']),
engines: {
browsers: ['> 0.25%'],
},
@@ -79,6 +83,7 @@ describe('Environment', () => {
minify: false,
scopeHoist: false,
sourceMap: undefined,
+ loc: undefined,
});
});
});
diff --git a/packages/core/core/test/ParcelConfigRequest.test.js b/packages/core/core/test/ParcelConfigRequest.test.js
index 572caf8d19c..509f4d38570 100644
--- a/packages/core/core/test/ParcelConfigRequest.test.js
+++ b/packages/core/core/test/ParcelConfigRequest.test.js
@@ -568,7 +568,7 @@ describe('loadParcelConfig', () => {
resolveFrom: '.parcelrc',
keyPath: '/bundler',
},
- runtimes: {},
+ runtimes: [],
namers: [],
optimizers: {},
packagers: {},
diff --git a/packages/core/core/test/TargetRequest.test.js b/packages/core/core/test/TargetRequest.test.js
index 643450d51e3..1a74e436d31 100644
--- a/packages/core/core/test/TargetRequest.test.js
+++ b/packages/core/core/test/TargetRequest.test.js
@@ -103,7 +103,7 @@ describe('TargetResolver', () => {
publicUrl: '/',
distDir: path.resolve('customA'),
env: {
- context: 'browser',
+ context: new Set(['browser']),
includeNodeModules: true,
engines: {
browsers: ['> 0.25%'],
@@ -113,6 +113,7 @@ describe('TargetResolver', () => {
minify: false,
scopeHoist: false,
sourceMap: {},
+ loc: undefined,
},
},
{
@@ -120,7 +121,7 @@ describe('TargetResolver', () => {
publicUrl: '/',
distDir: path.resolve('customB'),
env: {
- context: 'node',
+ context: new Set(['node']),
includeNodeModules: false,
engines: {
node: '>= 8.0.0',
@@ -130,6 +131,7 @@ describe('TargetResolver', () => {
minify: false,
scopeHoist: false,
sourceMap: {},
+ loc: undefined,
},
},
],
@@ -148,7 +150,7 @@ describe('TargetResolver', () => {
distEntry: 'index.js',
publicUrl: '/',
env: {
- context: 'node',
+ context: new Set(['node']),
engines: {
node: '>= 8.0.0',
},
@@ -158,6 +160,7 @@ describe('TargetResolver', () => {
minify: false,
scopeHoist: false,
sourceMap: {},
+ loc: undefined,
},
loc: {
filePath: path.join(COMMON_TARGETS_FIXTURE_PATH, 'package.json'),
@@ -177,7 +180,7 @@ describe('TargetResolver', () => {
distEntry: 'index.js',
publicUrl: '/',
env: {
- context: 'browser',
+ context: new Set(['browser']),
engines: {
browsers: ['last 1 version'],
},
@@ -189,6 +192,7 @@ describe('TargetResolver', () => {
sourceMap: {
inlineSources: true,
},
+ loc: undefined,
},
loc: {
filePath: path.join(COMMON_TARGETS_FIXTURE_PATH, 'package.json'),
@@ -208,7 +212,7 @@ describe('TargetResolver', () => {
distEntry: 'index.js',
publicUrl: '/assets',
env: {
- context: 'browser',
+ context: new Set(['browser']),
engines: {
browsers: ['last 1 version'],
},
@@ -218,6 +222,7 @@ describe('TargetResolver', () => {
minify: false,
scopeHoist: false,
sourceMap: {},
+ loc: undefined,
},
loc: {
filePath: path.join(COMMON_TARGETS_FIXTURE_PATH, 'package.json'),
@@ -247,7 +252,7 @@ describe('TargetResolver', () => {
distEntry: 'index.js',
publicUrl: '/',
env: {
- context: 'node',
+ context: new Set(['node']),
engines: {
node: '>= 8.0.0',
},
@@ -257,6 +262,7 @@ describe('TargetResolver', () => {
minify: false,
scopeHoist: false,
sourceMap: undefined,
+ loc: undefined,
},
loc: {
filePath: path.join(
@@ -288,7 +294,7 @@ describe('TargetResolver', () => {
distEntry: 'index.js',
publicUrl: '/',
env: {
- context: 'node',
+ context: new Set(['node']),
engines: {
node: '>= 8.0.0',
},
@@ -298,6 +304,7 @@ describe('TargetResolver', () => {
minify: false,
scopeHoist: false,
sourceMap: {},
+ loc: undefined,
},
loc: {
filePath: path.join(CUSTOM_TARGETS_FIXTURE_PATH, 'package.json'),
@@ -320,7 +327,7 @@ describe('TargetResolver', () => {
distEntry: 'index.js',
publicUrl: '/',
env: {
- context: 'browser',
+ context: new Set(['browser']),
engines: {
browsers: ['last 1 version'],
},
@@ -330,6 +337,7 @@ describe('TargetResolver', () => {
minify: false,
scopeHoist: false,
sourceMap: {},
+ loc: undefined,
},
loc: {
filePath: path.join(CUSTOM_TARGETS_FIXTURE_PATH, 'package.json'),
@@ -352,7 +360,7 @@ describe('TargetResolver', () => {
distEntry: 'index.js',
publicUrl: '/',
env: {
- context: 'browser',
+ context: new Set(['browser']),
engines: {
browsers: ['ie11'],
},
@@ -362,6 +370,7 @@ describe('TargetResolver', () => {
minify: false,
scopeHoist: false,
sourceMap: {},
+ loc: undefined,
},
loc: {
filePath: path.join(CUSTOM_TARGETS_FIXTURE_PATH, 'package.json'),
@@ -390,7 +399,7 @@ describe('TargetResolver', () => {
distEntry: undefined,
publicUrl: 'www',
env: {
- context: 'browser',
+ context: new Set(['browser']),
engines: {
browsers: '> 0.25%',
},
@@ -400,6 +409,7 @@ describe('TargetResolver', () => {
minify: false,
scopeHoist: false,
sourceMap: {},
+ loc: undefined,
},
loc: undefined,
},
@@ -416,7 +426,7 @@ describe('TargetResolver', () => {
distEntry: 'index.js',
publicUrl: '/',
env: {
- context: 'node',
+ context: new Set(['node']),
engines: {},
includeNodeModules: false,
isLibrary: true,
@@ -424,6 +434,7 @@ describe('TargetResolver', () => {
minify: false,
scopeHoist: false,
sourceMap: {},
+ loc: undefined,
},
loc: {
filePath: path.join(CONTEXT_FIXTURE_PATH, 'package.json'),
@@ -450,7 +461,7 @@ describe('TargetResolver', () => {
distEntry: 'index.html',
publicUrl: '/',
env: {
- context: 'browser',
+ context: new Set(['browser']),
engines: {},
includeNodeModules: true,
isLibrary: false,
@@ -458,6 +469,7 @@ describe('TargetResolver', () => {
minify: false,
scopeHoist: false,
sourceMap: {},
+ loc: undefined,
},
loc: {
filePath: path.join(fixture, 'package.json'),
@@ -489,7 +501,7 @@ describe('TargetResolver', () => {
distEntry: 'index.js',
publicUrl: '/',
env: {
- context: 'node',
+ context: new Set(['node']),
engines: {
node: '>= 8.0.0',
},
@@ -499,6 +511,7 @@ describe('TargetResolver', () => {
minify: false,
scopeHoist: false,
sourceMap: {},
+ loc: undefined,
},
loc: {
filePath: path.join(COMMON_TARGETS_FIXTURE_PATH, 'package.json'),
@@ -518,7 +531,7 @@ describe('TargetResolver', () => {
distEntry: 'index.js',
publicUrl: '/assets',
env: {
- context: 'browser',
+ context: new Set(['browser']),
engines: {
browsers: ['last 1 version'],
},
@@ -528,6 +541,7 @@ describe('TargetResolver', () => {
minify: false,
scopeHoist: false,
sourceMap: {},
+ loc: undefined,
},
loc: {
filePath: path.join(COMMON_TARGETS_FIXTURE_PATH, 'package.json'),
@@ -561,7 +575,7 @@ describe('TargetResolver', () => {
distDir: serveDistDir,
publicUrl: '/',
env: {
- context: 'browser',
+ context: new Set(['browser']),
engines: {},
includeNodeModules: true,
outputFormat: 'global',
@@ -569,6 +583,7 @@ describe('TargetResolver', () => {
minify: false,
scopeHoist: false,
sourceMap: {},
+ loc: undefined,
},
},
],
@@ -586,7 +601,7 @@ describe('TargetResolver', () => {
distDir: path.join(DEFAULT_DISTPATH_FIXTURE_PATHS.none, 'dist'),
publicUrl: '/',
env: {
- context: 'browser',
+ context: new Set(['browser']),
engines: {
browsers: ['Chrome 80'],
},
@@ -596,6 +611,7 @@ describe('TargetResolver', () => {
minify: false,
scopeHoist: false,
sourceMap: {},
+ loc: undefined,
},
},
],
@@ -614,7 +630,7 @@ describe('TargetResolver', () => {
distEntry: undefined,
publicUrl: '/',
env: {
- context: 'browser',
+ context: new Set(['browser']),
engines: {
browsers: ['Chrome 80'],
},
@@ -624,6 +640,7 @@ describe('TargetResolver', () => {
minify: false,
scopeHoist: false,
sourceMap: {},
+ loc: undefined,
},
loc: undefined,
},
@@ -647,7 +664,7 @@ describe('TargetResolver', () => {
distEntry: undefined,
publicUrl: '/',
env: {
- context: 'browser',
+ context: new Set(['browser']),
engines: {
browsers: ['last 1 version'],
},
@@ -657,6 +674,7 @@ describe('TargetResolver', () => {
minify: false,
scopeHoist: false,
sourceMap: {},
+ loc: undefined,
},
loc: undefined,
},
@@ -670,7 +688,7 @@ describe('TargetResolver', () => {
distEntry: undefined,
publicUrl: '/',
env: {
- context: 'browser',
+ context: new Set(['browser']),
engines: {
browsers: ['IE 11'],
},
@@ -680,6 +698,7 @@ describe('TargetResolver', () => {
minify: false,
scopeHoist: false,
sourceMap: {},
+ loc: undefined,
},
loc: undefined,
},
diff --git a/packages/core/integration-tests/test/cache.js b/packages/core/integration-tests/test/cache.js
index 4e1de620e17..8682d31b1fe 100644
--- a/packages/core/integration-tests/test/cache.js
+++ b/packages/core/integration-tests/test/cache.js
@@ -1808,7 +1808,7 @@ describe('cache', function() {
'utf8',
);
assert(
- contents.includes('
+