Skip to content

Commit

Permalink
tests: add project24
Browse files Browse the repository at this point in the history
  • Loading branch information
justkey007 committed Jul 3, 2023
1 parent d2939fa commit b8243bb
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 3 deletions.
2 changes: 2 additions & 0 deletions projects/project24/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.idea/
node_modules/
37 changes: 37 additions & 0 deletions projects/project24/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# tsc-alias-bug-demo

Steps to reproduce https://github.com/justkey007/tsc-alias/issues/154:

1) Install dependencies
```sh
npm install
```

2) Start the app using `ts-node`
```sh
npm start
```
Output:
```
[Function: i18nConfigure]
Translation
```

3) Compile TS files and start the app
```sh
npm run build && node dist/index.js
```
Output:
```
console.log(i18n_1.default.configure);
^
TypeError: Cannot read property 'configure' of undefined
```
It happens because `dist/i18n/index.js` contains
```js
const i18n_1 = __importDefault(require("../i18n"));
```
instead of
```js
const i18n_1 = __importDefault(require("i18n"));
```
26 changes: 26 additions & 0 deletions projects/project24/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "tsc-alias-bug-demo",
"version": "1.0.0",
"description": "Demonstration of a bug with incorrect module path",
"private": true,
"main": "dist/index.js",
"scripts": {
"build": "npm install && tsc && tsc-alias",
"start": "npm run build && node dist/index.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Jokero/tsc-alias-bug.git"
},
"author": "Dmitry Kirilyuk <[email protected]>",
"license": "MIT",
"devDependencies": {
"@types/i18n": "^0.13.6",
"ts-node": "^10.9.1",
"tsc-alias": "^1.8.3",
"typescript": "^4.9.5"
},
"dependencies": {
"i18n": "^0.15.1"
}
}
5 changes: 5 additions & 0 deletions projects/project24/src/i18n/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import i18n from 'i18n';

console.log(i18n.configure);

export default () => 'Translation';
3 changes: 3 additions & 0 deletions projects/project24/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import i18n from './i18n';

console.log(i18n());
10 changes: 10 additions & 0 deletions projects/project24/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"module": "commonjs",
"esModuleInterop": true,
"moduleResolution": "node",
"target": "esnext",
"outDir": "dist"
},
"include": ["src/**/*"]
}
6 changes: 3 additions & 3 deletions tests/test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { join, normalize } from 'path';
import * as rimraf from 'rimraf';
import * as shell from 'shelljs';
import {
prepareSingleFileReplaceTscAliasPaths,
ReplaceTscAliasPathsOptions
ReplaceTscAliasPathsOptions,
prepareSingleFileReplaceTscAliasPaths
} from '../src';
import { newImportStatementRegex, newStringRegex } from '../src/utils';

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

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

0 comments on commit b8243bb

Please sign in to comment.