@rollup/plugin-commonjs 21.0.1 → 21.1.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/CHANGELOG.md +24 -0
- package/README.md +1 -1
- package/dist/index.es.js +34 -30
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +34 -30
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/types/index.d.ts +8 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @rollup/plugin-commonjs ChangeLog
|
|
2
2
|
|
|
3
|
+
## v21.1.0
|
|
4
|
+
|
|
5
|
+
_2022-04-15_
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
- feat: make defaultIsModuleExports as funtion to config defaultIsModuleExports for each source (#1052)
|
|
10
|
+
|
|
11
|
+
## v21.0.3
|
|
12
|
+
|
|
13
|
+
_2022-03-27_
|
|
14
|
+
|
|
15
|
+
### Updates
|
|
16
|
+
|
|
17
|
+
- docs: sync required rollup version (#1118)
|
|
18
|
+
|
|
19
|
+
## v21.0.2
|
|
20
|
+
|
|
21
|
+
_2022-02-23_
|
|
22
|
+
|
|
23
|
+
### Updates
|
|
24
|
+
|
|
25
|
+
- chore: transpile dynamic helper to ES5 (#1082)
|
|
26
|
+
|
|
3
27
|
## v21.0.1
|
|
4
28
|
|
|
5
29
|
_2021-10-19_
|
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
## Requirements
|
|
15
15
|
|
|
16
|
-
This plugin requires an [LTS](https://github.com/nodejs/Release) Node version (v8.0.0+) and Rollup
|
|
16
|
+
This plugin requires an [LTS](https://github.com/nodejs/Release) Node version (v8.0.0+) and Rollup v2.38.3+.
|
|
17
17
|
|
|
18
18
|
## Install
|
|
19
19
|
|
package/dist/index.es.js
CHANGED
|
@@ -152,7 +152,7 @@ export function commonjsRegister (path, loader) {
|
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
export function commonjsRegisterOrShort (path, to) {
|
|
155
|
-
|
|
155
|
+
var resolvedPath = commonjsResolveImpl(path, null, true);
|
|
156
156
|
if (resolvedPath !== null && DYNAMIC_REQUIRE_CACHE[resolvedPath]) {
|
|
157
157
|
DYNAMIC_REQUIRE_CACHE[path] = DYNAMIC_REQUIRE_CACHE[resolvedPath];
|
|
158
158
|
} else {
|
|
@@ -160,24 +160,24 @@ export function commonjsRegisterOrShort (path, to) {
|
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
163
|
+
var DYNAMIC_REQUIRE_LOADERS = Object.create(null);
|
|
164
|
+
var DYNAMIC_REQUIRE_CACHE = Object.create(null);
|
|
165
|
+
var DYNAMIC_REQUIRE_SHORTS = Object.create(null);
|
|
166
|
+
var DEFAULT_PARENT_MODULE = {
|
|
167
167
|
id: '<' + 'rollup>', exports: {}, parent: undefined, filename: null, loaded: false, children: [], paths: []
|
|
168
168
|
};
|
|
169
|
-
|
|
169
|
+
var CHECKED_EXTENSIONS = ['', '.js', '.json'];
|
|
170
170
|
|
|
171
171
|
function normalize (path) {
|
|
172
172
|
path = path.replace(/\\\\/g, '/');
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
for (
|
|
173
|
+
var parts = path.split('/');
|
|
174
|
+
var slashed = parts[0] === '';
|
|
175
|
+
for (var i = 1; i < parts.length; i++) {
|
|
176
176
|
if (parts[i] === '.' || parts[i] === '') {
|
|
177
177
|
parts.splice(i--, 1);
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
|
-
for (
|
|
180
|
+
for (var i = 1; i < parts.length; i++) {
|
|
181
181
|
if (parts[i] !== '..') continue;
|
|
182
182
|
if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') {
|
|
183
183
|
parts.splice(--i, 2);
|
|
@@ -195,9 +195,9 @@ function normalize (path) {
|
|
|
195
195
|
function join () {
|
|
196
196
|
if (arguments.length === 0)
|
|
197
197
|
return '.';
|
|
198
|
-
|
|
199
|
-
for (
|
|
200
|
-
|
|
198
|
+
var joined;
|
|
199
|
+
for (var i = 0; i < arguments.length; ++i) {
|
|
200
|
+
var arg = arguments[i];
|
|
201
201
|
if (arg.length > 0) {
|
|
202
202
|
if (joined === undefined)
|
|
203
203
|
joined = arg;
|
|
@@ -212,9 +212,9 @@ function join () {
|
|
|
212
212
|
}
|
|
213
213
|
|
|
214
214
|
function isPossibleNodeModulesPath (modulePath) {
|
|
215
|
-
|
|
215
|
+
var c0 = modulePath[0];
|
|
216
216
|
if (c0 === '/' || c0 === '\\\\') return false;
|
|
217
|
-
|
|
217
|
+
var c1 = modulePath[1], c2 = modulePath[2];
|
|
218
218
|
if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) ||
|
|
219
219
|
(c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false;
|
|
220
220
|
if (c1 === ':' && (c2 === '/' || c2 === '\\\\'))
|
|
@@ -226,9 +226,9 @@ function dirname (path) {
|
|
|
226
226
|
if (path.length === 0)
|
|
227
227
|
return '.';
|
|
228
228
|
|
|
229
|
-
|
|
229
|
+
var i = path.length - 1;
|
|
230
230
|
while (i > 0) {
|
|
231
|
-
|
|
231
|
+
var c = path.charCodeAt(i);
|
|
232
232
|
if ((c === 47 || c === 92) && i !== path.length - 1)
|
|
233
233
|
break;
|
|
234
234
|
i--;
|
|
@@ -244,9 +244,9 @@ function dirname (path) {
|
|
|
244
244
|
}
|
|
245
245
|
|
|
246
246
|
export function commonjsResolveImpl (path, originalModuleDir, testCache) {
|
|
247
|
-
|
|
247
|
+
var shouldTryNodeModules = isPossibleNodeModulesPath(path);
|
|
248
248
|
path = normalize(path);
|
|
249
|
-
|
|
249
|
+
var relPath;
|
|
250
250
|
if (path[0] === '/') {
|
|
251
251
|
originalModuleDir = '/';
|
|
252
252
|
}
|
|
@@ -263,8 +263,8 @@ export function commonjsResolveImpl (path, originalModuleDir, testCache) {
|
|
|
263
263
|
break; // Travelled too far up, avoid infinite loop
|
|
264
264
|
}
|
|
265
265
|
|
|
266
|
-
for (
|
|
267
|
-
|
|
266
|
+
for (var extensionIndex = 0; extensionIndex < CHECKED_EXTENSIONS.length; extensionIndex++) {
|
|
267
|
+
var resolvedPath = relPath + CHECKED_EXTENSIONS[extensionIndex];
|
|
268
268
|
if (DYNAMIC_REQUIRE_CACHE[resolvedPath]) {
|
|
269
269
|
return resolvedPath;
|
|
270
270
|
}
|
|
@@ -276,7 +276,7 @@ export function commonjsResolveImpl (path, originalModuleDir, testCache) {
|
|
|
276
276
|
}
|
|
277
277
|
}
|
|
278
278
|
if (!shouldTryNodeModules) break;
|
|
279
|
-
|
|
279
|
+
var nextDir = normalize(originalModuleDir + '/..');
|
|
280
280
|
if (nextDir === originalModuleDir) break;
|
|
281
281
|
originalModuleDir = nextDir;
|
|
282
282
|
}
|
|
@@ -284,7 +284,7 @@ export function commonjsResolveImpl (path, originalModuleDir, testCache) {
|
|
|
284
284
|
}
|
|
285
285
|
|
|
286
286
|
export function commonjsResolve (path, originalModuleDir) {
|
|
287
|
-
|
|
287
|
+
var resolvedPath = commonjsResolveImpl(path, originalModuleDir);
|
|
288
288
|
if (resolvedPath !== null) {
|
|
289
289
|
return resolvedPath;
|
|
290
290
|
}
|
|
@@ -292,18 +292,18 @@ export function commonjsResolve (path, originalModuleDir) {
|
|
|
292
292
|
}
|
|
293
293
|
|
|
294
294
|
export function commonjsRequire (path, originalModuleDir) {
|
|
295
|
-
|
|
295
|
+
var resolvedPath = commonjsResolveImpl(path, originalModuleDir, true);
|
|
296
296
|
if (resolvedPath !== null) {
|
|
297
|
-
|
|
297
|
+
var cachedModule = DYNAMIC_REQUIRE_CACHE[resolvedPath];
|
|
298
298
|
if (cachedModule) return cachedModule.exports;
|
|
299
|
-
|
|
299
|
+
var shortTo = DYNAMIC_REQUIRE_SHORTS[resolvedPath];
|
|
300
300
|
if (shortTo) {
|
|
301
301
|
cachedModule = DYNAMIC_REQUIRE_CACHE[shortTo];
|
|
302
302
|
if (cachedModule)
|
|
303
303
|
return cachedModule.exports;
|
|
304
304
|
resolvedPath = commonjsResolveImpl(shortTo, null, true);
|
|
305
305
|
}
|
|
306
|
-
|
|
306
|
+
var loader = DYNAMIC_REQUIRE_LOADERS[resolvedPath];
|
|
307
307
|
if (loader) {
|
|
308
308
|
DYNAMIC_REQUIRE_CACHE[resolvedPath] = cachedModule = {
|
|
309
309
|
id: resolvedPath,
|
|
@@ -1668,6 +1668,7 @@ function commonjs(options = {}) {
|
|
|
1668
1668
|
ignoreGlobal,
|
|
1669
1669
|
ignoreDynamicRequires,
|
|
1670
1670
|
requireReturnsDefault: requireReturnsDefaultOption,
|
|
1671
|
+
defaultIsModuleExports: defaultIsModuleExportsOption,
|
|
1671
1672
|
esmExternals
|
|
1672
1673
|
} = options;
|
|
1673
1674
|
const getRequireReturnsDefault =
|
|
@@ -1681,8 +1682,11 @@ function commonjs(options = {}) {
|
|
|
1681
1682
|
: Array.isArray(esmExternals)
|
|
1682
1683
|
? ((esmExternalIds = new Set(esmExternals)), (id) => esmExternalIds.has(id))
|
|
1683
1684
|
: () => esmExternals;
|
|
1684
|
-
const
|
|
1685
|
-
typeof
|
|
1685
|
+
const getDefaultIsModuleExports =
|
|
1686
|
+
typeof defaultIsModuleExportsOption === 'function'
|
|
1687
|
+
? defaultIsModuleExportsOption
|
|
1688
|
+
: () =>
|
|
1689
|
+
typeof defaultIsModuleExportsOption === 'boolean' ? defaultIsModuleExportsOption : 'auto';
|
|
1686
1690
|
|
|
1687
1691
|
const { dynamicRequireModuleSet, dynamicRequireModuleDirPaths } = getDynamicRequirePaths(
|
|
1688
1692
|
options.dynamicRequireTargets
|
|
@@ -1771,7 +1775,7 @@ function commonjs(options = {}) {
|
|
|
1771
1775
|
disableWrap,
|
|
1772
1776
|
commonDir,
|
|
1773
1777
|
ast,
|
|
1774
|
-
|
|
1778
|
+
getDefaultIsModuleExports(id)
|
|
1775
1779
|
);
|
|
1776
1780
|
}
|
|
1777
1781
|
|