@rollup/plugin-node-resolve 13.2.0 → 13.3.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 CHANGED
@@ -1,5 +1,31 @@
1
1
  # @rollup/plugin-node-resolve ChangeLog
2
2
 
3
+ ## v13.3.0
4
+
5
+ _2022-05-02_
6
+
7
+ ### Features
8
+
9
+ - feat: support `node:` protocol (#1124)
10
+
11
+ ## v13.2.2
12
+
13
+ _2022-05-02_
14
+
15
+ ### Bugfixes
16
+
17
+ - fix: Respect if other plugins resolve the resolution to a different id (#1181)
18
+ - fix: Revert respect if other plugins resolve the resolution to a different id (ae59ceb)
19
+ - fix: Respect if other plugins resolve the resolution to a different id (f8d4c44)
20
+
21
+ ## v13.2.1
22
+
23
+ _2022-04-15_
24
+
25
+ ### Bugfixes
26
+
27
+ - fix: update side effects logic to be deep when glob doesn’t contain `/` (#1148)
28
+
3
29
  ## v13.2.0
4
30
 
5
31
  _2022-04-11_
package/dist/cjs/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var path = require('path');
6
- var builtinList = require('builtin-modules');
6
+ var isBuiltinModule = require('is-builtin-module');
7
7
  var deepMerge = require('deepmerge');
8
8
  var isModule = require('is-module');
9
9
  var fs = require('fs');
@@ -15,13 +15,13 @@ var pluginutils = require('@rollup/pluginutils');
15
15
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
16
16
 
17
17
  var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
18
- var builtinList__default = /*#__PURE__*/_interopDefaultLegacy(builtinList);
18
+ var isBuiltinModule__default = /*#__PURE__*/_interopDefaultLegacy(isBuiltinModule);
19
19
  var deepMerge__default = /*#__PURE__*/_interopDefaultLegacy(deepMerge);
20
20
  var isModule__default = /*#__PURE__*/_interopDefaultLegacy(isModule);
21
21
  var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
22
22
  var resolve__default = /*#__PURE__*/_interopDefaultLegacy(resolve);
23
23
 
24
- var version = "13.2.0";
24
+ var version = "13.3.0";
25
25
 
26
26
  util.promisify(fs__default["default"].access);
27
27
  const readFile$1 = util.promisify(fs__default["default"].readFile);
@@ -282,7 +282,17 @@ function getPackageInfo(options) {
282
282
  if (typeof packageSideEffects === 'boolean') {
283
283
  internalPackageInfo.hasModuleSideEffects = () => packageSideEffects;
284
284
  } else if (Array.isArray(packageSideEffects)) {
285
- internalPackageInfo.hasModuleSideEffects = pluginutils.createFilter(packageSideEffects, null, {
285
+ const finalPackageSideEffects = packageSideEffects.map((sideEffect) => {
286
+ /*
287
+ * The array accepts simple glob patterns to the relevant files... Patterns like .css, which do not include a /, will be treated like **\/.css.
288
+ * https://webpack.js.org/guides/tree-shaking/
289
+ */
290
+ if (sideEffect.includes('/')) {
291
+ return sideEffect;
292
+ }
293
+ return `**/${sideEffect}`;
294
+ });
295
+ internalPackageInfo.hasModuleSideEffects = pluginutils.createFilter(finalPackageSideEffects, null, {
286
296
  resolve: pkgRoot
287
297
  });
288
298
  }
@@ -912,7 +922,6 @@ async function resolveImportSpecifiers({
912
922
 
913
923
  /* eslint-disable no-param-reassign, no-shadow, no-undefined */
914
924
 
915
- const builtins = new Set(builtinList__default["default"]);
916
925
  const ES6_BROWSER_EMPTY = '\0node-resolve:empty.js';
917
926
  const deepFreeze = (object) => {
918
927
  Object.freeze(object);
@@ -1071,7 +1080,7 @@ function nodeResolve(opts = {}) {
1071
1080
  ignoreSideEffectsForRoot
1072
1081
  });
1073
1082
 
1074
- const importeeIsBuiltin = builtins.has(importee);
1083
+ const importeeIsBuiltin = isBuiltinModule__default["default"](importee);
1075
1084
  const resolved =
1076
1085
  importeeIsBuiltin && preferBuiltins
1077
1086
  ? {
@@ -1141,14 +1150,14 @@ function nodeResolve(opts = {}) {
1141
1150
 
1142
1151
  version,
1143
1152
 
1144
- buildStart(options) {
1145
- rollupOptions = options;
1153
+ buildStart(buildOptions) {
1154
+ rollupOptions = buildOptions;
1146
1155
 
1147
1156
  for (const warning of warnings) {
1148
1157
  this.warn(warning);
1149
1158
  }
1150
1159
 
1151
- ({ preserveSymlinks } = options);
1160
+ ({ preserveSymlinks } = buildOptions);
1152
1161
  },
1153
1162
 
1154
1163
  generateBundle() {
@@ -1180,6 +1189,11 @@ function nodeResolve(opts = {}) {
1180
1189
  if (resolvedResolved.external) {
1181
1190
  return false;
1182
1191
  }
1192
+ // Allow other plugins to take over resolution. Rollup core will not
1193
+ // change the id if it corresponds to an existing file
1194
+ if (resolvedResolved.id !== resolved.id) {
1195
+ return resolvedResolved;
1196
+ }
1183
1197
  // Pass on meta information added by other plugins
1184
1198
  return { ...resolved, meta: resolvedResolved.meta };
1185
1199
  }
package/dist/es/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import path, { dirname, resolve, extname, normalize, sep } from 'path';
2
- import builtinList from 'builtin-modules';
2
+ import isBuiltinModule from 'is-builtin-module';
3
3
  import deepMerge from 'deepmerge';
4
4
  import isModule from 'is-module';
5
5
  import fs, { realpathSync } from 'fs';
@@ -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 = "13.2.0";
11
+ var version = "13.3.0";
12
12
 
13
13
  promisify(fs.access);
14
14
  const readFile$1 = promisify(fs.readFile);
@@ -269,7 +269,17 @@ function getPackageInfo(options) {
269
269
  if (typeof packageSideEffects === 'boolean') {
270
270
  internalPackageInfo.hasModuleSideEffects = () => packageSideEffects;
271
271
  } else if (Array.isArray(packageSideEffects)) {
272
- internalPackageInfo.hasModuleSideEffects = createFilter(packageSideEffects, null, {
272
+ const finalPackageSideEffects = packageSideEffects.map((sideEffect) => {
273
+ /*
274
+ * The array accepts simple glob patterns to the relevant files... Patterns like .css, which do not include a /, will be treated like **\/.css.
275
+ * https://webpack.js.org/guides/tree-shaking/
276
+ */
277
+ if (sideEffect.includes('/')) {
278
+ return sideEffect;
279
+ }
280
+ return `**/${sideEffect}`;
281
+ });
282
+ internalPackageInfo.hasModuleSideEffects = createFilter(finalPackageSideEffects, null, {
273
283
  resolve: pkgRoot
274
284
  });
275
285
  }
@@ -899,7 +909,6 @@ async function resolveImportSpecifiers({
899
909
 
900
910
  /* eslint-disable no-param-reassign, no-shadow, no-undefined */
901
911
 
902
- const builtins = new Set(builtinList);
903
912
  const ES6_BROWSER_EMPTY = '\0node-resolve:empty.js';
904
913
  const deepFreeze = (object) => {
905
914
  Object.freeze(object);
@@ -1058,7 +1067,7 @@ function nodeResolve(opts = {}) {
1058
1067
  ignoreSideEffectsForRoot
1059
1068
  });
1060
1069
 
1061
- const importeeIsBuiltin = builtins.has(importee);
1070
+ const importeeIsBuiltin = isBuiltinModule(importee);
1062
1071
  const resolved =
1063
1072
  importeeIsBuiltin && preferBuiltins
1064
1073
  ? {
@@ -1128,14 +1137,14 @@ function nodeResolve(opts = {}) {
1128
1137
 
1129
1138
  version,
1130
1139
 
1131
- buildStart(options) {
1132
- rollupOptions = options;
1140
+ buildStart(buildOptions) {
1141
+ rollupOptions = buildOptions;
1133
1142
 
1134
1143
  for (const warning of warnings) {
1135
1144
  this.warn(warning);
1136
1145
  }
1137
1146
 
1138
- ({ preserveSymlinks } = options);
1147
+ ({ preserveSymlinks } = buildOptions);
1139
1148
  },
1140
1149
 
1141
1150
  generateBundle() {
@@ -1167,6 +1176,11 @@ function nodeResolve(opts = {}) {
1167
1176
  if (resolvedResolved.external) {
1168
1177
  return false;
1169
1178
  }
1179
+ // Allow other plugins to take over resolution. Rollup core will not
1180
+ // change the id if it corresponds to an existing file
1181
+ if (resolvedResolved.id !== resolved.id) {
1182
+ return resolvedResolved;
1183
+ }
1170
1184
  // Pass on meta information added by other plugins
1171
1185
  return { ...resolved, meta: resolvedResolved.meta };
1172
1186
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rollup/plugin-node-resolve",
3
- "version": "13.2.0",
3
+ "version": "13.3.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -57,8 +57,8 @@
57
57
  "dependencies": {
58
58
  "@rollup/pluginutils": "^3.1.0",
59
59
  "@types/resolve": "1.17.1",
60
- "builtin-modules": "^3.1.0",
61
60
  "deepmerge": "^4.2.2",
61
+ "is-builtin-module": "^3.1.0",
62
62
  "is-module": "^1.0.0",
63
63
  "resolve": "^1.19.0"
64
64
  },