Skip to content

Commit

Permalink
rename parentAsset to root for msb config and remove unstable (#9486)
Browse files Browse the repository at this point in the history
  • Loading branch information
AGawrys committed Jan 23, 2024
1 parent a5ff7e7 commit 855bbb6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
22 changes: 11 additions & 11 deletions packages/bundlers/default/src/DefaultBundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type ManualSharedBundles = Array<{|
name: string,
assets: Array<Glob>,
types?: Array<string>,
parent?: string,
root?: string,
split?: number,
|}>;

Expand All @@ -47,7 +47,7 @@ type BaseBundlerConfig = {|
minBundleSize?: number,
maxParallelRequests?: number,
disableSharedBundles?: boolean,
unstable_manualSharedBundles?: ManualSharedBundles,
manualSharedBundles?: ManualSharedBundles,
|};

type BundlerConfig = {|
Expand Down Expand Up @@ -443,8 +443,8 @@ function createIdealGraph(
let parentsToConfig = new DefaultMap(() => []);

for (let c of config.manualSharedBundles) {
if (c.parent != null) {
parentsToConfig.get(path.join(config.projectRoot, c.parent)).push(c);
if (c.root != null) {
parentsToConfig.get(path.join(config.projectRoot, c.root)).push(c);
}
}
let numParentsToFind = parentsToConfig.size;
Expand All @@ -468,7 +468,7 @@ function createIdealGraph(
// Process in reverse order so earlier configs take precedence
for (let c of config.manualSharedBundles.reverse()) {
invariant(
c.parent == null || configToParentAsset.has(c),
c.root == null || configToParentAsset.has(c),
'Invalid manual shared bundle. Could not find parent asset.',
);

Expand Down Expand Up @@ -1812,7 +1812,7 @@ const CONFIG_SCHEMA: SchemaEntity = {
type: 'number',
enum: Object.keys(HTTP_OPTIONS).map(k => Number(k)),
},
unstable_manualSharedBundles: {
manualSharedBundles: {
type: 'array',
items: {
type: 'object',
Expand All @@ -1832,7 +1832,7 @@ const CONFIG_SCHEMA: SchemaEntity = {
type: 'string',
},
},
parent: {
root: {
type: 'string',
},
split: {
Expand Down Expand Up @@ -2001,12 +2001,12 @@ async function loadBundlerConfig(
});
}

if (modeConfig.unstable_manualSharedBundles) {
let nameArray = modeConfig.unstable_manualSharedBundles.map(a => a.name);
if (modeConfig.manualSharedBundles) {
let nameArray = modeConfig.manualSharedBundles.map(a => a.name);
let nameSet = new Set(nameArray);
invariant(
nameSet.size == nameArray.length,
'The name field must be unique for property unstable_manualSharedBundles',
'The name field must be unique for property manualSharedBundles',
);
}

Expand Down Expand Up @@ -2034,7 +2034,7 @@ async function loadBundlerConfig(
disableSharedBundles:
modeConfig.disableSharedBundles ?? defaults.disableSharedBundles,
manualSharedBundles:
modeConfig.unstable_manualSharedBundles ?? defaults.manualSharedBundles,
modeConfig.manualSharedBundles ?? defaults.manualSharedBundles,
};
}

Expand Down
20 changes: 10 additions & 10 deletions packages/core/integration-tests/test/bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,7 @@ describe('bundler', function () {
{
"@parcel/bundler-default": {
"minBundleSize": 0,
"unstable_manualSharedBundles": [{
"manualSharedBundles": [{
"name": "vendor",
"assets": ["vendor*.*"]
}]
Expand Down Expand Up @@ -1305,7 +1305,7 @@ describe('bundler', function () {
package.json:
{
"@parcel/bundler-default": {
"unstable_manualSharedBundles": [{
"manualSharedBundles": [{
"name": "manual-inline",
"assets": ["shared.js"]
}]
Expand Down Expand Up @@ -1386,7 +1386,7 @@ describe('bundler', function () {
{
"@parcel/bundler-default": {
"minBundleSize": 0,
"unstable_manualSharedBundles": [{
"manualSharedBundles": [{
"name": "vendor",
"assets": ["vendor*.*"],
"types": ["js"]
Expand Down Expand Up @@ -1471,9 +1471,9 @@ describe('bundler', function () {
{
"@parcel/bundler-default": {
"minBundleSize": 0,
"unstable_manualSharedBundles": [{
"manualSharedBundles": [{
"name": "vendor",
"parent": "math/math.js",
"root": "math/math.js",
"assets": ["math/!(divide).js"]
}]
}
Expand Down Expand Up @@ -1542,7 +1542,7 @@ describe('bundler', function () {
},
"@parcel/bundler-default": {
"minBundleSize": 0,
"unstable_manualSharedBundles": [{
"manualSharedBundles": [{
"name": "vendor",
"assets": ["vendor*.*"],
"types": ["js"]
Expand Down Expand Up @@ -1614,9 +1614,9 @@ describe('bundler', function () {
},
"@parcel/bundler-default": {
"minBundleSize": 0,
"unstable_manualSharedBundles": [{
"manualSharedBundles": [{
"name": "vendor",
"parent": "manual.js",
"root": "manual.js",
"assets": ["**/*"],
"types": ["js"]
}]
Expand Down Expand Up @@ -1682,9 +1682,9 @@ describe('bundler', function () {
{
"@parcel/bundler-default": {
"minBundleSize": 0,
"unstable_manualSharedBundles": [{
"manualSharedBundles": [{
"name": "vendor",
"parent": "vendor.js",
"root": "vendor.js",
"assets": ["**/*"],
"split": 3
}]
Expand Down

0 comments on commit 855bbb6

Please sign in to comment.