@rollup/plugin-commonjs 19.0.1 → 21.0.1
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 +32 -0
- package/README.md +4 -2
- package/dist/index.es.js +43 -10
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +45 -12
- package/dist/index.js.map +1 -1
- package/package.json +9 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# @rollup/plugin-commonjs ChangeLog
|
|
2
2
|
|
|
3
|
+
## v21.0.1
|
|
4
|
+
|
|
5
|
+
_2021-10-19_
|
|
6
|
+
|
|
7
|
+
### Bugfixes
|
|
8
|
+
|
|
9
|
+
- fix: pass on isEntry and custom resolve options (#1018)
|
|
10
|
+
|
|
11
|
+
## v21.0.0
|
|
12
|
+
|
|
13
|
+
_2021-10-01_
|
|
14
|
+
|
|
15
|
+
### Breaking Changes
|
|
16
|
+
|
|
17
|
+
- fix: use safe default value for ignoreTryCatch (#1005)
|
|
18
|
+
|
|
19
|
+
## v20.0.0
|
|
20
|
+
|
|
21
|
+
_2021-07-30_
|
|
22
|
+
|
|
23
|
+
### Breaking Changes
|
|
24
|
+
|
|
25
|
+
- fix: Correctly infer module name for any separator (#924)
|
|
26
|
+
|
|
27
|
+
## v19.0.2
|
|
28
|
+
|
|
29
|
+
_2021-07-26_
|
|
30
|
+
|
|
31
|
+
### Bugfixes
|
|
32
|
+
|
|
33
|
+
- fix convert module.exports with `__esModule` property(#939) (#942)
|
|
34
|
+
|
|
3
35
|
## v19.0.1
|
|
4
36
|
|
|
5
37
|
_2021-07-15_
|
package/README.md
CHANGED
|
@@ -123,7 +123,7 @@ Sometimes you have to leave require statements unconverted. Pass an array contai
|
|
|
123
123
|
### `ignoreTryCatch`
|
|
124
124
|
|
|
125
125
|
Type: `boolean | 'remove' | string[] | ((id: string) => boolean)`<br>
|
|
126
|
-
Default: `
|
|
126
|
+
Default: `true`
|
|
127
127
|
|
|
128
128
|
In most cases, where `require` calls are inside a `try-catch` clause, they should be left unconverted as it requires an optional dependency that may or may not be installed beside the rolled up package.
|
|
129
129
|
Due to the conversion of `require` to a static `import` - the call is hoisted to the top of the file, outside of the `try-catch` clause.
|
|
@@ -309,7 +309,9 @@ For these situations, you can change Rollup's behaviour either globally or per m
|
|
|
309
309
|
import * as dep$1 from 'dep';
|
|
310
310
|
|
|
311
311
|
function getDefaultExportFromNamespaceIfNotNamed(n) {
|
|
312
|
-
return n && Object.prototype.hasOwnProperty.call(n, 'default') && Object.keys(n).length === 1
|
|
312
|
+
return n && Object.prototype.hasOwnProperty.call(n, 'default') && Object.keys(n).length === 1
|
|
313
|
+
? n['default']
|
|
314
|
+
: n;
|
|
313
315
|
}
|
|
314
316
|
|
|
315
317
|
var dep = getDefaultExportFromNamespaceIfNotNamed(dep$1);
|
package/dist/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { basename, extname, dirname,
|
|
1
|
+
import { basename, extname, dirname, join, resolve, sep } from 'path';
|
|
2
2
|
import { makeLegalIdentifier, attachScopes, extractAssignedNames, createFilter } from '@rollup/pluginutils';
|
|
3
3
|
import getCommonDir from 'commondir';
|
|
4
4
|
import { existsSync, readFileSync, statSync } from 'fs';
|
|
@@ -366,8 +366,7 @@ function getName(id) {
|
|
|
366
366
|
if (name !== 'index') {
|
|
367
367
|
return name;
|
|
368
368
|
}
|
|
369
|
-
|
|
370
|
-
return makeLegalIdentifier(segments[segments.length - 1]);
|
|
369
|
+
return makeLegalIdentifier(basename(dirname(id)));
|
|
371
370
|
}
|
|
372
371
|
|
|
373
372
|
function normalizePathSlashes(path) {
|
|
@@ -587,7 +586,7 @@ function getResolveId(extensions) {
|
|
|
587
586
|
return undefined;
|
|
588
587
|
}
|
|
589
588
|
|
|
590
|
-
return function resolveId(importee, rawImporter) {
|
|
589
|
+
return function resolveId(importee, rawImporter, resolveOptions) {
|
|
591
590
|
if (isWrappedId(importee, MODULE_SUFFIX) || isWrappedId(importee, EXPORTS_SUFFIX)) {
|
|
592
591
|
return importee;
|
|
593
592
|
}
|
|
@@ -630,10 +629,16 @@ function getResolveId(extensions) {
|
|
|
630
629
|
return null;
|
|
631
630
|
}
|
|
632
631
|
|
|
633
|
-
return this.resolve(
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
632
|
+
return this.resolve(
|
|
633
|
+
importee,
|
|
634
|
+
importer,
|
|
635
|
+
Object.assign({}, resolveOptions, {
|
|
636
|
+
skipSelf: true,
|
|
637
|
+
custom: Object.assign({}, resolveOptions.custom, {
|
|
638
|
+
'node-resolve': { isRequire: isProxyModule || isRequiredModule }
|
|
639
|
+
})
|
|
640
|
+
})
|
|
641
|
+
).then((resolved) => {
|
|
637
642
|
if (!resolved) {
|
|
638
643
|
resolved = resolveExtensions(importee, importer);
|
|
639
644
|
}
|
|
@@ -779,6 +784,20 @@ function isShorthandProperty(parent) {
|
|
|
779
784
|
return parent && parent.type === 'Property' && parent.shorthand;
|
|
780
785
|
}
|
|
781
786
|
|
|
787
|
+
function hasDefineEsmProperty(node) {
|
|
788
|
+
return node.properties.some((property) => {
|
|
789
|
+
if (
|
|
790
|
+
property.type === 'Property' &&
|
|
791
|
+
property.key.type === 'Identifier' &&
|
|
792
|
+
property.key.name === '__esModule' &&
|
|
793
|
+
isTruthy(property.value)
|
|
794
|
+
) {
|
|
795
|
+
return true;
|
|
796
|
+
}
|
|
797
|
+
return false;
|
|
798
|
+
});
|
|
799
|
+
}
|
|
800
|
+
|
|
782
801
|
function wrapCode(magicString, uses, moduleName, exportsName) {
|
|
783
802
|
const args = [];
|
|
784
803
|
const passedArgs = [];
|
|
@@ -1254,6 +1273,18 @@ function transformCommonjs(
|
|
|
1254
1273
|
} else if (!firstTopLevelModuleExportsAssignment) {
|
|
1255
1274
|
firstTopLevelModuleExportsAssignment = node;
|
|
1256
1275
|
}
|
|
1276
|
+
|
|
1277
|
+
if (defaultIsModuleExports === false) {
|
|
1278
|
+
shouldWrap = true;
|
|
1279
|
+
} else if (defaultIsModuleExports === 'auto') {
|
|
1280
|
+
if (node.right.type === 'ObjectExpression') {
|
|
1281
|
+
if (hasDefineEsmProperty(node.right)) {
|
|
1282
|
+
shouldWrap = true;
|
|
1283
|
+
}
|
|
1284
|
+
} else if (defaultIsModuleExports === false) {
|
|
1285
|
+
shouldWrap = true;
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1257
1288
|
} else if (exportName === KEY_COMPILED_ESM) {
|
|
1258
1289
|
if (programDepth > 3) {
|
|
1259
1290
|
shouldWrap = true;
|
|
@@ -1678,7 +1709,9 @@ function commonjs(options = {}) {
|
|
|
1678
1709
|
? options.ignoreTryCatch(id)
|
|
1679
1710
|
: Array.isArray(options.ignoreTryCatch)
|
|
1680
1711
|
? options.ignoreTryCatch.includes(id)
|
|
1681
|
-
: options.ignoreTryCatch
|
|
1712
|
+
: typeof options.ignoreTryCatch !== 'undefined'
|
|
1713
|
+
? options.ignoreTryCatch
|
|
1714
|
+
: true;
|
|
1682
1715
|
|
|
1683
1716
|
return {
|
|
1684
1717
|
canConvertRequire: mode !== 'remove' && mode !== true,
|
|
@@ -1873,5 +1906,5 @@ function commonjs(options = {}) {
|
|
|
1873
1906
|
};
|
|
1874
1907
|
}
|
|
1875
1908
|
|
|
1876
|
-
export default
|
|
1909
|
+
export { commonjs as default };
|
|
1877
1910
|
//# sourceMappingURL=index.es.js.map
|