Skip to content

Commit 4671087

Browse files
committed
fix: support tsconfig aliases prefixed with #
fix #106
1 parent 983a5eb commit 4671087

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/utils/rollup-plugins/resolve-tsconfig-paths.ts

-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const name = 'resolve-tsconfig-paths';
55

66
const isRelative = (filePath: string) => filePath[0] === '.';
77
const isAbsolute = (filePath: string) => filePath[0] === '/' || /^[\s\S]:/.test(filePath);
8-
const isImports = (filePath: string) => filePath[0] === '#';
98

109
export const resolveTsconfigPaths = (
1110
tsconfig: TsConfigResult,
@@ -24,7 +23,6 @@ export const resolveTsconfigPaths = (
2423
!importer
2524
|| isRelative(id)
2625
|| isAbsolute(id)
27-
|| isImports(id)
2826
|| id.startsWith('\0')
2927
) {
3028
return null;

tests/specs/builds/typescript.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,14 @@ export default testSuite(({ describe }, nodePath: string) => {
110110
'index.ts': outdent`
111111
import * as foo from '@foo/index.js';
112112
import { bar } from '~bar';
113-
export { foo, bar };`,
113+
import { baz } from '#baz';
114+
export { foo, bar, baz };`,
114115
foo: {
115116
'index.ts': 'export { a } from \'@foo/a.js\';',
116117
'a.ts': 'export const a = \'a\';',
117118
},
118119
'bar/index.ts': 'export const bar = \'bar\';',
120+
'baz.ts': 'export const baz = \'baz\';',
119121
},
120122
'package.json': createPackageJson({
121123
exports: {
@@ -128,6 +130,7 @@ export default testSuite(({ describe }, nodePath: string) => {
128130
paths: {
129131
'@foo/*': ['./src/foo/*'],
130132
'~bar': ['./src/bar/index.ts'],
133+
'#baz': ['./src/baz.ts'],
131134
},
132135
},
133136
}),
@@ -144,6 +147,7 @@ export default testSuite(({ describe }, nodePath: string) => {
144147
const content = await fixture.readFile('dist/index.mjs', 'utf8');
145148
expect(content).toMatch('"a"');
146149
expect(content).toMatch('"bar"');
150+
expect(content).toMatch('"baz"');
147151
});
148152
});
149153

0 commit comments

Comments
 (0)