Skip to content

Commit b8243bb

Browse files
committed
tests: add project24
1 parent d2939fa commit b8243bb

File tree

7 files changed

+86
-3
lines changed

7 files changed

+86
-3
lines changed

projects/project24/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.idea/
2+
node_modules/

projects/project24/README.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# tsc-alias-bug-demo
2+
3+
Steps to reproduce https://github.com/justkey007/tsc-alias/issues/154:
4+
5+
1) Install dependencies
6+
```sh
7+
npm install
8+
```
9+
10+
2) Start the app using `ts-node`
11+
```sh
12+
npm start
13+
```
14+
Output:
15+
```
16+
[Function: i18nConfigure]
17+
Translation
18+
```
19+
20+
3) Compile TS files and start the app
21+
```sh
22+
npm run build && node dist/index.js
23+
```
24+
Output:
25+
```
26+
console.log(i18n_1.default.configure);
27+
^
28+
TypeError: Cannot read property 'configure' of undefined
29+
```
30+
It happens because `dist/i18n/index.js` contains
31+
```js
32+
const i18n_1 = __importDefault(require("../i18n"));
33+
```
34+
instead of
35+
```js
36+
const i18n_1 = __importDefault(require("i18n"));
37+
```

projects/project24/package.json

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "tsc-alias-bug-demo",
3+
"version": "1.0.0",
4+
"description": "Demonstration of a bug with incorrect module path",
5+
"private": true,
6+
"main": "dist/index.js",
7+
"scripts": {
8+
"build": "npm install && tsc && tsc-alias",
9+
"start": "npm run build && node dist/index.js"
10+
},
11+
"repository": {
12+
"type": "git",
13+
"url": "git+https://github.com/Jokero/tsc-alias-bug.git"
14+
},
15+
"author": "Dmitry Kirilyuk <[email protected]>",
16+
"license": "MIT",
17+
"devDependencies": {
18+
"@types/i18n": "^0.13.6",
19+
"ts-node": "^10.9.1",
20+
"tsc-alias": "^1.8.3",
21+
"typescript": "^4.9.5"
22+
},
23+
"dependencies": {
24+
"i18n": "^0.15.1"
25+
}
26+
}

projects/project24/src/i18n/index.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import i18n from 'i18n';
2+
3+
console.log(i18n.configure);
4+
5+
export default () => 'Translation';

projects/project24/src/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import i18n from './i18n';
2+
3+
console.log(i18n());

projects/project24/tsconfig.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"compilerOptions": {
3+
"module": "commonjs",
4+
"esModuleInterop": true,
5+
"moduleResolution": "node",
6+
"target": "esnext",
7+
"outDir": "dist"
8+
},
9+
"include": ["src/**/*"]
10+
}

tests/test.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { join, normalize } from 'path';
44
import * as rimraf from 'rimraf';
55
import * as shell from 'shelljs';
66
import {
7-
prepareSingleFileReplaceTscAliasPaths,
8-
ReplaceTscAliasPathsOptions
7+
ReplaceTscAliasPathsOptions,
8+
prepareSingleFileReplaceTscAliasPaths
99
} from '../src';
1010
import { newImportStatementRegex, newStringRegex } from '../src/utils';
1111

@@ -92,7 +92,7 @@ it(`Import regex does not match edge cases from keywords in strings`, function (
9292

9393
// Run tests on projects. 9-11 are for testing fullpath file resolution
9494
[
95-
1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 21, 22, 23
95+
1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 21, 22, 23, 24
9696
].forEach((value) => {
9797
it(`Project ${value} runs after alias resolution`, () => {
9898
runTestProject(value);

0 commit comments

Comments
 (0)