@babel/helper-define-polyfill-provider
Advanced tools
Comparing version 0.4.4 to 0.5.0
@@ -8,3 +8,3 @@ "use strict"; | ||
var _utils = require("./utils"); | ||
var _importsCache = _interopRequireDefault(require("./imports-cache")); | ||
var _importsInjector = _interopRequireDefault(require("./imports-injector")); | ||
var _debugUtils = require("./debug-utils"); | ||
@@ -94,3 +94,2 @@ var _normalizeOptions = require("./normalize-options"); | ||
} = resolveOptions(options, babelApi); | ||
const getUtils = (0, _utils.createUtilsGetter)(new _importsCache.default(moduleName => deps.resolve(dirname, moduleName, absoluteImports))); | ||
@@ -102,2 +101,6 @@ // eslint-disable-next-line prefer-const | ||
let filterPolyfills; | ||
const getUtils = (0, _utils.createUtilsGetter)(new _importsInjector.default(moduleName => deps.resolve(dirname, moduleName, absoluteImports), name => { | ||
var _polyfillsNames$get, _polyfillsNames; | ||
return (_polyfillsNames$get = (_polyfillsNames = polyfillsNames) == null ? void 0 : _polyfillsNames.get(name)) != null ? _polyfillsNames$get : Infinity; | ||
})); | ||
const depsCache = new Map(); | ||
@@ -160,10 +163,10 @@ const api = { | ||
if (Array.isArray(provider.polyfills)) { | ||
polyfillsNames = new Set(provider.polyfills); | ||
polyfillsNames = new Map(provider.polyfills.map((name, index) => [name, index])); | ||
filterPolyfills = provider.filterPolyfills; | ||
} else if (provider.polyfills) { | ||
polyfillsNames = new Set(Object.keys(provider.polyfills)); | ||
polyfillsNames = new Map(Object.keys(provider.polyfills).map((name, index) => [name, index])); | ||
polyfillsSupport = provider.polyfills; | ||
filterPolyfills = provider.filterPolyfills; | ||
} else { | ||
polyfillsNames = new Set(); | ||
polyfillsNames = new Map(); | ||
} | ||
@@ -170,0 +173,0 @@ ({ |
@@ -29,3 +29,3 @@ "use strict"; | ||
let matched = false; | ||
for (const polyfill of polyfills) { | ||
for (const polyfill of polyfills.keys()) { | ||
if (regexp.test(polyfill)) { | ||
@@ -32,0 +32,0 @@ matched = true; |
@@ -138,9 +138,9 @@ "use strict"; | ||
return { | ||
injectGlobalImport(url) { | ||
cache.storeAnonymous(prog, url, (isScript, source) => { | ||
injectGlobalImport(url, moduleName) { | ||
cache.storeAnonymous(prog, url, moduleName, (isScript, source) => { | ||
return isScript ? template.statement.ast`require(${source})` : t.importDeclaration([], source); | ||
}); | ||
}, | ||
injectNamedImport(url, name, hint = name) { | ||
return cache.storeNamed(prog, url, name, (isScript, source, name) => { | ||
injectNamedImport(url, name, hint = name, moduleName) { | ||
return cache.storeNamed(prog, url, name, moduleName, (isScript, source, name) => { | ||
const id = prog.scope.generateUidIdentifier(hint); | ||
@@ -155,4 +155,4 @@ return { | ||
}, | ||
injectDefaultImport(url, hint = url) { | ||
return cache.storeNamed(prog, url, "default", (isScript, source) => { | ||
injectDefaultImport(url, hint = url, moduleName) { | ||
return cache.storeNamed(prog, url, "default", moduleName, (isScript, source) => { | ||
const id = prog.scope.generateUidIdentifier(hint); | ||
@@ -159,0 +159,0 @@ return { |
{ | ||
"name": "@babel/helper-define-polyfill-provider", | ||
"version": "0.4.4", | ||
"version": "0.5.0", | ||
"description": "Babel helper to create your own polyfill provider", | ||
@@ -58,3 +58,3 @@ "repository": { | ||
}, | ||
"gitHead": "984c56c59568283889c3f0f89e58d370e4fd10f8" | ||
"gitHead": "9738ea2a12643376a52c9be30c20ac19426a88cb" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
209838
2423