rollup-plugin-node-globals
Advanced tools
Comparing version 1.0.6 to 1.0.7
@@ -5,8 +5,175 @@ 'use strict'; | ||
var inject = _interopDefault(require('rollup-plugin-inject')); | ||
var rollupPluginutils = require('rollup-pluginutils'); | ||
var estreeWalker = require('estree-walker'); | ||
var acorn = require('acorn'); | ||
var MagicString = _interopDefault(require('magic-string')); | ||
var path = require('path'); | ||
var crypto = require('crypto'); | ||
var reservedWords = 'break case class catch const continue debugger default delete do else export extends finally for function if import in instanceof let new return super switch this throw try typeof var void while with yield enum await implements package protected static interface private public'.split(' '); | ||
var builtins = 'Infinity NaN undefined null true false eval uneval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Symbol Error EvalError InternalError RangeError ReferenceError SyntaxError TypeError URIError Number Math Date String RegExp Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array Map Set WeakMap WeakSet SIMD ArrayBuffer DataView JSON Promise Generator GeneratorFunction Reflect Proxy Intl'.split(' '); | ||
var blacklisted = Object.create(null); | ||
reservedWords.concat(builtins).forEach(function (word) { | ||
return blacklisted[word] = true; | ||
}); | ||
function makeLegalIdentifier(str) { | ||
str = str.replace(/-(\w)/g, function (_, letter) { | ||
return letter.toUpperCase(); | ||
}).replace(/[^$_a-zA-Z0-9]/g, '_'); | ||
if (/\d/.test(str[0]) || blacklisted[str]) str = '_' + str; | ||
return str; | ||
} | ||
function isReference(node, parent) { | ||
if (node.type === 'MemberExpression') { | ||
return !node.computed && isReference(node.object, node); | ||
} | ||
if (node.type === 'Identifier') { | ||
// TODO is this right? | ||
if (parent.type === 'MemberExpression') return parent.computed || node === parent.object; | ||
// disregard the `bar` in { bar: foo } | ||
if (parent.type === 'Property' && node !== parent.value) return false; | ||
// disregard the `bar` in `class Foo { bar () {...} }` | ||
if (parent.type === 'MethodDefinition') return false; | ||
// disregard the `bar` in `export { foo as bar }` | ||
if (parent.type === 'ExportSpecifier' && node !== parent.local) return; | ||
return true; | ||
} | ||
} | ||
function flatten(node) { | ||
var name = void 0; | ||
var parts = []; | ||
while (node.type === 'MemberExpression') { | ||
parts.unshift(node.property.name); | ||
node = node.object; | ||
} | ||
name = node.name; | ||
parts.unshift(name); | ||
return { | ||
name: name, | ||
keypath: parts.join('.') | ||
}; | ||
} | ||
function inject (code, id, mod1, mod2, sourceMap) { | ||
var ast = void 0; | ||
try { | ||
ast = acorn.parse(code, { | ||
ecmaVersion: 6, | ||
sourceType: 'module' | ||
}); | ||
} catch (err) { | ||
err.message += ' in ' + id; | ||
throw err; | ||
} | ||
// analyse scopes | ||
var scope = rollupPluginutils.attachScopes(ast, 'scope'); | ||
var imports = {}; | ||
ast.body.forEach(function (node) { | ||
if (node.type === 'ImportDeclaration') { | ||
node.specifiers.forEach(function (specifier) { | ||
imports[specifier.local.name] = true; | ||
}); | ||
} | ||
}); | ||
var magicString = new MagicString(code); | ||
var newImports = {}; | ||
function handleReference(node, name, keypath, parent) { | ||
if ((mod1.has(keypath) || mod2.has(keypath)) && !scope.contains(name) && !imports[name]) { | ||
if (mod2.has(keypath) && parent.__handled) { | ||
return; | ||
} | ||
var module = mod1.has(keypath) ? mod1.get(keypath) : mod2.get(keypath); | ||
var moduleName = void 0, | ||
hash = void 0; | ||
if (typeof module === 'string') { | ||
moduleName = module; | ||
hash = keypath + ':' + moduleName + ':default'; | ||
} else { | ||
moduleName = module[0]; | ||
hash = keypath + ':' + moduleName + ':' + module[1]; | ||
} | ||
// prevent module from importing itself | ||
if (moduleName === id) return; | ||
var importLocalName = name === keypath ? name : makeLegalIdentifier('$inject_' + keypath); | ||
if (!newImports[hash]) { | ||
newImports[hash] = 'import ' + (typeof module === 'string' ? importLocalName : '{ ' + module[1] + ' as ' + importLocalName + ' }') + ' from \'' + moduleName + '\';'; | ||
} | ||
if (name !== keypath) { | ||
magicString.overwrite(node.start, node.end, importLocalName, true); | ||
} | ||
if (mod1.has(keypath)) { | ||
node.__handled = true; | ||
} | ||
} | ||
} | ||
estreeWalker.walk(ast, { | ||
enter: function enter(node, parent) { | ||
if (sourceMap) { | ||
magicString.addSourcemapLocation(node.start); | ||
magicString.addSourcemapLocation(node.end); | ||
} | ||
if (node.scope) scope = node.scope; | ||
// special case – shorthand properties. because node.key === node.value, | ||
// we can't differentiate once we've descended into the node | ||
if (node.type === 'Property' && node.shorthand) { | ||
var name = node.key.name; | ||
handleReference(node, name, name); | ||
return this.skip(); | ||
} | ||
if (isReference(node, parent)) { | ||
var _flatten = flatten(node); | ||
var _name = _flatten.name; | ||
var keypath = _flatten.keypath; | ||
handleReference(node, _name, keypath, parent); | ||
} | ||
}, | ||
leave: function leave(node) { | ||
if (node.scope) scope = scope.parent; | ||
} | ||
}); | ||
var keys = Object.keys(newImports); | ||
if (!keys.length) return null; | ||
var importBlock = keys.map(function (hash) { | ||
return newImports[hash]; | ||
}).join('\n\n'); | ||
magicString.prepend(importBlock + '\n\n'); | ||
return { | ||
code: magicString.toString(), | ||
map: sourceMap ? magicString.generateMap() : null | ||
}; | ||
} | ||
var PROCESS_PATH = require.resolve('process-es6'); | ||
var BUFFER_PATH = path.join(__dirname, '..', 'dist', 'buffer.js'); | ||
var BUFFER_PATH = require.resolve('buffer-es6'); | ||
var GLOBAL_PATH = path.join(__dirname, '..', 'src', 'global.js'); | ||
@@ -25,2 +192,29 @@ | ||
} | ||
var _mods1 = { | ||
'process.nextTick': [PROCESS_PATH, 'nextTick'], | ||
'process.browser': [PROCESS_PATH, 'browser'], | ||
'Buffer.isBuffer': [BUFFER_PATH, 'isBuffer'] | ||
}; | ||
var _mods2 = { | ||
process: PROCESS_PATH, | ||
Buffer: [BUFFER_PATH, 'Buffer'], | ||
global: GLOBAL_PATH, | ||
__filename: '__filename', | ||
__dirname: '__dirname' | ||
}; | ||
var mods1 = new Map(); | ||
var mods2 = new Map(); | ||
var buf = new Map(); | ||
buf.set('global', GLOBAL_PATH); | ||
Object.keys(_mods1).forEach(function (key) { | ||
mods1.set(key, _mods1[key]); | ||
}); | ||
Object.keys(_mods2).forEach(function (key) { | ||
mods2.set(key, _mods2[key]); | ||
}); | ||
var mods = Object.keys(_mods1).concat(Object.keys(_mods2)); | ||
function escape(str) { | ||
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&'); | ||
} | ||
var firstpass = new RegExp('(?:' + mods.map(escape).join('|') + ')', 'g'); | ||
var index = (function (options) { | ||
@@ -30,2 +224,6 @@ options = options || {}; | ||
var dirs = new Map(); | ||
var opts = clone(options); | ||
var exclude = (opts.exclude || []).concat(GLOBAL_PATH); | ||
var filter = rollupPluginutils.createFilter(options.include, exclude); | ||
var sourceMap = options.sourceMap !== false; | ||
return { | ||
@@ -50,16 +248,11 @@ load: function load(id) { | ||
transform: function transform(code, id) { | ||
var opts = clone(options); | ||
opts.exclude = opts.exclude || []; | ||
opts.exclude.push(GLOBAL_PATH); | ||
opts.exclude.push(BUFFER_PATH); | ||
opts.modules = { | ||
process: PROCESS_PATH, | ||
'process.nextTick': [PROCESS_PATH, 'nextTick'], | ||
'process.browser': [PROCESS_PATH, 'browser'], | ||
Buffer: [BUFFER_PATH, 'Buffer'], | ||
global: [GLOBAL_PATH, '_global'], | ||
__filename: '__filename', | ||
__dirname: '__dirname' | ||
}; | ||
return inject(opts).transform(code, id); | ||
if (id === BUFFER_PATH) { | ||
return inject(code, id, buf, new Map(), sourceMap); | ||
} | ||
if (!filter(id)) return null; | ||
if (code.search(firstpass) === -1) return null; | ||
if (id.slice(-3) !== '.js') return null; | ||
var out = inject(code, id, mods1, mods2, sourceMap); | ||
return out; | ||
} | ||
@@ -66,0 +259,0 @@ }; |
@@ -1,7 +0,174 @@ | ||
import inject from 'rollup-plugin-inject'; | ||
import { createFilter, attachScopes } from 'rollup-pluginutils'; | ||
import { walk } from 'estree-walker'; | ||
import { parse } from 'acorn'; | ||
import MagicString from 'magic-string'; | ||
import { join, relative, dirname } from 'path'; | ||
import { randomBytes } from 'crypto'; | ||
var reservedWords = 'break case class catch const continue debugger default delete do else export extends finally for function if import in instanceof let new return super switch this throw try typeof var void while with yield enum await implements package protected static interface private public'.split(' '); | ||
var builtins = 'Infinity NaN undefined null true false eval uneval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Symbol Error EvalError InternalError RangeError ReferenceError SyntaxError TypeError URIError Number Math Date String RegExp Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array Map Set WeakMap WeakSet SIMD ArrayBuffer DataView JSON Promise Generator GeneratorFunction Reflect Proxy Intl'.split(' '); | ||
var blacklisted = Object.create(null); | ||
reservedWords.concat(builtins).forEach(function (word) { | ||
return blacklisted[word] = true; | ||
}); | ||
function makeLegalIdentifier(str) { | ||
str = str.replace(/-(\w)/g, function (_, letter) { | ||
return letter.toUpperCase(); | ||
}).replace(/[^$_a-zA-Z0-9]/g, '_'); | ||
if (/\d/.test(str[0]) || blacklisted[str]) str = '_' + str; | ||
return str; | ||
} | ||
function isReference(node, parent) { | ||
if (node.type === 'MemberExpression') { | ||
return !node.computed && isReference(node.object, node); | ||
} | ||
if (node.type === 'Identifier') { | ||
// TODO is this right? | ||
if (parent.type === 'MemberExpression') return parent.computed || node === parent.object; | ||
// disregard the `bar` in { bar: foo } | ||
if (parent.type === 'Property' && node !== parent.value) return false; | ||
// disregard the `bar` in `class Foo { bar () {...} }` | ||
if (parent.type === 'MethodDefinition') return false; | ||
// disregard the `bar` in `export { foo as bar }` | ||
if (parent.type === 'ExportSpecifier' && node !== parent.local) return; | ||
return true; | ||
} | ||
} | ||
function flatten(node) { | ||
var name = void 0; | ||
var parts = []; | ||
while (node.type === 'MemberExpression') { | ||
parts.unshift(node.property.name); | ||
node = node.object; | ||
} | ||
name = node.name; | ||
parts.unshift(name); | ||
return { | ||
name: name, | ||
keypath: parts.join('.') | ||
}; | ||
} | ||
function inject (code, id, mod1, mod2, sourceMap) { | ||
var ast = void 0; | ||
try { | ||
ast = parse(code, { | ||
ecmaVersion: 6, | ||
sourceType: 'module' | ||
}); | ||
} catch (err) { | ||
err.message += ' in ' + id; | ||
throw err; | ||
} | ||
// analyse scopes | ||
var scope = attachScopes(ast, 'scope'); | ||
var imports = {}; | ||
ast.body.forEach(function (node) { | ||
if (node.type === 'ImportDeclaration') { | ||
node.specifiers.forEach(function (specifier) { | ||
imports[specifier.local.name] = true; | ||
}); | ||
} | ||
}); | ||
var magicString = new MagicString(code); | ||
var newImports = {}; | ||
function handleReference(node, name, keypath, parent) { | ||
if ((mod1.has(keypath) || mod2.has(keypath)) && !scope.contains(name) && !imports[name]) { | ||
if (mod2.has(keypath) && parent.__handled) { | ||
return; | ||
} | ||
var module = mod1.has(keypath) ? mod1.get(keypath) : mod2.get(keypath); | ||
var moduleName = void 0, | ||
hash = void 0; | ||
if (typeof module === 'string') { | ||
moduleName = module; | ||
hash = keypath + ':' + moduleName + ':default'; | ||
} else { | ||
moduleName = module[0]; | ||
hash = keypath + ':' + moduleName + ':' + module[1]; | ||
} | ||
// prevent module from importing itself | ||
if (moduleName === id) return; | ||
var importLocalName = name === keypath ? name : makeLegalIdentifier('$inject_' + keypath); | ||
if (!newImports[hash]) { | ||
newImports[hash] = 'import ' + (typeof module === 'string' ? importLocalName : '{ ' + module[1] + ' as ' + importLocalName + ' }') + ' from \'' + moduleName + '\';'; | ||
} | ||
if (name !== keypath) { | ||
magicString.overwrite(node.start, node.end, importLocalName, true); | ||
} | ||
if (mod1.has(keypath)) { | ||
node.__handled = true; | ||
} | ||
} | ||
} | ||
walk(ast, { | ||
enter: function enter(node, parent) { | ||
if (sourceMap) { | ||
magicString.addSourcemapLocation(node.start); | ||
magicString.addSourcemapLocation(node.end); | ||
} | ||
if (node.scope) scope = node.scope; | ||
// special case – shorthand properties. because node.key === node.value, | ||
// we can't differentiate once we've descended into the node | ||
if (node.type === 'Property' && node.shorthand) { | ||
var name = node.key.name; | ||
handleReference(node, name, name); | ||
return this.skip(); | ||
} | ||
if (isReference(node, parent)) { | ||
var _flatten = flatten(node); | ||
var _name = _flatten.name; | ||
var keypath = _flatten.keypath; | ||
handleReference(node, _name, keypath, parent); | ||
} | ||
}, | ||
leave: function leave(node) { | ||
if (node.scope) scope = scope.parent; | ||
} | ||
}); | ||
var keys = Object.keys(newImports); | ||
if (!keys.length) return null; | ||
var importBlock = keys.map(function (hash) { | ||
return newImports[hash]; | ||
}).join('\n\n'); | ||
magicString.prepend(importBlock + '\n\n'); | ||
return { | ||
code: magicString.toString(), | ||
map: sourceMap ? magicString.generateMap() : null | ||
}; | ||
} | ||
var PROCESS_PATH = require.resolve('process-es6'); | ||
var BUFFER_PATH = join(__dirname, '..', 'dist', 'buffer.js'); | ||
var BUFFER_PATH = require.resolve('buffer-es6'); | ||
var GLOBAL_PATH = join(__dirname, '..', 'src', 'global.js'); | ||
@@ -20,2 +187,29 @@ | ||
} | ||
var _mods1 = { | ||
'process.nextTick': [PROCESS_PATH, 'nextTick'], | ||
'process.browser': [PROCESS_PATH, 'browser'], | ||
'Buffer.isBuffer': [BUFFER_PATH, 'isBuffer'] | ||
}; | ||
var _mods2 = { | ||
process: PROCESS_PATH, | ||
Buffer: [BUFFER_PATH, 'Buffer'], | ||
global: GLOBAL_PATH, | ||
__filename: '__filename', | ||
__dirname: '__dirname' | ||
}; | ||
var mods1 = new Map(); | ||
var mods2 = new Map(); | ||
var buf = new Map(); | ||
buf.set('global', GLOBAL_PATH); | ||
Object.keys(_mods1).forEach(function (key) { | ||
mods1.set(key, _mods1[key]); | ||
}); | ||
Object.keys(_mods2).forEach(function (key) { | ||
mods2.set(key, _mods2[key]); | ||
}); | ||
var mods = Object.keys(_mods1).concat(Object.keys(_mods2)); | ||
function escape(str) { | ||
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&'); | ||
} | ||
var firstpass = new RegExp('(?:' + mods.map(escape).join('|') + ')', 'g'); | ||
var index = (function (options) { | ||
@@ -25,2 +219,6 @@ options = options || {}; | ||
var dirs = new Map(); | ||
var opts = clone(options); | ||
var exclude = (opts.exclude || []).concat(GLOBAL_PATH); | ||
var filter = createFilter(options.include, exclude); | ||
var sourceMap = options.sourceMap !== false; | ||
return { | ||
@@ -45,16 +243,11 @@ load: function load(id) { | ||
transform: function transform(code, id) { | ||
var opts = clone(options); | ||
opts.exclude = opts.exclude || []; | ||
opts.exclude.push(GLOBAL_PATH); | ||
opts.exclude.push(BUFFER_PATH); | ||
opts.modules = { | ||
process: PROCESS_PATH, | ||
'process.nextTick': [PROCESS_PATH, 'nextTick'], | ||
'process.browser': [PROCESS_PATH, 'browser'], | ||
Buffer: [BUFFER_PATH, 'Buffer'], | ||
global: [GLOBAL_PATH, '_global'], | ||
__filename: '__filename', | ||
__dirname: '__dirname' | ||
}; | ||
return inject(opts).transform(code, id); | ||
if (id === BUFFER_PATH) { | ||
return inject(code, id, buf, new Map(), sourceMap); | ||
} | ||
if (!filter(id)) return null; | ||
if (code.search(firstpass) === -1) return null; | ||
if (id.slice(-3) !== '.js') return null; | ||
var out = inject(code, id, mods1, mods2, sourceMap); | ||
return out; | ||
} | ||
@@ -61,0 +254,0 @@ }; |
@@ -5,3 +5,3 @@ { | ||
"jsnext:main": "dist/rollup-plugin-node-globals.es6.js", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "insert the same globals browserify does", | ||
@@ -17,4 +17,3 @@ "files": [ | ||
"build": "rollup -c -f cjs -o dist/rollup-plugin-node-globals.cjs.js && rollup -c -f es6 -o dist/rollup-plugin-node-globals.es6.js", | ||
"create-buffer": "browserify src/buffer-raw.js | derequire | derequire --from module --to ___mod | derequire --from exports --to _expor_ > tmp/buffer-raw.js", | ||
"prebuild": "rimraf dist tmp && mkdirp tmp dist && npm run create-buffer && cat src/buffer-prefix.js tmp/buffer-raw.js src/buffer-suffix.js > dist/buffer.js && rimraf tmp" | ||
"prebuild": "rimraf dist && mkdirp dist" | ||
}, | ||
@@ -24,4 +23,8 @@ "author": "Calvin Metcalf <calvin.metcalf@gmail.com>", | ||
"dependencies": { | ||
"acorn": "^4.0.1", | ||
"buffer-es6": "^4.9.1", | ||
"estree-walker": "^0.2.1", | ||
"magic-string": "^0.16.0", | ||
"process-es6": "^0.11.3", | ||
"rollup-plugin-inject": "^1.4.0" | ||
"rollup-pluginutils": "^1.5.2" | ||
}, | ||
@@ -28,0 +31,0 @@ "keywords": [ |
rollup-plugin-node-globals | ||
=== | ||
Plugin to insert node globals including so code that works with browserify should work even if it uses process or buffers. This not only uses [rollup-plugin-inject | ||
](https://github.com/rollup/rollup-plugin-inject) but bases itself on that as well. | ||
Plugin to insert node globals including so code that works with browserify should work even if it uses process or buffers. This is based on [rollup-plugin-inject | ||
](https://github.com/rollup/rollup-plugin-inject). | ||
@@ -7,0 +7,0 @@ - process |
@@ -1,3 +0,3 @@ | ||
export var _global = typeof global !== "undefined" ? global : | ||
export default typeof global !== "undefined" ? global : | ||
typeof self !== "undefined" ? self : | ||
typeof window !== "undefined" ? window : {} |
@@ -1,12 +0,13 @@ | ||
import inject from 'rollup-plugin-inject'; | ||
import inject from './inject/index'; | ||
import { join, relative, dirname } from 'path'; | ||
import {randomBytes} from 'crypto'; | ||
import {createFilter} from 'rollup-pluginutils'; | ||
const PROCESS_PATH = require.resolve('process-es6'); | ||
const BUFFER_PATH = join(__dirname, '..', 'dist', 'buffer.js'); | ||
const PROCESS_PATH = require.resolve('process-es6'); | ||
const BUFFER_PATH = require.resolve('buffer-es6'); | ||
const GLOBAL_PATH = join(__dirname, '..', 'src', 'global.js'); | ||
function clone (obj) { | ||
function clone(obj) { | ||
var out = {}; | ||
Object.keys(obj).forEach(function (key) { | ||
Object.keys(obj).forEach(function(key) { | ||
if (Array.isArray(obj[key])) { | ||
@@ -20,2 +21,29 @@ out[key] = obj[key].slice(); | ||
} | ||
var _mods1 = { | ||
'process.nextTick': [PROCESS_PATH, 'nextTick'], | ||
'process.browser': [PROCESS_PATH, 'browser'], | ||
'Buffer.isBuffer': [BUFFER_PATH, 'isBuffer'] | ||
}; | ||
var _mods2 = { | ||
process: PROCESS_PATH, | ||
Buffer: [BUFFER_PATH, 'Buffer'], | ||
global: GLOBAL_PATH, | ||
__filename: '__filename', | ||
__dirname: '__dirname' | ||
}; | ||
var mods1 = new Map(); | ||
var mods2 = new Map(); | ||
var buf = new Map(); | ||
buf.set('global', GLOBAL_PATH); | ||
Object.keys(_mods1).forEach(key=>{ | ||
mods1.set(key, _mods1[key]); | ||
}); | ||
Object.keys(_mods2).forEach(key=>{ | ||
mods2.set(key, _mods2[key]); | ||
}); | ||
var mods = Object.keys(_mods1).concat(Object.keys(_mods2)); | ||
function escape ( str ) { | ||
return str.replace( /[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&' ); | ||
} | ||
const firstpass = new RegExp(`(?:${ mods.map( escape ).join( '|')})`, 'g'); | ||
export default options => { | ||
@@ -25,2 +53,6 @@ options = options || {}; | ||
var dirs = new Map(); | ||
var opts = clone(options); | ||
var exclude = (opts.exclude || []).concat(GLOBAL_PATH); | ||
const filter = createFilter(options.include, exclude); | ||
const sourceMap = options.sourceMap !== false; | ||
return { | ||
@@ -35,3 +67,3 @@ load(id) { | ||
let id = randomBytes(15).toString('hex'); | ||
dirs.set(id, dirname('/' + relative(basedir, importer))); | ||
dirs.set(id, dirname('/' + relative(basedir, importer))); | ||
return id; | ||
@@ -41,3 +73,3 @@ } | ||
let id = randomBytes(15).toString('hex'); | ||
dirs.set(id, '/' + relative(basedir, importer)); | ||
dirs.set(id, '/' + relative(basedir, importer)); | ||
return id; | ||
@@ -47,18 +79,13 @@ } | ||
transform(code, id) { | ||
var opts = clone(options); | ||
opts.exclude = opts.exclude || []; | ||
opts.exclude.push(GLOBAL_PATH); | ||
opts.exclude.push(BUFFER_PATH); | ||
opts.modules = { | ||
process: PROCESS_PATH, | ||
'process.nextTick': [PROCESS_PATH, 'nextTick'], | ||
'process.browser': [PROCESS_PATH, 'browser'], | ||
Buffer: [BUFFER_PATH, 'Buffer'], | ||
global: [GLOBAL_PATH, '_global'], | ||
__filename: '__filename', | ||
__dirname: '__dirname' | ||
}; | ||
return inject(opts).transform(code, id); | ||
if (id === BUFFER_PATH) { | ||
return inject(code, id, buf, new Map(), sourceMap); | ||
} | ||
if (!filter(id)) return null; | ||
if (code.search(firstpass) === -1) return null; | ||
if (id.slice(-3) !== '.js') return null; | ||
var out = inject(code, id, mods1, mods2, sourceMap); | ||
return out; | ||
} | ||
} | ||
} |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
0
26941
6
8
664
1
+ Addedacorn@^4.0.1
+ Addedbuffer-es6@^4.9.1
+ Addedestree-walker@^0.2.1
+ Addedmagic-string@^0.16.0
+ Addedrollup-pluginutils@^1.5.2
+ Addedacorn@4.0.13(transitive)
+ Addedbuffer-es6@4.9.3(transitive)
+ Addedmagic-string@0.16.0(transitive)
- Removedrollup-plugin-inject@^1.4.0
- Removedacorn@2.7.0(transitive)
- Removedmagic-string@0.10.2(transitive)
- Removedrollup-plugin-inject@1.4.1(transitive)