-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add projects to test typescript support with different compiler optio…
…ns (#4597) * test: create ts projects using esm and cjs Signed-off-by: Jonathan MASSUCHETTI <[email protected]> * misc: rename "projects" to "builds Signed-off-by: Jonathan MASSUCHETTI <[email protected]> * build(typescript): reference the new definition file in the package.json "types" fields Signed-off-by: Jonathan MASSUCHETTI <[email protected]> --------- Signed-off-by: Jonathan MASSUCHETTI <[email protected]>
- Loading branch information
1 parent
eec3ff1
commit 2a7904a
Showing
13 changed files
with
129 additions
and
1 deletion.
There are no files selected for viewing
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/builds/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/builds/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" | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
runtime/JavaScript/spec/imports/builds/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,19 @@ | ||
#!/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 loading runtime with config: $tsconfig"; } | ||
rm -rf ./tsOutput | ||
done | ||
|
||
exit $failure |
10 changes: 10 additions & 0 deletions
10
runtime/JavaScript/spec/imports/builds/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/builds/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/builds/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" | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
runtime/JavaScript/spec/imports/builds/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,20 @@ | ||
#!/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 loading runtime with config: $tsconfig"; } | ||
rm -rf ./tsOutput | ||
done | ||
|
||
exit $failure |
10 changes: 10 additions & 0 deletions
10
runtime/JavaScript/spec/imports/builds/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/builds/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/builds/node-esm-ts | ||
npm run test | ||
cd ../node-cjs-ts | ||
npm run test |