-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: create ts projects using esm and cjs
- Loading branch information
1 parent
380ce4b
commit 6349c22
Showing
14 changed files
with
131 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
runtime/JavaScript/spec/imports/setups/node-cjs-ts/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/node_modules | ||
|
||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const { CharStream } = require("antlr4"); | ||
|
||
const cs = new CharStream("OK"); | ||
|
||
console.log(cs.toString()); |
18 changes: 18 additions & 0 deletions
18
runtime/JavaScript/spec/imports/setups/node-cjs-ts/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "test-import-node-cjs-ts", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"type": "commonjs", | ||
"scripts": { | ||
"test": "bash test.sh" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"antlr4": "file:../../../.." | ||
}, | ||
"devDependencies": { | ||
"typescript": "^5.4.3" | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
runtime/JavaScript/spec/imports/setups/node-cjs-ts/test.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env bash | ||
|
||
tsconfigFiles=( | ||
"tsconfig.node.commonjs.json" | ||
) | ||
|
||
failure=0 | ||
|
||
for tsconfig in "${tsconfigFiles[@]}"; do | ||
echo -n "$tsconfig " | ||
|
||
./node_modules/.bin/tsc -p $tsconfig || { failure=1 ; echo "FAIL tsc: $tsconfig"; } | ||
result=$(node ./tsOutput/index.js) | ||
[[ $result == "OK" ]] && echo "OK" | ||
[[ $result != "OK" ]] && { failure=1 ; echo "FAIL runtime: $tsconfig"; } | ||
done | ||
|
||
exit $failure |
10 changes: 10 additions & 0 deletions
10
runtime/JavaScript/spec/imports/setups/node-cjs-ts/tsconfig.node.commonjs.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"skipLibCheck": true, | ||
"outDir": "./tsOutput", | ||
"module": "commonjs", | ||
"moduleResolution": "node" | ||
}, | ||
"include": ["index.ts"], | ||
} |
3 changes: 3 additions & 0 deletions
3
runtime/JavaScript/spec/imports/setups/node-esm-ts/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/node_modules | ||
|
||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { CharStream } from "antlr4"; | ||
|
||
const cs = new CharStream("OK"); | ||
|
||
console.log(cs.toString()); |
18 changes: 18 additions & 0 deletions
18
runtime/JavaScript/spec/imports/setups/node-esm-ts/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "test-import-node-esm-ts", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"type": "module", | ||
"scripts": { | ||
"test": "bash test.sh" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"antlr4": "file:../../../.." | ||
}, | ||
"devDependencies": { | ||
"typescript": "^5.4.3" | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
runtime/JavaScript/spec/imports/setups/node-esm-ts/test.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env bash | ||
|
||
tsconfigFiles=( | ||
"tsconfig.node16.json" | ||
"tsconfig.bundler.es2022.json" | ||
) | ||
|
||
failure=0 | ||
|
||
for tsconfig in "${tsconfigFiles[@]}"; do | ||
echo -n "$tsconfig " | ||
|
||
./node_modules/.bin/tsc -p $tsconfig || { failure=1 ; echo "FAIL tsc: $tsconfig"; } | ||
result=$(node ./tsOutput/index.js) | ||
[[ $result == "OK" ]] && echo "OK" | ||
[[ $result != "OK" ]] && { failure=1 ; echo "FAIL runtime: $tsconfig"; } | ||
done | ||
|
||
exit $failure |
10 changes: 10 additions & 0 deletions
10
runtime/JavaScript/spec/imports/setups/node-esm-ts/tsconfig.bundler.es2022.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"skipLibCheck": true, | ||
"outDir": "./tsOutput", | ||
"module": "es2022", | ||
"moduleResolution": "bundler" | ||
}, | ||
"include": ["index.ts"], | ||
} |
10 changes: 10 additions & 0 deletions
10
runtime/JavaScript/spec/imports/setups/node-esm-ts/tsconfig.node16.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"skipLibCheck": true, | ||
"outDir": "./tsOutput", | ||
"module": "node16", | ||
"moduleResolution": "node16" | ||
}, | ||
"include": ["index.ts"], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env bash | ||
|
||
cd spec/imports/setups/node-esm-ts | ||
npm run test | ||
cd ../node-cjs-ts | ||
npm run test |