@rollup/plugin-node-resolve 15.0.1 → 15.1.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/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.0.1";
15
+ var version = "15.1.0";
16
16
  var peerDependencies = {
17
17
  rollup: "^2.78.0||^3.0.0"
18
18
  };
@@ -861,8 +861,8 @@ async function resolveWithClassic({
861
861
  }
862
862
 
863
863
  // Resolves to the module if found or `null`.
864
- // The first import specificer will first be attempted with the exports algorithm.
865
- // If this is unsuccesful because export maps are not being used, then all of `importSpecifierList`
864
+ // The first import specifier will first be attempted with the exports algorithm.
865
+ // If this is unsuccessful because export maps are not being used, then all of `importSpecifierList`
866
866
  // will be tried with the classic resolution algorithm
867
867
  async function resolveImportSpecifiers({
868
868
  importer,
@@ -1090,11 +1090,18 @@ function nodeResolve(opts = {}) {
1090
1090
  importSpecifierList.push(`./${importee}`);
1091
1091
  }
1092
1092
 
1093
- // TypeScript files may import '.js' to refer to either '.ts' or '.tsx'
1094
- if (importer && importee.endsWith('.js')) {
1095
- for (const ext of ['.ts', '.tsx']) {
1096
- if (importer.endsWith(ext) && extensions.includes(ext)) {
1097
- importSpecifierList.push(importee.replace(/.js$/, ext));
1093
+ // TypeScript files may import '.mjs' or '.cjs' to refer to either '.mts' or '.cts'.
1094
+ // They may also import .js to refer to either .ts or .tsx, and .jsx to refer to .tsx.
1095
+ if (importer && /\.(ts|mts|cts|tsx)$/.test(importer)) {
1096
+ for (const [importeeExt, resolvedExt] of [
1097
+ ['.js', '.ts'],
1098
+ ['.js', '.tsx'],
1099
+ ['.jsx', '.tsx'],
1100
+ ['.mjs', '.mts'],
1101
+ ['.cjs', '.cts']
1102
+ ]) {
1103
+ if (importee.endsWith(importeeExt) && extensions.includes(resolvedExt)) {
1104
+ importSpecifierList.push(importee.slice(0, -importeeExt.length) + resolvedExt);
1098
1105
  }
1099
1106
  }
1100
1107
  }
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.0.1";
11
+ var version = "15.1.0";
12
12
  var peerDependencies = {
13
13
  rollup: "^2.78.0||^3.0.0"
14
14
  };
@@ -857,8 +857,8 @@ async function resolveWithClassic({
857
857
  }
858
858
 
859
859
  // Resolves to the module if found or `null`.
860
- // The first import specificer will first be attempted with the exports algorithm.
861
- // If this is unsuccesful because export maps are not being used, then all of `importSpecifierList`
860
+ // The first import specifier will first be attempted with the exports algorithm.
861
+ // If this is unsuccessful because export maps are not being used, then all of `importSpecifierList`
862
862
  // will be tried with the classic resolution algorithm
863
863
  async function resolveImportSpecifiers({
864
864
  importer,
@@ -1086,11 +1086,18 @@ function nodeResolve(opts = {}) {
1086
1086
  importSpecifierList.push(`./${importee}`);
1087
1087
  }
1088
1088
 
1089
- // TypeScript files may import '.js' to refer to either '.ts' or '.tsx'
1090
- if (importer && importee.endsWith('.js')) {
1091
- for (const ext of ['.ts', '.tsx']) {
1092
- if (importer.endsWith(ext) && extensions.includes(ext)) {
1093
- importSpecifierList.push(importee.replace(/.js$/, ext));
1089
+ // TypeScript files may import '.mjs' or '.cjs' to refer to either '.mts' or '.cts'.
1090
+ // They may also import .js to refer to either .ts or .tsx, and .jsx to refer to .tsx.
1091
+ if (importer && /\.(ts|mts|cts|tsx)$/.test(importer)) {
1092
+ for (const [importeeExt, resolvedExt] of [
1093
+ ['.js', '.ts'],
1094
+ ['.js', '.tsx'],
1095
+ ['.jsx', '.tsx'],
1096
+ ['.mjs', '.mts'],
1097
+ ['.cjs', '.cts']
1098
+ ]) {
1099
+ if (importee.endsWith(importeeExt) && extensions.includes(resolvedExt)) {
1100
+ importSpecifierList.push(importee.slice(0, -importeeExt.length) + resolvedExt);
1094
1101
  }
1095
1102
  }
1096
1103
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rollup/plugin-node-resolve",
3
- "version": "15.0.1",
3
+ "version": "15.1.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -64,7 +64,7 @@
64
64
  "@rollup/pluginutils": "^5.0.1",
65
65
  "@types/resolve": "1.20.2",
66
66
  "deepmerge": "^4.2.2",
67
- "is-builtin-module": "^3.2.0",
67
+ "is-builtin-module": "^3.2.1",
68
68
  "is-module": "^1.0.0",
69
69
  "resolve": "^1.22.1"
70
70
  },
package/types/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Plugin } from 'rollup';
1
+ import type { Plugin } from 'rollup';
2
2
 
3
3
  export const DEFAULTS: {
4
4
  customResolveOptions: {};