Skip to content

Commit

Permalink
fix: accept node prefix in modules obj
Browse files Browse the repository at this point in the history
fixes: #296
  • Loading branch information
imranbarbhuiya committed Nov 17, 2024
1 parent 40a00a2 commit 4b8b611
Show file tree
Hide file tree
Showing 11 changed files with 36,345 additions and 74,122 deletions.
6 changes: 4 additions & 2 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@ export default [
...node,
...typescript,
{
ignores: ['.github', '.yarn', 'dist'],
rules: {
'unicorn/prefer-string-replace-all': 'off',
},
languageOptions: {
parserOptions: {
projectService: {
allowDefaultProject: ['eslint.config.mjs', 'tsup.config.ts', 'vitest.config.ts', 'eslint.config.mjs'],
allowDefaultProject: ['tsup.config.ts', 'vitest.config.ts', 'eslint.config.mjs'],
defaultProject: 'tsconfig.eslint.json',
},
tsconfigRootDir: import.meta.dirname,
},
},
},
{
ignores: ['.github', '.yarn', 'dist'],
},
];
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"node-polyfill"
],
"dependencies": {
"@jspm/core": "^2.1.0",
"@jspm/core": "2.0.1",
"local-pkg": "^0.5.0",
"resolve.exports": "^2.0.2"
},
Expand All @@ -43,7 +43,7 @@
"@types/node": "^22.9.0",
"cz-conventional-changelog": "^3.3.0",
"esbuild": "^0.24.0",
"eslint": "^9.15.0",
"eslint": "9.14.0",
"eslint-config-mahir": "^1.0.5",
"husky": "^9.1.6",
"lint-staged": "^15.2.10",
Expand All @@ -54,7 +54,7 @@
"vitest": "^2.1.5"
},
"peerDependencies": {
"esbuild": ">=0.14.0 <=0.23.x"
"esbuild": ">=0.14.0 <=0.24.x"
},
"files": [
"dist/**/*.js*",
Expand Down Expand Up @@ -85,7 +85,8 @@
},
"resolutions": {
"ansi-regex": "^5.0.1",
"minimist": "^1.2.8"
"minimist": "^1.2.8",
"eslint": "9.14.0"
},
"engines": {
"node": ">=14.0.0"
Expand Down
4 changes: 2 additions & 2 deletions src/lib/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ export const nodeModulesPolyfillPlugin = (options: NodePolyfillsOptions = {}): P

return {
name,
// eslint-disable-next-line @typescript-eslint/unbound-method
setup: ({ onLoad, onResolve, onEnd, initialOptions }) => {
if (shouldDetectErrorModules && initialOptions.write !== false)
throw new Error(`The "write" build option must be set to false when using the "error" polyfill type`);
Expand Down Expand Up @@ -177,7 +176,8 @@ export const nodeModulesPolyfillPlugin = (options: NodePolyfillsOptions = {}): P
}

const moduleName = normalizeNodeBuiltinPath(args.path);
const polyfillOption = modules[moduleName];

const polyfillOption = modules[moduleName] ?? modules[`node:${moduleName}`];

if (!polyfillOption) return result[fallback];

Expand Down
Loading

0 comments on commit 4b8b611

Please sign in to comment.