From 4e840a0bb5427d81fd4e42f656adb8dadea5bf19 Mon Sep 17 00:00:00 2001 From: Peter Coulton Date: Mon, 11 Oct 2021 19:28:59 +0100 Subject: [PATCH 1/3] bug: add minimal reproduction of swc dynamic import bug --- example.ts | 8 +++++++- other.ts | 1 + run.sh | 2 +- tsconfig.json | 12 ++++++++++++ 4 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 other.ts create mode 100644 tsconfig.json diff --git a/example.ts b/example.ts index a201bd7..9239898 100644 --- a/example.ts +++ b/example.ts @@ -1 +1,7 @@ -console.log('Some .ts code reproducing a bug'); +const example = async () => { + const other = await import('./other') + console.log(other) +} + +example() + diff --git a/other.ts b/other.ts new file mode 100644 index 0000000..dedd3ac --- /dev/null +++ b/other.ts @@ -0,0 +1 @@ +export const foo = "bar" diff --git a/run.sh b/run.sh index d553b44..9a71837 100644 --- a/run.sh +++ b/run.sh @@ -7,7 +7,7 @@ n lts yarn # Run ts-node -yarn ts-node ./example.ts +yarn ts-node --project ./tsconfig.json ./example.ts echo "Process exited with code: $?" echo diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..b64c642 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "ts-node/node16/tsconfig.json", + + "ts-node": { + "transpileOnly": true, + "transpiler": "ts-node/transpilers/swc-experimental" + }, + + "include": ["*.ts"], + "exclude": ["node_modules"] + } + \ No newline at end of file From 366a888ae88c43fcc1d66b92e1194f4a6a4d1923 Mon Sep 17 00:00:00 2001 From: Peter Coulton Date: Mon, 11 Oct 2021 19:31:43 +0100 Subject: [PATCH 2/3] chore: trigger workflow --- example.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example.ts b/example.ts index 9239898..72366c4 100644 --- a/example.ts +++ b/example.ts @@ -3,5 +3,5 @@ const example = async () => { console.log(other) } -example() +example().then(() => console.log(`done`)) From aa2407e3cce403fdb79a880fc05caeb8d4851770 Mon Sep 17 00:00:00 2001 From: Peter Coulton Date: Mon, 11 Oct 2021 19:33:36 +0100 Subject: [PATCH 3/3] chore: add swc deps --- package.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 4d56496..ed08855 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,8 @@ { "dependencies": { "ts-node": "latest", - "typescript": "latest" + "typescript": "latest", + "@swc/core": "^1.2.95", + "@swc/helpers": "^0.2.13" } }