@rollup/plugin-node-resolve 11.1.1 → 11.2.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 +13 -0
- package/README.md +10 -3
- package/dist/cjs/index.js +38 -16
- package/dist/es/index.js +38 -16
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
# @rollup/plugin-node-resolve ChangeLog
|
2
2
|
|
3
|
+
## v11.2.0
|
4
|
+
|
5
|
+
_2021-02-14_
|
6
|
+
|
7
|
+
### Features
|
8
|
+
|
9
|
+
- feat: add `ignoreSideEffectsForRoot` option (#694)
|
10
|
+
|
11
|
+
### Updates
|
12
|
+
|
13
|
+
- chore: mark `url` as an external and throw on warning (#783)
|
14
|
+
- docs: clearer "Resolving Built-Ins" doc (#782)
|
15
|
+
|
3
16
|
## v11.1.1
|
4
17
|
|
5
18
|
_2021-01-29_
|
package/README.md
CHANGED
@@ -157,6 +157,10 @@ Specifies the root directory from which to resolve modules. Typically used when
|
|
157
157
|
rootDir: path.join(process.cwd(), '..')
|
158
158
|
```
|
159
159
|
|
160
|
+
## `ignoreSideEffectsForRoot`
|
161
|
+
|
162
|
+
If you use the `sideEffects` property in the package.json, by default this is respected for files in the root package. Set to `true` to ignore the `sideEffects` configuration for the root package.
|
163
|
+
|
160
164
|
## Preserving symlinks
|
161
165
|
|
162
166
|
This plugin honours the rollup [`preserveSymlinks`](https://rollupjs.org/guide/en/#preservesymlinks) option.
|
@@ -187,14 +191,17 @@ By default this plugin will prefer built-ins over local modules, marking them as
|
|
187
191
|
|
188
192
|
See [`preferBuiltins`](#preferbuiltins).
|
189
193
|
|
190
|
-
To provide stubbed versions of Node built-ins, use a plugin like [rollup-plugin-node-polyfills](https://github.com/ionic-team/rollup-plugin-node-polyfills)
|
194
|
+
To provide stubbed versions of Node built-ins, use a plugin like [rollup-plugin-node-polyfills](https://github.com/ionic-team/rollup-plugin-node-polyfills) and set `preferBuiltins` to `false`. e.g.
|
191
195
|
|
192
196
|
```js
|
193
197
|
import { nodeResolve } from '@rollup/plugin-node-resolve';
|
194
|
-
import
|
198
|
+
import nodePolyfills from 'rollup-plugin-node-polyfills';
|
195
199
|
export default ({
|
196
200
|
input: ...,
|
197
|
-
plugins: [
|
201
|
+
plugins: [
|
202
|
+
nodePolyfills(),
|
203
|
+
nodeResolve({ preferBuiltins: false })
|
204
|
+
],
|
198
205
|
external: builtins,
|
199
206
|
output: ...
|
200
207
|
})
|
package/dist/cjs/index.js
CHANGED
@@ -116,7 +116,16 @@ function getMainFields(options) {
|
|
116
116
|
}
|
117
117
|
|
118
118
|
function getPackageInfo(options) {
|
119
|
-
const {
|
119
|
+
const {
|
120
|
+
cache,
|
121
|
+
extensions,
|
122
|
+
pkg,
|
123
|
+
mainFields,
|
124
|
+
preserveSymlinks,
|
125
|
+
useBrowserOverrides,
|
126
|
+
rootDir,
|
127
|
+
ignoreSideEffectsForRoot
|
128
|
+
} = options;
|
120
129
|
let { pkgPath } = options;
|
121
130
|
|
122
131
|
if (cache.has(pkgPath)) {
|
@@ -206,13 +215,15 @@ function getPackageInfo(options) {
|
|
206
215
|
packageInfo.browserMappedMain = false;
|
207
216
|
}
|
208
217
|
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
218
|
+
if (!ignoreSideEffectsForRoot || rootDir !== pkgRoot) {
|
219
|
+
const packageSideEffects = pkg.sideEffects;
|
220
|
+
if (typeof packageSideEffects === 'boolean') {
|
221
|
+
internalPackageInfo.hasModuleSideEffects = () => packageSideEffects;
|
222
|
+
} else if (Array.isArray(packageSideEffects)) {
|
223
|
+
internalPackageInfo.hasModuleSideEffects = pluginutils.createFilter(packageSideEffects, null, {
|
224
|
+
resolve: pkgRoot
|
225
|
+
});
|
226
|
+
}
|
216
227
|
}
|
217
228
|
|
218
229
|
cache.set(pkgPath, internalPackageInfo);
|
@@ -564,7 +575,9 @@ async function resolveId({
|
|
564
575
|
preserveSymlinks,
|
565
576
|
useBrowserOverrides,
|
566
577
|
baseDir,
|
567
|
-
moduleDirectories
|
578
|
+
moduleDirectories,
|
579
|
+
rootDir,
|
580
|
+
ignoreSideEffectsForRoot
|
568
581
|
}) {
|
569
582
|
let hasModuleSideEffects = () => null;
|
570
583
|
let hasPackageEntry = true;
|
@@ -579,7 +592,9 @@ async function resolveId({
|
|
579
592
|
pkgPath,
|
580
593
|
mainFields,
|
581
594
|
preserveSymlinks,
|
582
|
-
useBrowserOverrides
|
595
|
+
useBrowserOverrides,
|
596
|
+
rootDir,
|
597
|
+
ignoreSideEffectsForRoot
|
583
598
|
});
|
584
599
|
|
585
600
|
({ packageInfo, hasModuleSideEffects, hasPackageEntry, packageBrowserField } = info);
|
@@ -701,7 +716,9 @@ async function resolveImportSpecifiers({
|
|
701
716
|
preserveSymlinks,
|
702
717
|
useBrowserOverrides,
|
703
718
|
baseDir,
|
704
|
-
moduleDirectories
|
719
|
+
moduleDirectories,
|
720
|
+
rootDir,
|
721
|
+
ignoreSideEffectsForRoot
|
705
722
|
}) {
|
706
723
|
let lastResolveError;
|
707
724
|
|
@@ -718,7 +735,9 @@ async function resolveImportSpecifiers({
|
|
718
735
|
preserveSymlinks,
|
719
736
|
useBrowserOverrides,
|
720
737
|
baseDir,
|
721
|
-
moduleDirectories
|
738
|
+
moduleDirectories,
|
739
|
+
rootDir,
|
740
|
+
ignoreSideEffectsForRoot
|
722
741
|
});
|
723
742
|
|
724
743
|
if (result instanceof ResolveError) {
|
@@ -807,7 +826,8 @@ const defaults = {
|
|
807
826
|
// which deploy both ESM .mjs and CommonJS .js files as ESM.
|
808
827
|
extensions: ['.mjs', '.js', '.json', '.node'],
|
809
828
|
resolveOnly: [],
|
810
|
-
moduleDirectories: ['node_modules']
|
829
|
+
moduleDirectories: ['node_modules'],
|
830
|
+
ignoreSideEffectsForRoot: false
|
811
831
|
};
|
812
832
|
const DEFAULTS = deepFreeze(deepMerge__default['default']({}, defaults));
|
813
833
|
|
@@ -815,7 +835,7 @@ function nodeResolve(opts = {}) {
|
|
815
835
|
const { warnings } = handleDeprecatedOptions(opts);
|
816
836
|
|
817
837
|
const options = { ...defaults, ...opts };
|
818
|
-
const { extensions, jail, moduleDirectories } = options;
|
838
|
+
const { extensions, jail, moduleDirectories, ignoreSideEffectsForRoot } = options;
|
819
839
|
const conditionsEsm = [...baseConditionsEsm, ...(options.exportConditions || [])];
|
820
840
|
const conditionsCjs = [...baseConditionsCjs, ...(options.exportConditions || [])];
|
821
841
|
const packageInfoCache = new Map();
|
@@ -824,7 +844,7 @@ function nodeResolve(opts = {}) {
|
|
824
844
|
const useBrowserOverrides = mainFields.indexOf('browser') !== -1;
|
825
845
|
const isPreferBuiltinsSet = options.preferBuiltins === true || options.preferBuiltins === false;
|
826
846
|
const preferBuiltins = isPreferBuiltinsSet ? options.preferBuiltins : true;
|
827
|
-
const rootDir = options.rootDir || process.cwd();
|
847
|
+
const rootDir = path.resolve(options.rootDir || process.cwd());
|
828
848
|
let { dedupe } = options;
|
829
849
|
let rollupOptions;
|
830
850
|
|
@@ -973,7 +993,9 @@ function nodeResolve(opts = {}) {
|
|
973
993
|
preserveSymlinks,
|
974
994
|
useBrowserOverrides,
|
975
995
|
baseDir,
|
976
|
-
moduleDirectories
|
996
|
+
moduleDirectories,
|
997
|
+
rootDir,
|
998
|
+
ignoreSideEffectsForRoot
|
977
999
|
});
|
978
1000
|
|
979
1001
|
const resolved =
|
package/dist/es/index.js
CHANGED
@@ -103,7 +103,16 @@ function getMainFields(options) {
|
|
103
103
|
}
|
104
104
|
|
105
105
|
function getPackageInfo(options) {
|
106
|
-
const {
|
106
|
+
const {
|
107
|
+
cache,
|
108
|
+
extensions,
|
109
|
+
pkg,
|
110
|
+
mainFields,
|
111
|
+
preserveSymlinks,
|
112
|
+
useBrowserOverrides,
|
113
|
+
rootDir,
|
114
|
+
ignoreSideEffectsForRoot
|
115
|
+
} = options;
|
107
116
|
let { pkgPath } = options;
|
108
117
|
|
109
118
|
if (cache.has(pkgPath)) {
|
@@ -193,13 +202,15 @@ function getPackageInfo(options) {
|
|
193
202
|
packageInfo.browserMappedMain = false;
|
194
203
|
}
|
195
204
|
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
205
|
+
if (!ignoreSideEffectsForRoot || rootDir !== pkgRoot) {
|
206
|
+
const packageSideEffects = pkg.sideEffects;
|
207
|
+
if (typeof packageSideEffects === 'boolean') {
|
208
|
+
internalPackageInfo.hasModuleSideEffects = () => packageSideEffects;
|
209
|
+
} else if (Array.isArray(packageSideEffects)) {
|
210
|
+
internalPackageInfo.hasModuleSideEffects = createFilter(packageSideEffects, null, {
|
211
|
+
resolve: pkgRoot
|
212
|
+
});
|
213
|
+
}
|
203
214
|
}
|
204
215
|
|
205
216
|
cache.set(pkgPath, internalPackageInfo);
|
@@ -551,7 +562,9 @@ async function resolveId({
|
|
551
562
|
preserveSymlinks,
|
552
563
|
useBrowserOverrides,
|
553
564
|
baseDir,
|
554
|
-
moduleDirectories
|
565
|
+
moduleDirectories,
|
566
|
+
rootDir,
|
567
|
+
ignoreSideEffectsForRoot
|
555
568
|
}) {
|
556
569
|
let hasModuleSideEffects = () => null;
|
557
570
|
let hasPackageEntry = true;
|
@@ -566,7 +579,9 @@ async function resolveId({
|
|
566
579
|
pkgPath,
|
567
580
|
mainFields,
|
568
581
|
preserveSymlinks,
|
569
|
-
useBrowserOverrides
|
582
|
+
useBrowserOverrides,
|
583
|
+
rootDir,
|
584
|
+
ignoreSideEffectsForRoot
|
570
585
|
});
|
571
586
|
|
572
587
|
({ packageInfo, hasModuleSideEffects, hasPackageEntry, packageBrowserField } = info);
|
@@ -688,7 +703,9 @@ async function resolveImportSpecifiers({
|
|
688
703
|
preserveSymlinks,
|
689
704
|
useBrowserOverrides,
|
690
705
|
baseDir,
|
691
|
-
moduleDirectories
|
706
|
+
moduleDirectories,
|
707
|
+
rootDir,
|
708
|
+
ignoreSideEffectsForRoot
|
692
709
|
}) {
|
693
710
|
let lastResolveError;
|
694
711
|
|
@@ -705,7 +722,9 @@ async function resolveImportSpecifiers({
|
|
705
722
|
preserveSymlinks,
|
706
723
|
useBrowserOverrides,
|
707
724
|
baseDir,
|
708
|
-
moduleDirectories
|
725
|
+
moduleDirectories,
|
726
|
+
rootDir,
|
727
|
+
ignoreSideEffectsForRoot
|
709
728
|
});
|
710
729
|
|
711
730
|
if (result instanceof ResolveError) {
|
@@ -794,7 +813,8 @@ const defaults = {
|
|
794
813
|
// which deploy both ESM .mjs and CommonJS .js files as ESM.
|
795
814
|
extensions: ['.mjs', '.js', '.json', '.node'],
|
796
815
|
resolveOnly: [],
|
797
|
-
moduleDirectories: ['node_modules']
|
816
|
+
moduleDirectories: ['node_modules'],
|
817
|
+
ignoreSideEffectsForRoot: false
|
798
818
|
};
|
799
819
|
const DEFAULTS = deepFreeze(deepMerge({}, defaults));
|
800
820
|
|
@@ -802,7 +822,7 @@ function nodeResolve(opts = {}) {
|
|
802
822
|
const { warnings } = handleDeprecatedOptions(opts);
|
803
823
|
|
804
824
|
const options = { ...defaults, ...opts };
|
805
|
-
const { extensions, jail, moduleDirectories } = options;
|
825
|
+
const { extensions, jail, moduleDirectories, ignoreSideEffectsForRoot } = options;
|
806
826
|
const conditionsEsm = [...baseConditionsEsm, ...(options.exportConditions || [])];
|
807
827
|
const conditionsCjs = [...baseConditionsCjs, ...(options.exportConditions || [])];
|
808
828
|
const packageInfoCache = new Map();
|
@@ -811,7 +831,7 @@ function nodeResolve(opts = {}) {
|
|
811
831
|
const useBrowserOverrides = mainFields.indexOf('browser') !== -1;
|
812
832
|
const isPreferBuiltinsSet = options.preferBuiltins === true || options.preferBuiltins === false;
|
813
833
|
const preferBuiltins = isPreferBuiltinsSet ? options.preferBuiltins : true;
|
814
|
-
const rootDir = options.rootDir || process.cwd();
|
834
|
+
const rootDir = resolve(options.rootDir || process.cwd());
|
815
835
|
let { dedupe } = options;
|
816
836
|
let rollupOptions;
|
817
837
|
|
@@ -960,7 +980,9 @@ function nodeResolve(opts = {}) {
|
|
960
980
|
preserveSymlinks,
|
961
981
|
useBrowserOverrides,
|
962
982
|
baseDir,
|
963
|
-
moduleDirectories
|
983
|
+
moduleDirectories,
|
984
|
+
rootDir,
|
985
|
+
ignoreSideEffectsForRoot
|
964
986
|
});
|
965
987
|
|
966
988
|
const resolved =
|