From c69143fe7749f5157c6319ec9e75d1aa9aba6cf7 Mon Sep 17 00:00:00 2001 From: Tyler van Hensbergen Date: Tue, 6 Sep 2022 13:39:58 -0600 Subject: [PATCH 1/4] wip: register hook --- .eslintrc.json | 1 + .projenrc.ts | 2 +- .swcrc | 29 ----------------------------- register.js | 26 ++++++++++++++++++++++++++ test-app/.swcrc | 29 ----------------------------- test-app/cdk.json | 2 +- 6 files changed, 29 insertions(+), 60 deletions(-) delete mode 100644 .swcrc create mode 100644 register.js delete mode 100644 test-app/.swcrc diff --git a/.eslintrc.json b/.eslintrc.json index 5a222b9e..b2dd0454 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -37,6 +37,7 @@ }, "ignorePatterns": [ "scripts/**", + "register.js", "!.projenrc.ts", "!projenrc/**/*.ts" ], diff --git a/.projenrc.ts b/.projenrc.ts index bf4fcb3e..ca410373 100644 --- a/.projenrc.ts +++ b/.projenrc.ts @@ -145,7 +145,7 @@ const project = new CustomTypescriptProject({ ], eslintOptions: { dirs: ["src", "test"], - ignorePatterns: ["scripts/**"], + ignorePatterns: ["scripts/**", "register.js"], lintProjenRc: false, }, tsconfig: { diff --git a/.swcrc b/.swcrc deleted file mode 100644 index c6c9553a..00000000 --- a/.swcrc +++ /dev/null @@ -1,29 +0,0 @@ -{ - "jsc": { - "parser": { - "syntax": "typescript", - "dynamicImport": false, - "decorators": false, - "hidden": { - "jest": true - } - }, - "transform": null, - "target": "es2021", - "loose": false, - "externalHelpers": false, - "experimental": { - "plugins": [ - [ - "@functionless/ast-reflection", - {} - ] - ] - } - }, - "minify": true, - "sourceMaps": "inline", - "module": { - "type": "commonjs" - } -} diff --git a/register.js b/register.js new file mode 100644 index 00000000..e7f220ac --- /dev/null +++ b/register.js @@ -0,0 +1,26 @@ +const register = require("@swc/register/lib/node").default; + +register({ + jsc: { + parser: { + syntax: "typescript", + dynamicImport: false, + decorators: false, + hidden: { + jest: true, + }, + }, + transform: null, + target: "es2022", + loose: false, + externalHelpers: false, + experimental: { + plugins: [["@functionless/ast-reflection", {}]], + }, + }, + minify: true, + sourceMaps: "inline", + module: { + type: "commonjs", + }, +}); diff --git a/test-app/.swcrc b/test-app/.swcrc deleted file mode 100644 index 7a21792b..00000000 --- a/test-app/.swcrc +++ /dev/null @@ -1,29 +0,0 @@ -{ - "jsc": { - "parser": { - "syntax": "typescript", - "dynamicImport": false, - "decorators": false, - "hidden": { - "jest": true - } - }, - "transform": null, - "target": "es2021", - "loose": false, - "externalHelpers": false, - "experimental": { - "plugins": [ - [ - "@functionless/ast-reflection", - {} - ] - ] - } - }, - "minify": false, - "sourceMaps": "inline", - "module": { - "type": "commonjs" - } -} diff --git a/test-app/cdk.json b/test-app/cdk.json index da048aa5..d7a8d03a 100644 --- a/test-app/cdk.json +++ b/test-app/cdk.json @@ -1,3 +1,3 @@ { - "app": "node -r '@swc/register' ./src/message-board.ts" + "app": "node -r 'functionless/register' ./src/message-board.ts" } From c8197434dd6af441fa7f47fb4f7b3c0c2bd7854d Mon Sep 17 00:00:00 2001 From: github-actions Date: Tue, 6 Sep 2022 20:56:50 +0000 Subject: [PATCH 2/4] chore: self mutation Signed-off-by: github-actions --- .swcrc | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .swcrc diff --git a/.swcrc b/.swcrc new file mode 100644 index 00000000..c6c9553a --- /dev/null +++ b/.swcrc @@ -0,0 +1,29 @@ +{ + "jsc": { + "parser": { + "syntax": "typescript", + "dynamicImport": false, + "decorators": false, + "hidden": { + "jest": true + } + }, + "transform": null, + "target": "es2021", + "loose": false, + "externalHelpers": false, + "experimental": { + "plugins": [ + [ + "@functionless/ast-reflection", + {} + ] + ] + } + }, + "minify": true, + "sourceMaps": "inline", + "module": { + "type": "commonjs" + } +} From 819bdd9a605d5fe90a454717cdd8b9aed2756d5e Mon Sep 17 00:00:00 2001 From: Tyler van Hensbergen Date: Tue, 6 Sep 2022 15:01:30 -0600 Subject: [PATCH 3/4] sync projen --- .gitattributes | 1 - .gitignore | 1 - .projen/files.json | 1 - .projenrc.ts | 30 +----------------------------- 4 files changed, 1 insertion(+), 32 deletions(-) diff --git a/.gitattributes b/.gitattributes index 81a5e951..87b23178 100644 --- a/.gitattributes +++ b/.gitattributes @@ -18,7 +18,6 @@ /.projen/deps.json linguist-generated /.projen/files.json linguist-generated /.projen/tasks.json linguist-generated -/.swcrc linguist-generated /LICENSE linguist-generated /package.json linguist-generated /tsconfig.dev.json linguist-generated diff --git a/.gitignore b/.gitignore index aab84bfb..6a423edd 100644 --- a/.gitignore +++ b/.gitignore @@ -54,4 +54,3 @@ junit.xml /dist/ !/.eslintrc.json !/.git/hooks/pre-commit -!/.swcrc diff --git a/.projen/files.json b/.projen/files.json index d7e2e5b5..2afb3380 100644 --- a/.projen/files.json +++ b/.projen/files.json @@ -16,7 +16,6 @@ ".projen/deps.json", ".projen/files.json", ".projen/tasks.json", - ".swcrc", "LICENSE", "tsconfig.dev.json", "tsconfig.json" diff --git a/.projenrc.ts b/.projenrc.ts index ca410373..e439ac5f 100644 --- a/.projenrc.ts +++ b/.projenrc.ts @@ -1,6 +1,6 @@ import { readFileSync, writeFileSync, chmodSync } from "fs"; import { join } from "path"; -import { typescript, TextFile, JsonFile, Project } from "projen"; +import { typescript, TextFile, Project } from "projen"; import { GithubCredentials } from "projen/lib/github"; /** @@ -180,34 +180,6 @@ const project = new CustomTypescriptProject({ delete project.jest!.config.globals; delete project.jest!.config.preset; -new JsonFile(project, ".swcrc", { - marker: false, // swc's JSON schema is super strict, so disable the `"//": "generated by projen" marker - obj: { - jsc: { - parser: { - syntax: "typescript", - dynamicImport: false, - decorators: false, - hidden: { - jest: true, - }, - }, - transform: null, - target: "es2021", - loose: false, - externalHelpers: false, - experimental: { - plugins: [["@functionless/ast-reflection", {}]], - }, - }, - minify: true, - sourceMaps: "inline", - module: { - type: "commonjs", - }, - }, -}); - const packageJson = project.tryFindObjectFile("package.json")!; packageJson.addOverride("lint-staged", { From b4168bd7f5d87e9fc3612fbfd672f54bbb3bc521 Mon Sep 17 00:00:00 2001 From: Tyler van Hensbergen Date: Wed, 7 Sep 2022 14:15:06 -0600 Subject: [PATCH 4/4] re-add swcrc config at root for tests --- .gitattributes | 1 + .gitignore | 1 + .projen/files.json | 1 + .projenrc.ts | 30 +++++++++++++++++++++++++++++- 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/.gitattributes b/.gitattributes index 87b23178..81a5e951 100644 --- a/.gitattributes +++ b/.gitattributes @@ -18,6 +18,7 @@ /.projen/deps.json linguist-generated /.projen/files.json linguist-generated /.projen/tasks.json linguist-generated +/.swcrc linguist-generated /LICENSE linguist-generated /package.json linguist-generated /tsconfig.dev.json linguist-generated diff --git a/.gitignore b/.gitignore index 6a423edd..aab84bfb 100644 --- a/.gitignore +++ b/.gitignore @@ -54,3 +54,4 @@ junit.xml /dist/ !/.eslintrc.json !/.git/hooks/pre-commit +!/.swcrc diff --git a/.projen/files.json b/.projen/files.json index 2afb3380..d7e2e5b5 100644 --- a/.projen/files.json +++ b/.projen/files.json @@ -16,6 +16,7 @@ ".projen/deps.json", ".projen/files.json", ".projen/tasks.json", + ".swcrc", "LICENSE", "tsconfig.dev.json", "tsconfig.json" diff --git a/.projenrc.ts b/.projenrc.ts index e439ac5f..ca410373 100644 --- a/.projenrc.ts +++ b/.projenrc.ts @@ -1,6 +1,6 @@ import { readFileSync, writeFileSync, chmodSync } from "fs"; import { join } from "path"; -import { typescript, TextFile, Project } from "projen"; +import { typescript, TextFile, JsonFile, Project } from "projen"; import { GithubCredentials } from "projen/lib/github"; /** @@ -180,6 +180,34 @@ const project = new CustomTypescriptProject({ delete project.jest!.config.globals; delete project.jest!.config.preset; +new JsonFile(project, ".swcrc", { + marker: false, // swc's JSON schema is super strict, so disable the `"//": "generated by projen" marker + obj: { + jsc: { + parser: { + syntax: "typescript", + dynamicImport: false, + decorators: false, + hidden: { + jest: true, + }, + }, + transform: null, + target: "es2021", + loose: false, + externalHelpers: false, + experimental: { + plugins: [["@functionless/ast-reflection", {}]], + }, + }, + minify: true, + sourceMaps: "inline", + module: { + type: "commonjs", + }, + }, +}); + const packageJson = project.tryFindObjectFile("package.json")!; packageJson.addOverride("lint-staged", {