@mui/internal-babel-plugin-resolve-imports 2.0.7-canary.2 → 2.0.7-canary.20

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/index.js CHANGED
@@ -1,7 +1,8 @@
1
1
  // @ts-check
2
+
2
3
  /// <reference path="./resolve.d.ts" />
3
4
 
4
- const nodePath = require('path');
5
+ const nodePath = require('node:path');
5
6
  const resolve = require('resolve/sync');
6
7
 
7
8
  /**
@@ -39,7 +40,7 @@ function pathToNodeImportSpecifier(importPath) {
39
40
  module.exports = function plugin({ types: t }, { outExtension }) {
40
41
  /** @type {Map<string, string>} */
41
42
  const cache = new Map();
42
- const extensions = ['.ts', '.tsx', '.js', '.jsx'];
43
+ const extensions = ['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx'];
43
44
  const extensionsSet = new Set(extensions);
44
45
 
45
46
  /**
@@ -50,6 +51,12 @@ module.exports = function plugin({ types: t }, { outExtension }) {
50
51
  function doResolve(importSource, state) {
51
52
  const importedPath = importSource.node.value;
52
53
 
54
+ const importExt = nodePath.extname(importedPath);
55
+ // ignore if the import already has a desired extension or if it is a css import.
56
+ if (extensionsSet.has(importExt) || importExt === '.css') {
57
+ return;
58
+ }
59
+
53
60
  if (!importedPath.startsWith('.')) {
54
61
  // Only handle relative imports
55
62
  return;
package/index.test.js CHANGED
@@ -1,5 +1,5 @@
1
- import * as fs from 'fs';
2
- import * as path from 'path';
1
+ import * as fs from 'node:fs';
2
+ import * as path from 'node:path';
3
3
  import { pluginTester } from 'babel-plugin-tester';
4
4
  import plugin from './index';
5
5
 
@@ -107,5 +107,16 @@ pluginTester({
107
107
  fixture: path.join(fixturePath, 'declaration-files', 'input.d.ts'),
108
108
  output: readOutputFixtureSync('declaration-files', 'output.d.ts'),
109
109
  },
110
+ {
111
+ title: 'Ignore imports with extensions',
112
+ pluginOptions: {
113
+ outExtension: '.js',
114
+ },
115
+ babelOptions: {
116
+ plugins: [['@babel/plugin-syntax-typescript', { dts: true }]],
117
+ },
118
+ fixture: path.join(fixturePath, 'ignore-imports-with-extensions', 'input.d.ts'),
119
+ output: readOutputFixtureSync('ignore-imports-with-extensions', 'output.d.ts'),
120
+ },
110
121
  ],
111
122
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/internal-babel-plugin-resolve-imports",
3
- "version": "2.0.7-canary.2",
3
+ "version": "2.0.7-canary.20",
4
4
  "author": "MUI Team",
5
5
  "description": "Babel plugin that resolves import specifiers to their actual output file.",
6
6
  "main": "./index.js",
@@ -17,15 +17,14 @@
17
17
  "resolve": "^1.22.10"
18
18
  },
19
19
  "devDependencies": {
20
- "@babel/core": "^7.27.1",
20
+ "@babel/core": "^7.28.4",
21
21
  "@babel/plugin-syntax-typescript": "^7.27.1",
22
22
  "@babel/preset-typescript": "^7.27.1",
23
23
  "@types/babel__core": "^7.20.5",
24
- "@types/chai": "^4.3.20",
25
- "@types/node": "^20.17.46",
24
+ "@types/chai": "^5.2.2",
25
+ "@types/node": "^24.3.1",
26
26
  "@types/resolve": "^1.20.6",
27
- "babel-plugin-tester": "^12.0.0",
28
- "chai": "^4.5.0"
27
+ "babel-plugin-tester": "^12.0.0"
29
28
  },
30
29
  "peerDependencies": {
31
30
  "@babel/core": "7"
@@ -33,6 +32,6 @@
33
32
  "publishConfig": {
34
33
  "access": "public"
35
34
  },
36
- "gitSha": "8391aed9c1a47151a520e3bfea6db8c730fdadd3",
35
+ "gitSha": "f9fb2233d5f6d847f6205b345bb829a712eea199",
37
36
  "scripts": {}
38
37
  }