Skip to content

Commit

Permalink
chore(is-core-module): make nolyfill baseline node version compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Jul 22, 2024
1 parent ada461e commit 7dba5fc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/manual/is-core-module/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions packages/manual/is-core-module/rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@ export default defineConfig(() => {
}
const coreJson = JSON.parse(fs.readFileSync(path.resolve(coreJsonPath, '../core.json'), 'utf-8')) as Record<string, boolean | string | string[]>;

const coreModules = Object.entries(coreJson).reduce<string[]>((acc, [key, value]) => {
const [coreModules, node12Modules] = Object.entries(coreJson).reduce<[coreModules: string[], node12Modules: string[]]>((acc, [key, value]) => {
// this excludes all dropped core modules (e.g. buffer_ieee754)
if (versionIncluded('999999.999999.999999', value)) {
acc.push(key);
if (versionIncluded('999999.99999.999999', value)) {
acc[0].push(key);
}
if (versionIncluded('12.4.0', value)) {
acc[1].push(key);
}

return acc;
}, []);
}, [[], []]);

const builtinModulesWithNodePrefix = builtinModules.concat(builtinModules.map(x => `node:${x}`));
for (const x of builtinModulesWithNodePrefix) {
Expand All @@ -34,8 +37,8 @@ export default defineConfig(() => {
}
}

const builtinModulesWithNodePrefixSet = new Set(builtinModulesWithNodePrefix);
const injectedModules = coreModules.filter(x => !builtinModulesWithNodePrefixSet.has(x));
const node12ModulesWithNodePrefix = new Set(node12Modules.concat(node12Modules.map(x => `node:${x}`)));
const injectedModules = coreModules.filter(x => !node12ModulesWithNodePrefix.has(x));

return defineConfig([
{
Expand Down

0 comments on commit 7dba5fc

Please sign in to comment.