Skip to content

Commit ef02236

Browse files
committed
Some changes
1 parent 68abb56 commit ef02236

File tree

4 files changed

+143
-27
lines changed

4 files changed

+143
-27
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"@eslint/js": "9.14.0",
5050
"@rollup/plugin-commonjs": "28.0.1",
5151
"@rollup/plugin-node-resolve": "15.3.0",
52+
"@rollup/plugin-terser": "0.4.4",
5253
"@rollup/plugin-typescript": "12.1.1",
5354
"@types/debug": "4.1.12",
5455
"@types/eslint__js": "8.42.3",
@@ -60,10 +61,10 @@
6061
"eslint-plugin-import": "2.31.0",
6162
"eslint-plugin-prettier": "5.2.1",
6263
"globals": "15.12.0",
63-
"npm-run-all2": "^7.0.1",
64+
"npm-run-all2": "7.0.1",
6465
"prettier": "3.3.3",
6566
"rollup": "4.25.0",
66-
"sort-package-json": "^2.10.1",
67+
"sort-package-json": "2.10.1",
6768
"typescript": "5.6.3",
6869
"typescript-eslint": "8.13.0"
6970
},

pnpm-lock.yaml

Lines changed: 120 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rollup.config.mjs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
11
// @ts-check
22
import commonjs from '@rollup/plugin-commonjs'
33
import { nodeResolve } from '@rollup/plugin-node-resolve'
4+
import terser from '@rollup/plugin-terser'
45
import typescript from '@rollup/plugin-typescript'
56

6-
export default [
7-
{
8-
input: 'src/index.ts',
9-
output: {
7+
export default {
8+
input: 'src/index.ts',
9+
output: [
10+
{
1011
format: 'esm',
1112
dir: 'dist',
1213
entryFileNames: 'index-esm.js',
14+
plugins: [terser()],
1315
},
14-
external: [/node_modules/],
15-
plugins: [nodeResolve(), commonjs(), typescript()],
16-
},
17-
{
18-
input: 'src/index.ts',
19-
output: {
16+
{
2017
format: 'cjs',
2118
dir: 'dist',
2219
entryFileNames: 'index-cjs.js',
20+
plugins: [terser()],
2321
},
24-
external: [/node_modules/],
25-
plugins: [nodeResolve(), commonjs(), typescript()],
26-
},
27-
]
22+
],
23+
external: [/node_modules/],
24+
plugins: [nodeResolve(), commonjs(), typescript()],
25+
}

src/resolveImport.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -135,18 +135,17 @@ function getMappedPath(
135135

136136
let projectConfig: TsConfigResult | null = null
137137

138-
const { ext } = path.parse(file)
138+
const { ext, dir } = path.parse(file)
139139

140-
const fromCache = fileTsJsConfigCache.get(file)
141-
142-
if (fromCache) {
143-
projectConfig = fromCache
144-
} else {
145-
projectConfig = getTsconfig(file, ext.includes('js') ? 'jsconfig.json' : 'tsconfig.json')
146-
if (projectConfig) fileTsJsConfigCache.set(file, projectConfig)
140+
if (!/node_modules/.test(dir)) {
141+
// get ts config by file path for resolving it and find closest mapper
142+
projectConfig = getTsconfig(file, ext.includes('js') ? 'jsconfig.json' : 'tsconfig.json', fileTsJsConfigCache)
147143
}
148144

149-
if (projectConfig) logger('project config by file path:', projectConfig?.path)
145+
if (projectConfig) {
146+
fileTsJsConfigCache.set(file, projectConfig)
147+
logger('project config by file path:', projectConfig?.path)
148+
}
150149

151150
const closestMapper = currentMatchersOfCwd?.find((mapper) => {
152151
return mapper.path === projectConfig?.path

0 commit comments

Comments
 (0)