@rollup/plugin-node-resolve 15.3.1 → 16.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/README.md CHANGED
@@ -53,7 +53,7 @@ This plugin supports the package entrypoints feature from node js, specified in
53
53
  Type: `Array[...String]`<br>
54
54
  Default: `[]`
55
55
 
56
- Additional conditions of the package.json exports field to match when resolving modules. By default, this plugin looks for the `['default', 'module', 'import']` conditions when resolving imports.
56
+ Additional conditions of the package.json exports field to match when resolving modules. By default, this plugin looks for the `['default', 'module', 'import', 'development|production']` conditions when resolving imports. If neither the `development` or `production` conditions are provided it will default to `production` - or `development` if `NODE_ENV` is set to a value other than `production`.
57
57
 
58
58
  When using `@rollup/plugin-commonjs` v16 or higher, this plugin will use the `['default', 'module', 'require']` conditions when resolving require statements.
59
59
 
@@ -181,6 +181,9 @@ rootDir: path.join(process.cwd(), '..')
181
181
 
182
182
  ### `ignoreSideEffectsForRoot`
183
183
 
184
+ Type: `Boolean`<br>
185
+ Default: `false`
186
+
184
187
  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.
185
188
 
186
189
  ### `allowExportsFolderMapping`
package/dist/cjs/index.js CHANGED
@@ -12,7 +12,7 @@ var url = require('url');
12
12
  var resolve = require('resolve');
13
13
  var pluginutils = require('@rollup/pluginutils');
14
14
 
15
- var version = "15.3.1";
15
+ var version = "16.0.1";
16
16
  var peerDependencies = {
17
17
  rollup: "^2.78.0||^3.0.0||^4.0.0"
18
18
  };
@@ -1067,8 +1067,17 @@ function nodeResolve(opts = {}) {
1067
1067
 
1068
1068
  const options = { ...defaults, ...opts };
1069
1069
  const { extensions, jail, moduleDirectories, modulePaths, ignoreSideEffectsForRoot } = options;
1070
- const conditionsEsm = [...baseConditionsEsm, ...(options.exportConditions || [])];
1071
- const conditionsCjs = [...baseConditionsCjs, ...(options.exportConditions || [])];
1070
+ const exportConditions = options.exportConditions || [];
1071
+ const devProdCondition =
1072
+ exportConditions.includes('development') || exportConditions.includes('production')
1073
+ ? []
1074
+ : [
1075
+ process.env.NODE_ENV && process.env.NODE_ENV !== 'production'
1076
+ ? 'development'
1077
+ : 'production'
1078
+ ];
1079
+ const conditionsEsm = [...baseConditionsEsm, ...exportConditions, ...devProdCondition];
1080
+ const conditionsCjs = [...baseConditionsCjs, ...exportConditions, ...devProdCondition];
1072
1081
  const packageInfoCache = new Map();
1073
1082
  const idToPackageInfo = new Map();
1074
1083
  const mainFields = getMainFields(options);
@@ -1186,7 +1195,6 @@ function nodeResolve(opts = {}) {
1186
1195
  const warn = (...args) => context.warn(...args);
1187
1196
  const isRequire = custom && custom['node-resolve'] && custom['node-resolve'].isRequire;
1188
1197
  const exportConditions = isRequire ? conditionsCjs : conditionsEsm;
1189
-
1190
1198
  if (useBrowserOverrides && !exportConditions.includes('browser'))
1191
1199
  exportConditions.push('browser');
1192
1200
 
package/dist/es/index.js CHANGED
@@ -8,7 +8,7 @@ import { pathToFileURL, fileURLToPath } from 'url';
8
8
  import resolve$1 from 'resolve';
9
9
  import { createFilter } from '@rollup/pluginutils';
10
10
 
11
- var version = "15.3.1";
11
+ var version = "16.0.1";
12
12
  var peerDependencies = {
13
13
  rollup: "^2.78.0||^3.0.0||^4.0.0"
14
14
  };
@@ -1063,8 +1063,17 @@ function nodeResolve(opts = {}) {
1063
1063
 
1064
1064
  const options = { ...defaults, ...opts };
1065
1065
  const { extensions, jail, moduleDirectories, modulePaths, ignoreSideEffectsForRoot } = options;
1066
- const conditionsEsm = [...baseConditionsEsm, ...(options.exportConditions || [])];
1067
- const conditionsCjs = [...baseConditionsCjs, ...(options.exportConditions || [])];
1066
+ const exportConditions = options.exportConditions || [];
1067
+ const devProdCondition =
1068
+ exportConditions.includes('development') || exportConditions.includes('production')
1069
+ ? []
1070
+ : [
1071
+ process.env.NODE_ENV && process.env.NODE_ENV !== 'production'
1072
+ ? 'development'
1073
+ : 'production'
1074
+ ];
1075
+ const conditionsEsm = [...baseConditionsEsm, ...exportConditions, ...devProdCondition];
1076
+ const conditionsCjs = [...baseConditionsCjs, ...exportConditions, ...devProdCondition];
1068
1077
  const packageInfoCache = new Map();
1069
1078
  const idToPackageInfo = new Map();
1070
1079
  const mainFields = getMainFields(options);
@@ -1182,7 +1191,6 @@ function nodeResolve(opts = {}) {
1182
1191
  const warn = (...args) => context.warn(...args);
1183
1192
  const isRequire = custom && custom['node-resolve'] && custom['node-resolve'].isRequire;
1184
1193
  const exportConditions = isRequire ? conditionsCjs : conditionsEsm;
1185
-
1186
1194
  if (useBrowserOverrides && !exportConditions.includes('browser'))
1187
1195
  exportConditions.push('browser');
1188
1196
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rollup/plugin-node-resolve",
3
- "version": "15.3.1",
3
+ "version": "16.0.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/types/index.d.ts CHANGED
@@ -99,6 +99,13 @@ export interface RollupNodeResolveOptions {
99
99
  */
100
100
  rootDir?: string;
101
101
 
102
+ /**
103
+ * 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.
104
+ *
105
+ * @default false
106
+ */
107
+ ignoreSideEffectsForRoot?: boolean;
108
+
102
109
  /**
103
110
  * Allow folder mappings in package exports (trailing /)
104
111
  * This was deprecated in Node 14 and removed with Node 17, see DEP0148.