requirejs-esm 4.3.0 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/bin/esm2requirejs.js +3 -0
- package/dist/api.js +91 -80
- package/dist/api.js.map +1 -1
- package/dist/plugin.js +88 -73
- package/dist/plugin.js.map +1 -1
- package/package.json +6 -6
- package/src/api.d.ts +1 -0
- package/src/plugin.js +4 -0
- package/src/transform.js +4 -0
- package/src/transformer/esm.js +41 -35
package/dist/plugin.js
CHANGED
|
@@ -10632,7 +10632,7 @@
|
|
|
10632
10632
|
var isInstance = false;
|
|
10633
10633
|
try {
|
|
10634
10634
|
isInstance = this instanceof a;
|
|
10635
|
-
} catch {}
|
|
10635
|
+
} catch (e) {}
|
|
10636
10636
|
if (isInstance) {
|
|
10637
10637
|
return Reflect.construct(f, arguments, this.constructor);
|
|
10638
10638
|
}
|
|
@@ -10806,7 +10806,7 @@
|
|
|
10806
10806
|
function requireLib () {
|
|
10807
10807
|
if (hasRequiredLib) return lib;
|
|
10808
10808
|
hasRequiredLib = 1;
|
|
10809
|
-
(function (exports
|
|
10809
|
+
(function (exports) {
|
|
10810
10810
|
|
|
10811
10811
|
function _(message, opts) {
|
|
10812
10812
|
return `${opts && opts.context ? opts.context : "Value"} ${message}.`;
|
|
@@ -10949,31 +10949,31 @@
|
|
|
10949
10949
|
};
|
|
10950
10950
|
}
|
|
10951
10951
|
|
|
10952
|
-
exports
|
|
10952
|
+
exports.any = V => {
|
|
10953
10953
|
return V;
|
|
10954
10954
|
};
|
|
10955
10955
|
|
|
10956
|
-
exports
|
|
10956
|
+
exports.void = function () {
|
|
10957
10957
|
return undefined;
|
|
10958
10958
|
};
|
|
10959
10959
|
|
|
10960
|
-
exports
|
|
10960
|
+
exports.boolean = function (val) {
|
|
10961
10961
|
return !!val;
|
|
10962
10962
|
};
|
|
10963
10963
|
|
|
10964
|
-
exports
|
|
10965
|
-
exports
|
|
10964
|
+
exports.byte = createIntegerConversion(8, { unsigned: false });
|
|
10965
|
+
exports.octet = createIntegerConversion(8, { unsigned: true });
|
|
10966
10966
|
|
|
10967
|
-
exports
|
|
10968
|
-
exports
|
|
10967
|
+
exports.short = createIntegerConversion(16, { unsigned: false });
|
|
10968
|
+
exports["unsigned short"] = createIntegerConversion(16, { unsigned: true });
|
|
10969
10969
|
|
|
10970
|
-
exports
|
|
10971
|
-
exports
|
|
10970
|
+
exports.long = createIntegerConversion(32, { unsigned: false });
|
|
10971
|
+
exports["unsigned long"] = createIntegerConversion(32, { unsigned: true });
|
|
10972
10972
|
|
|
10973
|
-
exports
|
|
10974
|
-
exports
|
|
10973
|
+
exports["long long"] = createIntegerConversion(64, { unsigned: false });
|
|
10974
|
+
exports["unsigned long long"] = createIntegerConversion(64, { unsigned: true });
|
|
10975
10975
|
|
|
10976
|
-
exports
|
|
10976
|
+
exports.double = (V, opts) => {
|
|
10977
10977
|
const x = +V;
|
|
10978
10978
|
|
|
10979
10979
|
if (!Number.isFinite(x)) {
|
|
@@ -10983,13 +10983,13 @@
|
|
|
10983
10983
|
return x;
|
|
10984
10984
|
};
|
|
10985
10985
|
|
|
10986
|
-
exports
|
|
10986
|
+
exports["unrestricted double"] = V => {
|
|
10987
10987
|
const x = +V;
|
|
10988
10988
|
|
|
10989
10989
|
return x;
|
|
10990
10990
|
};
|
|
10991
10991
|
|
|
10992
|
-
exports
|
|
10992
|
+
exports.float = (V, opts) => {
|
|
10993
10993
|
const x = +V;
|
|
10994
10994
|
|
|
10995
10995
|
if (!Number.isFinite(x)) {
|
|
@@ -11009,7 +11009,7 @@
|
|
|
11009
11009
|
return y;
|
|
11010
11010
|
};
|
|
11011
11011
|
|
|
11012
|
-
exports
|
|
11012
|
+
exports["unrestricted float"] = V => {
|
|
11013
11013
|
const x = +V;
|
|
11014
11014
|
|
|
11015
11015
|
if (isNaN(x)) {
|
|
@@ -11023,7 +11023,7 @@
|
|
|
11023
11023
|
return Math.fround(x);
|
|
11024
11024
|
};
|
|
11025
11025
|
|
|
11026
|
-
exports
|
|
11026
|
+
exports.DOMString = function (V, opts) {
|
|
11027
11027
|
if (opts === undefined) {
|
|
11028
11028
|
opts = {};
|
|
11029
11029
|
}
|
|
@@ -11039,8 +11039,8 @@
|
|
|
11039
11039
|
return String(V);
|
|
11040
11040
|
};
|
|
11041
11041
|
|
|
11042
|
-
exports
|
|
11043
|
-
const x = exports
|
|
11042
|
+
exports.ByteString = (V, opts) => {
|
|
11043
|
+
const x = exports.DOMString(V, opts);
|
|
11044
11044
|
let c;
|
|
11045
11045
|
for (let i = 0; (c = x.codePointAt(i)) !== undefined; ++i) {
|
|
11046
11046
|
if (c > 255) {
|
|
@@ -11051,8 +11051,8 @@
|
|
|
11051
11051
|
return x;
|
|
11052
11052
|
};
|
|
11053
11053
|
|
|
11054
|
-
exports
|
|
11055
|
-
const S = exports
|
|
11054
|
+
exports.USVString = (V, opts) => {
|
|
11055
|
+
const S = exports.DOMString(V, opts);
|
|
11056
11056
|
const n = S.length;
|
|
11057
11057
|
const U = [];
|
|
11058
11058
|
for (let i = 0; i < n; ++i) {
|
|
@@ -11079,7 +11079,7 @@
|
|
|
11079
11079
|
return U.join("");
|
|
11080
11080
|
};
|
|
11081
11081
|
|
|
11082
|
-
exports
|
|
11082
|
+
exports.object = (V, opts) => {
|
|
11083
11083
|
if (type(V) !== "Object") {
|
|
11084
11084
|
throw new TypeError(_("is not an object", opts));
|
|
11085
11085
|
}
|
|
@@ -11106,7 +11106,7 @@
|
|
|
11106
11106
|
].forEach(func => {
|
|
11107
11107
|
const name = func.name;
|
|
11108
11108
|
const article = /^[AEIOU]/.test(name) ? "an" : "a";
|
|
11109
|
-
exports
|
|
11109
|
+
exports[name] = (V, opts) => {
|
|
11110
11110
|
if (!(V instanceof func)) {
|
|
11111
11111
|
throw new TypeError(_(`is not ${article} ${name} object`, opts));
|
|
11112
11112
|
}
|
|
@@ -11117,7 +11117,7 @@
|
|
|
11117
11117
|
|
|
11118
11118
|
// Common definitions
|
|
11119
11119
|
|
|
11120
|
-
exports
|
|
11120
|
+
exports.ArrayBufferView = (V, opts) => {
|
|
11121
11121
|
if (!ArrayBuffer.isView(V)) {
|
|
11122
11122
|
throw new TypeError(_("is not a view on an ArrayBuffer object", opts));
|
|
11123
11123
|
}
|
|
@@ -11125,7 +11125,7 @@
|
|
|
11125
11125
|
return V;
|
|
11126
11126
|
};
|
|
11127
11127
|
|
|
11128
|
-
exports
|
|
11128
|
+
exports.BufferSource = (V, opts) => {
|
|
11129
11129
|
if (!(ArrayBuffer.isView(V) || V instanceof ArrayBuffer)) {
|
|
11130
11130
|
throw new TypeError(_("is not an ArrayBuffer object or a view on one", opts));
|
|
11131
11131
|
}
|
|
@@ -11133,11 +11133,11 @@
|
|
|
11133
11133
|
return V;
|
|
11134
11134
|
};
|
|
11135
11135
|
|
|
11136
|
-
exports
|
|
11136
|
+
exports.DOMTimeStamp = exports["unsigned long long"];
|
|
11137
11137
|
|
|
11138
|
-
exports
|
|
11138
|
+
exports.Function = convertCallbackFunction;
|
|
11139
11139
|
|
|
11140
|
-
exports
|
|
11140
|
+
exports.VoidFunction = convertCallbackFunction;
|
|
11141
11141
|
} (lib));
|
|
11142
11142
|
return lib;
|
|
11143
11143
|
}
|
|
@@ -11149,7 +11149,7 @@
|
|
|
11149
11149
|
function requireUtils () {
|
|
11150
11150
|
if (hasRequiredUtils) return utils.exports;
|
|
11151
11151
|
hasRequiredUtils = 1;
|
|
11152
|
-
(function (module, exports
|
|
11152
|
+
(function (module, exports) {
|
|
11153
11153
|
|
|
11154
11154
|
// Returns "Type(value) is Object" in ES terminology.
|
|
11155
11155
|
function isObject(value) {
|
|
@@ -79239,7 +79239,7 @@
|
|
|
79239
79239
|
function requireLodash_sortby () {
|
|
79240
79240
|
if (hasRequiredLodash_sortby) return lodash_sortby.exports;
|
|
79241
79241
|
hasRequiredLodash_sortby = 1;
|
|
79242
|
-
(function (module, exports
|
|
79242
|
+
(function (module, exports) {
|
|
79243
79243
|
/** Used as the size to enable large array optimizations. */
|
|
79244
79244
|
var LARGE_ARRAY_SIZE = 200;
|
|
79245
79245
|
|
|
@@ -79333,7 +79333,7 @@
|
|
|
79333
79333
|
var root = freeGlobal || freeSelf || Function('return this')();
|
|
79334
79334
|
|
|
79335
79335
|
/** Detect free variable `exports`. */
|
|
79336
|
-
var freeExports = exports
|
|
79336
|
+
var freeExports = exports && !exports.nodeType && exports;
|
|
79337
79337
|
|
|
79338
79338
|
/** Detect free variable `module`. */
|
|
79339
79339
|
var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
|
|
@@ -84122,15 +84122,15 @@
|
|
|
84122
84122
|
function requireBinarySearch () {
|
|
84123
84123
|
if (hasRequiredBinarySearch) return binarySearch;
|
|
84124
84124
|
hasRequiredBinarySearch = 1;
|
|
84125
|
-
(function (exports
|
|
84125
|
+
(function (exports) {
|
|
84126
84126
|
/*
|
|
84127
84127
|
* Copyright 2011 Mozilla Foundation and contributors
|
|
84128
84128
|
* Licensed under the New BSD license. See LICENSE or:
|
|
84129
84129
|
* http://opensource.org/licenses/BSD-3-Clause
|
|
84130
84130
|
*/
|
|
84131
84131
|
|
|
84132
|
-
exports
|
|
84133
|
-
exports
|
|
84132
|
+
exports.GREATEST_LOWER_BOUND = 1;
|
|
84133
|
+
exports.LEAST_UPPER_BOUND = 2;
|
|
84134
84134
|
|
|
84135
84135
|
/**
|
|
84136
84136
|
* Recursive implementation of binary search.
|
|
@@ -84169,7 +84169,7 @@
|
|
|
84169
84169
|
|
|
84170
84170
|
// The exact needle element was not found in this haystack. Determine if
|
|
84171
84171
|
// we are in termination case (3) or (2) and return the appropriate thing.
|
|
84172
|
-
if (aBias == exports
|
|
84172
|
+
if (aBias == exports.LEAST_UPPER_BOUND) {
|
|
84173
84173
|
return aHigh < aHaystack.length ? aHigh : -1;
|
|
84174
84174
|
}
|
|
84175
84175
|
return mid;
|
|
@@ -84182,7 +84182,7 @@
|
|
|
84182
84182
|
}
|
|
84183
84183
|
|
|
84184
84184
|
// we are in termination case (3) or (2) and return the appropriate thing.
|
|
84185
|
-
if (aBias == exports
|
|
84185
|
+
if (aBias == exports.LEAST_UPPER_BOUND) {
|
|
84186
84186
|
return mid;
|
|
84187
84187
|
}
|
|
84188
84188
|
return aLow < 0 ? -1 : aLow;
|
|
@@ -84206,13 +84206,13 @@
|
|
|
84206
84206
|
* searching for, respectively, if the exact element cannot be found.
|
|
84207
84207
|
* Defaults to 'binarySearch.GREATEST_LOWER_BOUND'.
|
|
84208
84208
|
*/
|
|
84209
|
-
exports
|
|
84209
|
+
exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {
|
|
84210
84210
|
if (aHaystack.length === 0) {
|
|
84211
84211
|
return -1;
|
|
84212
84212
|
}
|
|
84213
84213
|
|
|
84214
84214
|
let index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack,
|
|
84215
|
-
aCompare, aBias || exports
|
|
84215
|
+
aCompare, aBias || exports.GREATEST_LOWER_BOUND);
|
|
84216
84216
|
if (index < 0) {
|
|
84217
84217
|
return -1;
|
|
84218
84218
|
}
|
|
@@ -86615,6 +86615,7 @@
|
|
|
86615
86615
|
program
|
|
86616
86616
|
});
|
|
86617
86617
|
|
|
86618
|
+
const { splitDefaultNamedDeclarations } = options;
|
|
86618
86619
|
const { body } = program;
|
|
86619
86620
|
let { length } = body;
|
|
86620
86621
|
|
|
@@ -86676,46 +86677,52 @@
|
|
|
86676
86677
|
|
|
86677
86678
|
// expression after keyword default
|
|
86678
86679
|
const { declaration } = statement;
|
|
86680
|
+
// export default X
|
|
86679
86681
|
let exportValue = declaration;
|
|
86680
|
-
|
|
86681
|
-
|
|
86682
|
-
|
|
86683
|
-
|
|
86684
|
-
|
|
86685
|
-
|
|
86686
|
-
|
|
86687
|
-
|
|
86688
|
-
|
|
86689
|
-
|
|
86690
|
-
|
|
86691
|
-
|
|
86692
|
-
|
|
86693
|
-
|
|
86694
|
-
|
|
86695
|
-
// needReturnExport = false
|
|
86696
|
-
// } else {
|
|
86697
|
-
// exportStat = exportStatement(exportsVar, 'default', className)
|
|
86698
|
-
// }
|
|
86699
|
-
|
|
86700
|
-
// program.pushContainer('body', [exportStat])
|
|
86701
|
-
// needExportExpression = false
|
|
86702
|
-
// } else {
|
|
86703
|
-
// exportValue = toExpression(classNode)
|
|
86704
|
-
// }
|
|
86682
|
+
let keepDeclaration;
|
|
86683
|
+
|
|
86684
|
+
if (declaration.type === 'FunctionDeclaration' ||
|
|
86685
|
+
declaration.type === 'ClassDeclaration') {
|
|
86686
|
+
const { id } = declaration;
|
|
86687
|
+
if (id && splitDefaultNamedDeclarations) {
|
|
86688
|
+
// export default function X() {}
|
|
86689
|
+
// export default class X {}
|
|
86690
|
+
exportValue = identifier(declaration.id.name);
|
|
86691
|
+
keepDeclaration = true;
|
|
86692
|
+
} else {
|
|
86693
|
+
// export default function () {}
|
|
86694
|
+
// export default class {}
|
|
86695
|
+
exportValue = toExpression(declaration);
|
|
86696
|
+
}
|
|
86705
86697
|
}
|
|
86706
86698
|
|
|
86707
|
-
|
|
86708
|
-
let exportStat;
|
|
86699
|
+
let exportStat;
|
|
86709
86700
|
|
|
86710
|
-
|
|
86711
|
-
|
|
86712
|
-
|
|
86713
|
-
|
|
86714
|
-
|
|
86715
|
-
|
|
86701
|
+
if (i + 1 === length && isOnlyDefaultExport) {
|
|
86702
|
+
exportStat = returnStatement(exportValue);
|
|
86703
|
+
needReturnExport = false;
|
|
86704
|
+
} else {
|
|
86705
|
+
exportStat = exportStatement(exportsVar, 'default', exportValue);
|
|
86706
|
+
}
|
|
86716
86707
|
|
|
86717
|
-
|
|
86708
|
+
// This changes the original code by putting the name of the exported
|
|
86709
|
+
// function or class to the module scope. Being able to access the class
|
|
86710
|
+
// by name simplifies other AST manipulations, which would have to be more
|
|
86711
|
+
// complicated. Or the developer would have to help the manipulator
|
|
86712
|
+
// by separating the export expression to a declaration and an export
|
|
86713
|
+
// of an identifier. Use it if it doesn't break your code.
|
|
86714
|
+
//
|
|
86715
|
+
// // original, the name X is not in the module scope
|
|
86716
|
+
// export default class X {}
|
|
86717
|
+
//
|
|
86718
|
+
// // converted, the name X is in the module scope
|
|
86719
|
+
// class X {}
|
|
86720
|
+
// export default X
|
|
86721
|
+
if (keepDeclaration) {
|
|
86722
|
+
body.splice(i++, 0, declaration);
|
|
86723
|
+
++length;
|
|
86718
86724
|
}
|
|
86725
|
+
body[i] = exportStat;
|
|
86719
86726
|
}
|
|
86720
86727
|
|
|
86721
86728
|
// export {x as y}
|
|
@@ -87023,6 +87030,9 @@
|
|
|
87023
87030
|
// Do not insert `"use strict"` expression to the AMD modules. You'd set it
|
|
87024
87031
|
// to `false` if your bundler inserts `"use strict"` to the outer scope.
|
|
87025
87032
|
useStrict,
|
|
87033
|
+
// Split `export default class A {}` to `class A {}; export default A`
|
|
87034
|
+
// to trade easier AST manipulation for 100% code compatibility.
|
|
87035
|
+
splitDefaultNamedDeclarations,
|
|
87026
87036
|
// Enable source maps, can be an object with booleans { inline, content }.
|
|
87027
87037
|
// If set to true, the object will be set to { inline: true, content: true }.
|
|
87028
87038
|
sourceMap,
|
|
@@ -87050,6 +87060,7 @@
|
|
|
87050
87060
|
originalResolvePath: resolvePath$1,
|
|
87051
87061
|
useStrict,
|
|
87052
87062
|
skipIfNoImportExport,
|
|
87063
|
+
splitDefaultNamedDeclarations,
|
|
87053
87064
|
onBeforeTransform,
|
|
87054
87065
|
onAfterTransform,
|
|
87055
87066
|
onBeforeUpdate,
|
|
@@ -87103,6 +87114,9 @@
|
|
|
87103
87114
|
// Do not insert `"use strict"` expression to the AMD modules. You'd set it
|
|
87104
87115
|
// to `false` if your bundler inserts `"use strict"` to the outer scope.
|
|
87105
87116
|
useStrict,
|
|
87117
|
+
// Split `export default class A {}` to `class A {}; export default A`
|
|
87118
|
+
// to trade easier AST manipulation for 100% code compatibility.
|
|
87119
|
+
splitDefaultNamedDeclarations,
|
|
87106
87120
|
// Boolean or object with booleans { inline, content }.
|
|
87107
87121
|
sourceMap,
|
|
87108
87122
|
// Enable console logging.
|
|
@@ -87193,6 +87207,7 @@
|
|
|
87193
87207
|
/*ecmaVersion,*/
|
|
87194
87208
|
useStrict,
|
|
87195
87209
|
skipIfNoImportExport,
|
|
87210
|
+
splitDefaultNamedDeclarations,
|
|
87196
87211
|
// Always produce the source maps when transpiling in the browser, otherwise
|
|
87197
87212
|
// the debugging would me impossible. When building and bundling, check if
|
|
87198
87213
|
// the source maps were enabled for the output.
|