Skip to content
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
10 changes: 2 additions & 8 deletions tasks/transform_conformance/snapshots/babel.snap.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
commit: 54a8389f

Passed: 437/846
Passed: 439/846

# All Passed:
* babel-plugin-transform-class-static-block
Expand Down Expand Up @@ -276,7 +276,7 @@ x Output mismatch
x Output mismatch


# babel-plugin-transform-class-properties (110/264)
# babel-plugin-transform-class-properties (112/264)
* assumption-constantSuper/complex-super-class/input.js
x Output mismatch

Expand Down Expand Up @@ -795,9 +795,6 @@ x Output mismatch
* private-loose/update/input.js
x Output mismatch

* public/arrow-static-this-without-transform/input.js
x Output mismatch

* public/call/input.js
Scope children mismatch:
after transform: ScopeId(1): [ScopeId(2), ScopeId(3), ScopeId(4)]
Expand Down Expand Up @@ -901,9 +898,6 @@ rebuilt : ScopeId(2): Some(ScopeId(0))
* public/super-with-collision/input.js
x Output mismatch

* public-loose/arrow-static-this-without-transform/input.js
x Output mismatch

* public-loose/class-shadow-builtins/input.mjs
x Output mismatch

Expand Down
54 changes: 1 addition & 53 deletions tasks/transform_conformance/update_fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ async function updateDir(dirPath, options, hasChangedOptions) {
await backupFile(path);
await writeFile(path, JSON.stringify(localOptions, null, 2) + '\n');
}
options = mergeOptions(options, localOptions);
options = { ...options, ...localOptions };
}

// Run Babel with updated options/input
Expand Down Expand Up @@ -154,58 +154,6 @@ function updateOptions(options) {
return hasChangedOptions;
}

/**
* Merge `options` into `parentOptions`.
* Returns merged options object. Does not mutate either input.
* @param {Object} parentOptions - Parent options
* @param {Object} options - Local options
* @returns {Object} - Merged options object
*/
function mergeOptions(parentOptions, options) {
parentOptions = { ...parentOptions };

function merge(key) {
if (!options[key]) return;

if (!parentOptions[key]) {
parentOptions[key] = options[key];
return;
}

parentOptions[key] = [...parentOptions[key]];

const parentPluginIndexes = new Map();
for (const [index, plugin] of parentOptions[key].entries()) {
parentPluginIndexes.set(getName(plugin), index);
}

for (const plugin of options[key]) {
const pluginName = getName(plugin);
const parentPluginIndex = parentPluginIndexes.get(pluginName);
if (parentPluginIndex !== undefined) {
parentOptions[key][parentPluginIndex] = plugin;
} else {
parentOptions[key].push(plugin);
}
}
}

merge('presets');
merge('plugins');

if (options.assumptions) {
parentOptions.assumptions = { ...parentOptions.assumptions, ...options.assumptions };
}

for (const [key, value] of Object.entries(options)) {
if (key === 'plugins' || key === 'presets' || key === 'assumptions') continue;
if (Object.hasOwn(parentOptions, key)) throw new Error(`Clash: ${key}`);
parentOptions[key] = value;
}

return parentOptions;
}

/**
* Transform input with Babel and save to output file.
* @param {string} inputPath - Path of input file
Expand Down