rollup-plugin-node-polyfills
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -62,3 +62,3 @@ 'use strict'; | ||
if (libs.has(importee)) { | ||
return libs.get(importee); | ||
return { id: libs.get(importee), moduleSideEffects: false }; | ||
} | ||
@@ -72,7 +72,11 @@ return null; | ||
const injectPlugin = inject({ | ||
'process': 'process', | ||
'Buffer': ['buffer', 'Buffer'], | ||
'global': GLOBAL_PATH, | ||
'__filename': FILENAME_PATH, | ||
'__dirname': DIRNAME_PATH, | ||
include: opts.include, | ||
exclude: opts.exclude, | ||
modules: { | ||
'process': 'process', | ||
'Buffer': ['buffer', 'Buffer'], | ||
'global': GLOBAL_PATH, | ||
'__filename': FILENAME_PATH, | ||
'__dirname': DIRNAME_PATH, | ||
} | ||
}); | ||
@@ -82,7 +86,9 @@ const basedir = opts.baseDir || '/'; | ||
const resolver = builtinsResolver(opts); | ||
return Object.assign({}, injectPlugin, { name: 'node-polyfills', resolveId(importee, importer) { | ||
return { | ||
name: 'node-polyfills', | ||
resolveId(importee, importer) { | ||
if (importee === DIRNAME_PATH) { | ||
const id = getRandomId(); | ||
dirs.set(id, path.dirname('/' + path.relative(basedir, importer))); | ||
return id; | ||
return { id, moduleSideEffects: false }; | ||
} | ||
@@ -92,3 +98,3 @@ if (importee === FILENAME_PATH) { | ||
dirs.set(id, path.dirname('/' + path.relative(basedir, importer))); | ||
return id; | ||
return { id, moduleSideEffects: false }; | ||
} | ||
@@ -101,3 +107,7 @@ return resolver(importee); | ||
} | ||
} }); | ||
}, | ||
transform(code, id) { | ||
return injectPlugin.transform.call(this, code, id); | ||
} | ||
}; | ||
} | ||
@@ -104,0 +114,0 @@ function getRandomId() { |
import { NodePolyfillsOptions } from './modules'; | ||
export default function (opts?: NodePolyfillsOptions): any; | ||
export default function (opts?: NodePolyfillsOptions): { | ||
name: string; | ||
resolveId(importee: string, importer: string): { | ||
id: any; | ||
moduleSideEffects: boolean; | ||
} | null; | ||
load(id: string): string | undefined; | ||
transform(code: string, id: string): any; | ||
}; |
@@ -5,3 +5,8 @@ export interface NodePolyfillsOptions { | ||
baseDir?: string; | ||
include?: Array<string | RegExp> | string | RegExp | null; | ||
exclude?: Array<string | RegExp> | string | RegExp | null; | ||
} | ||
export declare function builtinsResolver(opts: NodePolyfillsOptions): (importee: string) => any; | ||
export declare function builtinsResolver(opts: NodePolyfillsOptions): (importee: string) => { | ||
id: any; | ||
moduleSideEffects: boolean; | ||
} | null; |
{ | ||
"name": "rollup-plugin-node-polyfills", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "module": "dist/index.mjs", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1453470
43874