@rollup/plugin-commonjs 21.0.1 → 21.0.2
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 +8 -0
- package/dist/index.es.js +27 -27
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +27 -27
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -161,7 +161,7 @@ export function commonjsRegister (path, loader) {
|
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
export function commonjsRegisterOrShort (path, to) {
|
|
164
|
-
|
|
164
|
+
var resolvedPath = commonjsResolveImpl(path, null, true);
|
|
165
165
|
if (resolvedPath !== null && DYNAMIC_REQUIRE_CACHE[resolvedPath]) {
|
|
166
166
|
DYNAMIC_REQUIRE_CACHE[path] = DYNAMIC_REQUIRE_CACHE[resolvedPath];
|
|
167
167
|
} else {
|
|
@@ -169,24 +169,24 @@ export function commonjsRegisterOrShort (path, to) {
|
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
172
|
+
var DYNAMIC_REQUIRE_LOADERS = Object.create(null);
|
|
173
|
+
var DYNAMIC_REQUIRE_CACHE = Object.create(null);
|
|
174
|
+
var DYNAMIC_REQUIRE_SHORTS = Object.create(null);
|
|
175
|
+
var DEFAULT_PARENT_MODULE = {
|
|
176
176
|
id: '<' + 'rollup>', exports: {}, parent: undefined, filename: null, loaded: false, children: [], paths: []
|
|
177
177
|
};
|
|
178
|
-
|
|
178
|
+
var CHECKED_EXTENSIONS = ['', '.js', '.json'];
|
|
179
179
|
|
|
180
180
|
function normalize (path) {
|
|
181
181
|
path = path.replace(/\\\\/g, '/');
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
for (
|
|
182
|
+
var parts = path.split('/');
|
|
183
|
+
var slashed = parts[0] === '';
|
|
184
|
+
for (var i = 1; i < parts.length; i++) {
|
|
185
185
|
if (parts[i] === '.' || parts[i] === '') {
|
|
186
186
|
parts.splice(i--, 1);
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
|
-
for (
|
|
189
|
+
for (var i = 1; i < parts.length; i++) {
|
|
190
190
|
if (parts[i] !== '..') continue;
|
|
191
191
|
if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') {
|
|
192
192
|
parts.splice(--i, 2);
|
|
@@ -204,9 +204,9 @@ function normalize (path) {
|
|
|
204
204
|
function join () {
|
|
205
205
|
if (arguments.length === 0)
|
|
206
206
|
return '.';
|
|
207
|
-
|
|
208
|
-
for (
|
|
209
|
-
|
|
207
|
+
var joined;
|
|
208
|
+
for (var i = 0; i < arguments.length; ++i) {
|
|
209
|
+
var arg = arguments[i];
|
|
210
210
|
if (arg.length > 0) {
|
|
211
211
|
if (joined === undefined)
|
|
212
212
|
joined = arg;
|
|
@@ -221,9 +221,9 @@ function join () {
|
|
|
221
221
|
}
|
|
222
222
|
|
|
223
223
|
function isPossibleNodeModulesPath (modulePath) {
|
|
224
|
-
|
|
224
|
+
var c0 = modulePath[0];
|
|
225
225
|
if (c0 === '/' || c0 === '\\\\') return false;
|
|
226
|
-
|
|
226
|
+
var c1 = modulePath[1], c2 = modulePath[2];
|
|
227
227
|
if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) ||
|
|
228
228
|
(c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false;
|
|
229
229
|
if (c1 === ':' && (c2 === '/' || c2 === '\\\\'))
|
|
@@ -235,9 +235,9 @@ function dirname (path) {
|
|
|
235
235
|
if (path.length === 0)
|
|
236
236
|
return '.';
|
|
237
237
|
|
|
238
|
-
|
|
238
|
+
var i = path.length - 1;
|
|
239
239
|
while (i > 0) {
|
|
240
|
-
|
|
240
|
+
var c = path.charCodeAt(i);
|
|
241
241
|
if ((c === 47 || c === 92) && i !== path.length - 1)
|
|
242
242
|
break;
|
|
243
243
|
i--;
|
|
@@ -253,9 +253,9 @@ function dirname (path) {
|
|
|
253
253
|
}
|
|
254
254
|
|
|
255
255
|
export function commonjsResolveImpl (path, originalModuleDir, testCache) {
|
|
256
|
-
|
|
256
|
+
var shouldTryNodeModules = isPossibleNodeModulesPath(path);
|
|
257
257
|
path = normalize(path);
|
|
258
|
-
|
|
258
|
+
var relPath;
|
|
259
259
|
if (path[0] === '/') {
|
|
260
260
|
originalModuleDir = '/';
|
|
261
261
|
}
|
|
@@ -272,8 +272,8 @@ export function commonjsResolveImpl (path, originalModuleDir, testCache) {
|
|
|
272
272
|
break; // Travelled too far up, avoid infinite loop
|
|
273
273
|
}
|
|
274
274
|
|
|
275
|
-
for (
|
|
276
|
-
|
|
275
|
+
for (var extensionIndex = 0; extensionIndex < CHECKED_EXTENSIONS.length; extensionIndex++) {
|
|
276
|
+
var resolvedPath = relPath + CHECKED_EXTENSIONS[extensionIndex];
|
|
277
277
|
if (DYNAMIC_REQUIRE_CACHE[resolvedPath]) {
|
|
278
278
|
return resolvedPath;
|
|
279
279
|
}
|
|
@@ -285,7 +285,7 @@ export function commonjsResolveImpl (path, originalModuleDir, testCache) {
|
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
287
|
if (!shouldTryNodeModules) break;
|
|
288
|
-
|
|
288
|
+
var nextDir = normalize(originalModuleDir + '/..');
|
|
289
289
|
if (nextDir === originalModuleDir) break;
|
|
290
290
|
originalModuleDir = nextDir;
|
|
291
291
|
}
|
|
@@ -293,7 +293,7 @@ export function commonjsResolveImpl (path, originalModuleDir, testCache) {
|
|
|
293
293
|
}
|
|
294
294
|
|
|
295
295
|
export function commonjsResolve (path, originalModuleDir) {
|
|
296
|
-
|
|
296
|
+
var resolvedPath = commonjsResolveImpl(path, originalModuleDir);
|
|
297
297
|
if (resolvedPath !== null) {
|
|
298
298
|
return resolvedPath;
|
|
299
299
|
}
|
|
@@ -301,18 +301,18 @@ export function commonjsResolve (path, originalModuleDir) {
|
|
|
301
301
|
}
|
|
302
302
|
|
|
303
303
|
export function commonjsRequire (path, originalModuleDir) {
|
|
304
|
-
|
|
304
|
+
var resolvedPath = commonjsResolveImpl(path, originalModuleDir, true);
|
|
305
305
|
if (resolvedPath !== null) {
|
|
306
|
-
|
|
306
|
+
var cachedModule = DYNAMIC_REQUIRE_CACHE[resolvedPath];
|
|
307
307
|
if (cachedModule) return cachedModule.exports;
|
|
308
|
-
|
|
308
|
+
var shortTo = DYNAMIC_REQUIRE_SHORTS[resolvedPath];
|
|
309
309
|
if (shortTo) {
|
|
310
310
|
cachedModule = DYNAMIC_REQUIRE_CACHE[shortTo];
|
|
311
311
|
if (cachedModule)
|
|
312
312
|
return cachedModule.exports;
|
|
313
313
|
resolvedPath = commonjsResolveImpl(shortTo, null, true);
|
|
314
314
|
}
|
|
315
|
-
|
|
315
|
+
var loader = DYNAMIC_REQUIRE_LOADERS[resolvedPath];
|
|
316
316
|
if (loader) {
|
|
317
317
|
DYNAMIC_REQUIRE_CACHE[resolvedPath] = cachedModule = {
|
|
318
318
|
id: resolvedPath,
|