isolated-externals-plugin
Advanced tools
Comparing version 1.7.1 to 1.8.0
@@ -0,1 +1,21 @@ | ||
# [1.8.0](https://github.com/WTW-IM/isolated-externals-plugin/compare/v1.7.1...v1.8.0) (2021-05-05) | ||
### Build | ||
* updating git author/committer info in Release ([2cdb6aa](https://github.com/WTW-IM/isolated-externals-plugin/commit/2cdb6aa2079c2ef2a9766c8edcbaa539aad36168)) | ||
### Fix | ||
* adding the readystatechange listener to the correct object ([63a185c](https://github.com/WTW-IM/isolated-externals-plugin/commit/63a185cd2de8f98433a8e3c72b58adbff705c4f3)) | ||
* using Object.assign and awaiting result text before assign ([17be70b](https://github.com/WTW-IM/isolated-externals-plugin/commit/17be70bef30735ba5212ec4b9f5e3109f61b2808)) | ||
### Update | ||
* enabling nested externals ([e0e8da4](https://github.com/WTW-IM/isolated-externals-plugin/commit/e0e8da4d2a35d330d819b699c34fc6ab232e349d)) | ||
### Upgrade | ||
* updating packages for audit ([5fef82c](https://github.com/WTW-IM/isolated-externals-plugin/commit/5fef82cbcec361fe6747dd32de231f9e634c2eab)) | ||
## [1.7.1](https://github.com/WTW-IM/isolated-externals-plugin/compare/v1.7.0...v1.7.1) (2021-04-07) | ||
@@ -2,0 +22,0 @@ |
@@ -86,2 +86,5 @@ "use strict"; | ||
var readFile = util_1.promisify(fs_1.default.readFile); | ||
var generateVar = function (external) { | ||
return "var " + external + " = context." + external + " || (window || global || self)[\"" + external + "\"];"; | ||
}; | ||
function wrapApp(source, externals, appName) { | ||
@@ -91,6 +94,9 @@ var externalsList = Object.entries(externals); | ||
.map(function (_a) { | ||
var _b = __read(_a, 2), external = _b[1]; | ||
return "var " + external.name + " = context." + external.name + " || ( window || global || self )[\"" + external.name + "\"];"; | ||
var _b = __read(_a, 2), name = _b[1].name; | ||
return generateVar( | ||
// for the case of nested dependencies, we only need to define the base | ||
// object from our context | ||
name.split('.')[0]); | ||
}) | ||
.join(' '); | ||
.join('\n '); | ||
var wrappedSource = new webpack_sources_1.ConcatSource("function " + appName + "(context){", "\n", varNames, "\n", source, "\n", "}"); | ||
@@ -167,3 +173,3 @@ return wrappedSource; | ||
return entrypoints.some(function (entry) { | ||
return entry.entrypoint.runtimeChunk.files.includes(name); | ||
return entry.entrypoint.chunks.some(function (chunk) { return chunk.files.includes(name); }); | ||
}) && /\.js(x)?$/.test(name); | ||
@@ -174,3 +180,3 @@ }) | ||
var targetEntry = entrypoints.find(function (entry) { | ||
return entry.entrypoint.runtimeChunk.files.includes(name); | ||
return entry.entrypoint.chunks.some(function (chunk) { return chunk.files.includes(name); }); | ||
}) || { name: '' }; | ||
@@ -177,0 +183,0 @@ return [targetEntry.name, name, source]; |
@@ -47,6 +47,39 @@ "use strict"; | ||
}()); | ||
/* assign polyfill */ | ||
if (typeof Object.assign !== 'function') { | ||
// Must be writable: true, enumerable: false, configurable: true | ||
Object.defineProperty(Object, 'assign', { | ||
value: function assign(target) { | ||
// .length of function is 2 | ||
'use strict'; | ||
var varArgs = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
varArgs[_i - 1] = arguments[_i]; | ||
} | ||
if (target === null || target === undefined) { | ||
throw new TypeError('Cannot convert undefined or null to object'); | ||
} | ||
var to = Object(target); | ||
for (var index = 0; index < arguments.length; index++) { | ||
var nextSource = varArgs[index]; | ||
if (nextSource !== null && nextSource !== undefined) { | ||
for (var nextKey in nextSource) { | ||
// Avoid bugs when hasOwnProperty is shadowed | ||
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) { | ||
to[nextKey] = nextSource[nextKey]; | ||
} | ||
} | ||
} | ||
} | ||
return to; | ||
}, | ||
writable: true, | ||
configurable: true, | ||
}); | ||
} | ||
/* end assign polyfill */ | ||
function wrappedEval(content) { | ||
// in case of a self-invoking wrapper, make sure self is defined | ||
// as our context object. | ||
return eval("var self=this;\n" + content); | ||
return eval("\nvar self=this;\nvar globalThis = this;\n" + content + "\n "); | ||
} | ||
@@ -68,5 +101,7 @@ function getWindowCache() { | ||
var loadedFunction = function () { | ||
external.content = this.responseText; | ||
external.failed = this.status >= 400; | ||
external.loading = false; | ||
Object.assign(external, { | ||
content: this.responseText, | ||
failed: this.status >= 400, | ||
loading: false, | ||
}); | ||
onLoaded(external); | ||
@@ -81,5 +116,5 @@ request.removeEventListener('load', loadedFunction); | ||
return __awaiter(this, void 0, void 0, function () { | ||
var response, _a; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
var response, responseText; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, fetch(external.url, { | ||
@@ -91,9 +126,11 @@ // "follow" is technically the default, | ||
case 1: | ||
response = _b.sent(); | ||
external.failed = !response.ok || response.status >= 400; | ||
external.loading = false; | ||
_a = external; | ||
response = _a.sent(); | ||
return [4 /*yield*/, response.text()]; | ||
case 2: | ||
_a.content = _b.sent(); | ||
responseText = _a.sent(); | ||
Object.assign(external, { | ||
failed: !response.ok || response.status >= 400, | ||
loading: false, | ||
content: responseText, | ||
}); | ||
return [2 /*return*/, external]; | ||
@@ -157,5 +194,5 @@ } | ||
var replaceEventListener = function (ev, listener, options) { | ||
window.removeEventListener(ev, inMemoryListeners[ev] || listener, options); | ||
document.removeEventListener(ev, inMemoryListeners[ev] || listener, options); | ||
inMemoryListeners[ev] = listener; | ||
window.addEventListener(ev, listener, options); | ||
document.addEventListener(ev, listener, options); | ||
}; | ||
@@ -162,0 +199,0 @@ /* eslint-disable-next-line @typescript-eslint/no-unused-vars */ |
{ | ||
"name": "isolated-externals-plugin", | ||
"version": "1.7.1", | ||
"version": "1.8.0", | ||
"description": "", | ||
@@ -87,5 +87,5 @@ "main": "dist/index.js", | ||
"react-dom": "^17.0.1", | ||
"semantic-release": "^17.3.7", | ||
"semantic-release": "^17.4.2", | ||
"typescript": "^4.1.3", | ||
"webpack": "4", | ||
"webpack": "^4.46.0", | ||
"webpack-cli": "^4.5.0", | ||
@@ -92,0 +92,0 @@ "webpack-dev-server": "^3.11.2" |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
41394
586
1