Fix UMD wrapper issues and refine wrappers - #2600
Merged
Merged
Conversation
…ion, only check for self in the UMD-IIFE case
9 tasks
|
Was there any reason there for the assignment in |
Member
Author
|
The reason for doing it in a little more complicated way is that in most situations, global will be used more than once and it was getting complicated to check how often global is accessed and implement two different versions for each possible access. Getting this right would have meant basically counting all accesses to global first before actually writing anything. Not impossible but quite complicated. |
Member
Author
|
For reference, this is what the wrapper will look like in a complicated scenario with a (function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('external1'), require('external2')) :
typeof define === 'function' && define.amd ? define(['exports', 'external1', 'external2'], factory) :
(global = global || self, (function () {
var current = global.my && global.my.nested && global.my.nested.bundle;
var exports = (global.my = global.my || {}, global.my.nested = global.my.nested || {}, global.my.nested.bundle = {});
factory(exports, global.external1, global.external2);
exports.noConflict = function () { global.my.nested.bundle = current; return exports; };
}()));
}(this, function (exports, external1, external2) { 'use strict';
const x = external1.value1 || external2.value2;
exports.x = x;
Object.defineProperty(exports, '__esModule', { value: true });
})); |
guybedford
approved these changes
Dec 19, 2018
This was referenced Aug 31, 2019
This was referenced Mar 25, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains:
Are tests included?
Breaking Changes?
List any relevant issue numbers:
Description
With the recent changes to the UMD wrapper, several bugs were introduced. This addresses this and includes a thorough test suite of 240 tests (of which 84 were broken, some event before the latest refactorings!) that actually runs the UMD wrapper with different combinations of options and different scenarios:
options:
environments:
tests:
All tests are green now and the wrapper could be further refined. Moreover,
thiswill now have precedence overselfin iife mode and the check has been moved into the wrapper code, e.g.A similar treatment is done for the IIFE wrappers.