Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Worker bug fixes #6582

Merged
merged 8 commits into from
Jul 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/core/core/src/BundleGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,8 @@ export default class BundleGraph {
if (
node.type === 'root' ||
(node.type === 'bundle' &&
node.value.env.context !== bundle.env.context)
(node.value.id === bundle.id ||
node.value.env.context !== bundle.env.context))
) {
isReachable = false;
actions.stop();
Expand Down
3 changes: 1 addition & 2 deletions packages/core/core/src/Environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,9 @@ export function mergeEnvironments(
}

function getEnvironmentHash(env: Environment): string {
// context is excluded from hash so that assets can be shared between e.g. workers and browser.
// Different engines should be sufficient to distinguish multi-target builds.
return hashString(
JSON.stringify([
env.context,
env.engines,
env.includeNodeModules,
env.outputFormat,
Expand Down
4 changes: 4 additions & 0 deletions packages/core/core/src/public/Environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,10 @@ export default class Environment implements IEnvironment {
}

let matchedBrowsers = browserslist(browsers);
if (matchedBrowsers.length === 0) {
return false;
}

let minBrowsers = getExcludedBrowsers(minVersions);
let withoutMinBrowsers = browserslist([...browsers, ...minBrowsers]);
return matchedBrowsers.length === withoutMinBrowsers.length;
Expand Down
10 changes: 5 additions & 5 deletions packages/core/core/test/Environment.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {createEnvironment} from '../src/Environment';
describe('Environment', () => {
it('assigns a default environment with nothing passed', () => {
assert.deepEqual(createEnvironment(), {
id: '2163092a3dd83a5f',
id: '28ff5688dfa7d45e',
context: 'browser',
engines: {
browsers: ['> 0.25%'],
Expand All @@ -24,7 +24,7 @@ describe('Environment', () => {

it('assigns a node context if a node engine is given', () => {
assert.deepEqual(createEnvironment({engines: {node: '>= 10.0.0'}}), {
id: '36da7887c1caf6e9',
id: '3bae9fa4de65ce29',
context: 'node',
engines: {
node: '>= 10.0.0',
Expand All @@ -44,7 +44,7 @@ describe('Environment', () => {
assert.deepEqual(
createEnvironment({engines: {browsers: ['last 1 version']}}),
{
id: '74e2019b893d5a25',
id: '0006b4816a385465',
context: 'browser',
engines: {
browsers: ['last 1 version'],
Expand All @@ -63,7 +63,7 @@ describe('Environment', () => {

it('assigns default engines for node', () => {
assert.deepEqual(createEnvironment({context: 'node'}), {
id: 'e9e007a350f036f2',
id: '5171f29d65a099c4',
context: 'node',
engines: {
node: '>= 8.0.0',
Expand All @@ -81,7 +81,7 @@ describe('Environment', () => {

it('assigns default engines for browsers', () => {
assert.deepEqual(createEnvironment({context: 'browser'}), {
id: '2163092a3dd83a5f',
id: '28ff5688dfa7d45e',
context: 'browser',
engines: {
browsers: ['> 0.25%'],
Expand Down
50 changes: 25 additions & 25 deletions packages/core/core/test/TargetRequest.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ describe('TargetResolver', () => {
publicUrl: '/',
distDir: path.resolve('customA'),
env: {
id: '6d6739300b296419',
id: '7185aca026a1ba43',
context: 'browser',
includeNodeModules: true,
engines: {
Expand All @@ -140,7 +140,7 @@ describe('TargetResolver', () => {
distEntry: 'b.js',
distDir: path.resolve('customB'),
env: {
id: '8370e1d9bac5928e',
id: '923e2836f26d91cc',
context: 'node',
includeNodeModules: false,
engines: {
Expand Down Expand Up @@ -171,7 +171,7 @@ describe('TargetResolver', () => {
distEntry: 'index.js',
publicUrl: '/',
env: {
id: '09b930c9a214dbbb',
id: '5b90122270d806a3',
context: 'node',
engines: {
node: '>= 8.0.0',
Expand Down Expand Up @@ -205,7 +205,7 @@ describe('TargetResolver', () => {
distEntry: 'index.js',
publicUrl: '/',
env: {
id: '02a05911c4b149ef',
id: 'd569d73dba5024af',
context: 'browser',
engines: {
browsers: ['last 1 version'],
Expand Down Expand Up @@ -241,7 +241,7 @@ describe('TargetResolver', () => {
distEntry: 'index.js',
publicUrl: '/assets',
env: {
id: 'f17b51a5bc6afeb9',
id: 'f68e756a9f45b317',
context: 'browser',
engines: {
browsers: ['last 1 version'],
Expand Down Expand Up @@ -287,7 +287,7 @@ describe('TargetResolver', () => {
distEntry: 'index.js',
publicUrl: '/',
env: {
id: 'e9e007a350f036f2',
id: '5171f29d65a099c4',
context: 'node',
engines: {
node: '>= 8.0.0',
Expand Down Expand Up @@ -330,7 +330,7 @@ describe('TargetResolver', () => {
distEntry: 'index.js',
publicUrl: '/',
env: {
id: '09b930c9a214dbbb',
id: '5b90122270d806a3',
context: 'node',
engines: {
node: '>= 8.0.0',
Expand Down Expand Up @@ -364,7 +364,7 @@ describe('TargetResolver', () => {
distEntry: 'index.js',
publicUrl: '/',
env: {
id: 'a44a40bf101f18ec',
id: 'a06e3cc9e0541b70',
context: 'browser',
engines: {
browsers: ['last 1 version'],
Expand Down Expand Up @@ -398,7 +398,7 @@ describe('TargetResolver', () => {
distEntry: 'index.js',
publicUrl: '/',
env: {
id: 'a188d65cbb275231',
id: 'd9b90540ac44a9db',
context: 'browser',
engines: {
browsers: ['ie11'],
Expand Down Expand Up @@ -449,7 +449,7 @@ describe('TargetResolver', () => {
distEntry: 'index.js',
publicUrl: '/',
env: {
id: '09b930c9a214dbbb',
id: '5b90122270d806a3',
context: 'node',
engines: {
node: '>= 8.0.0',
Expand Down Expand Up @@ -483,7 +483,7 @@ describe('TargetResolver', () => {
distEntry: 'index.js',
publicUrl: '/',
env: {
id: 'a44a40bf101f18ec',
id: 'a06e3cc9e0541b70',
context: 'browser',
engines: {
browsers: ['last 1 version'],
Expand Down Expand Up @@ -517,7 +517,7 @@ describe('TargetResolver', () => {
distEntry: 'index.js',
publicUrl: '/',
env: {
id: 'a188d65cbb275231',
id: 'd9b90540ac44a9db',
context: 'browser',
engines: {
browsers: ['ie11'],
Expand Down Expand Up @@ -560,7 +560,7 @@ describe('TargetResolver', () => {
distEntry: undefined,
publicUrl: 'www',
env: {
id: '4f21c7d6d9f7ead7',
id: '0d13493649c1b9ee',
context: 'browser',
engines: {
browsers: '> 0.25%',
Expand Down Expand Up @@ -603,7 +603,7 @@ describe('TargetResolver', () => {
distDir: path.resolve('customB'),
publicUrl: '/',
env: {
id: '6d6739300b296419',
id: '7185aca026a1ba43',
context: 'browser',
engines: {
browsers: ['> 0.25%'],
Expand Down Expand Up @@ -645,7 +645,7 @@ describe('TargetResolver', () => {
distDir: path.resolve('customA'),
publicUrl: '/',
env: {
id: '6d6739300b296419',
id: '7185aca026a1ba43',
context: 'browser',
engines: {
browsers: ['> 0.25%'],
Expand Down Expand Up @@ -674,7 +674,7 @@ describe('TargetResolver', () => {
distEntry: 'index.js',
publicUrl: '/',
env: {
id: '48f9c3826a31634f',
id: 'b58d7c211621cd65',
context: 'node',
engines: {},
includeNodeModules: false,
Expand Down Expand Up @@ -1031,7 +1031,7 @@ describe('TargetResolver', () => {
distEntry: 'index.mjs',
publicUrl: '/',
env: {
id: 'f1b17591962458cc',
id: '82a58acaebe4fd7c',
context: 'browser',
engines: {},
includeNodeModules: true,
Expand Down Expand Up @@ -1069,7 +1069,7 @@ describe('TargetResolver', () => {
distEntry: 'index.js',
publicUrl: '/',
env: {
id: 'f1b17591962458cc',
id: '82a58acaebe4fd7c',
context: 'browser',
engines: {},
includeNodeModules: true,
Expand Down Expand Up @@ -1111,7 +1111,7 @@ describe('TargetResolver', () => {
distEntry: 'index.js',
publicUrl: '/',
env: {
id: '09b930c9a214dbbb',
id: '5b90122270d806a3',
context: 'node',
engines: {
node: '>= 8.0.0',
Expand Down Expand Up @@ -1145,7 +1145,7 @@ describe('TargetResolver', () => {
distEntry: 'index.js',
publicUrl: '/assets',
env: {
id: 'f17b51a5bc6afeb9',
id: 'f68e756a9f45b317',
context: 'browser',
engines: {
browsers: ['last 1 version'],
Expand Down Expand Up @@ -1193,7 +1193,7 @@ describe('TargetResolver', () => {
distDir: '.parcel-cache/dist',
publicUrl: '/',
env: {
id: 'c22175d22bace513',
id: '69f74e7f31319ffd',
context: 'browser',
engines: {},
includeNodeModules: true,
Expand Down Expand Up @@ -1223,7 +1223,7 @@ describe('TargetResolver', () => {
),
publicUrl: '/',
env: {
id: '45ce37e4d0180a7f',
id: '04e06037831229c5',
context: 'browser',
engines: {
browsers: ['Chrome 80'],
Expand Down Expand Up @@ -1256,7 +1256,7 @@ describe('TargetResolver', () => {
distEntry: undefined,
publicUrl: '/',
env: {
id: '45ce37e4d0180a7f',
id: '04e06037831229c5',
context: 'browser',
engines: {
browsers: ['Chrome 80'],
Expand Down Expand Up @@ -1294,7 +1294,7 @@ describe('TargetResolver', () => {
distEntry: undefined,
publicUrl: '/',
env: {
id: 'a44a40bf101f18ec',
id: 'a06e3cc9e0541b70',
context: 'browser',
engines: {
browsers: ['last 1 version'],
Expand Down Expand Up @@ -1322,7 +1322,7 @@ describe('TargetResolver', () => {
distEntry: undefined,
publicUrl: '/',
env: {
id: '040f13701e396244',
id: '83bb584641584b67',
context: 'browser',
engines: {
browsers: ['IE 11'],
Expand Down
16 changes: 16 additions & 0 deletions packages/core/integration-tests/test/BundleGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ describe('BundleGraph', () => {
type: 'asset',
value: 'worker-a.js',
},
{
type: 'asset',
value: 'lodash.js',
},
{
type: 'asset',
value: 'worker-b.js',
Expand All @@ -59,6 +63,18 @@ describe('BundleGraph', () => {
type: 'asset',
value: 'runtime.js',
},
{
type: 'asset',
value: 'get-worker-url.js',
},
{
type: 'asset',
value: 'bundle-url.js',
},
{
type: 'asset',
value: 'esmodule-helpers.js',
},
]);
});
});
Loading