Skip to content

Commit 831051a

Browse files
committed
fix(): pass this context to injectPlugin
1 parent 2bd17fb commit 831051a

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/index.ts

+8-6
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,17 @@ export default function (opts: NodePolyfillsOptions = {}) {
99
include: opts.include,
1010
exclude: opts.exclude,
1111
modules: {
12-
'process': 'process',
13-
'Buffer': ['buffer', 'Buffer'],
14-
'global': GLOBAL_PATH,
15-
'__filename': FILENAME_PATH,
16-
'__dirname': DIRNAME_PATH,
12+
'process': 'process',
13+
'Buffer': ['buffer', 'Buffer'],
14+
'global': GLOBAL_PATH,
15+
'__filename': FILENAME_PATH,
16+
'__dirname': DIRNAME_PATH,
1717
}
1818
});
1919
const basedir = opts.baseDir || '/';
2020
const dirs = new Map<string, string>();
2121
const resolver = builtinsResolver(opts);
2222
return {
23-
...injectPlugin,
2423
name: 'node-polyfills',
2524
resolveId(importee: string, importer: string) {
2625
if (importee === DIRNAME_PATH) {
@@ -39,6 +38,9 @@ export default function (opts: NodePolyfillsOptions = {}) {
3938
if (dirs.has(id)) {
4039
return `export default '${dirs.get(id)}'`;
4140
}
41+
},
42+
transform(code: string, id: string) {
43+
return injectPlugin.transform.call(this, code, id);
4244
}
4345
};
4446
}

0 commit comments

Comments
 (0)