From 8fbee6ee2c2861e166025f1097cef228c77a1676 Mon Sep 17 00:00:00 2001 From: Semen Loktionov Date: Tue, 27 Feb 2024 12:27:26 +0200 Subject: [PATCH] fix swc compiled paths resolving, added strip leading paths, fix jest paths --- jest.config.base.js | 5 ----- packages/fetcher/.npmignore | 5 +++-- .swcrc => packages/fetcher/.swcrc | 0 packages/fetcher/jest.config.js | 7 +++++++ packages/fetcher/package.json | 4 ++-- packages/jac/.npmignore | 2 +- packages/jac/.swcrc | 31 ++++++++++++++++++++++++++++++ packages/jac/jest.config.js | 7 +++++++ packages/jac/package.json | 4 ++-- packages/reactivity/.npmignore | 2 +- packages/reactivity/.swcrc | 31 ++++++++++++++++++++++++++++++ packages/reactivity/jest.config.js | 7 +++++++ packages/reactivity/package.json | 4 ++-- packages/tools/.npmignore | 2 +- packages/tools/.swcrc | 31 ++++++++++++++++++++++++++++++ packages/tools/jest.config.js | 7 +++++++ packages/tools/package.json | 4 ++-- packages/w3p/.npmignore | 1 + packages/w3p/.swcrc | 31 ++++++++++++++++++++++++++++++ packages/w3p/jest.config.js | 7 +++++++ packages/w3p/package.json | 4 ++-- 21 files changed, 176 insertions(+), 20 deletions(-) rename .swcrc => packages/fetcher/.swcrc (100%) create mode 100644 packages/jac/.swcrc create mode 100644 packages/reactivity/.swcrc create mode 100644 packages/tools/.swcrc create mode 100644 packages/w3p/.swcrc diff --git a/jest.config.base.js b/jest.config.base.js index a6e2b4cf..6d2f88f2 100644 --- a/jest.config.base.js +++ b/jest.config.base.js @@ -1,6 +1,4 @@ const baseConfig = require('./jest.config.base') -const fs = require('fs') -const config = JSON.parse(fs.readFileSync(`${__dirname}/.swcrc`, 'utf-8')) module.exports = { ...baseConfig, @@ -9,9 +7,6 @@ module.exports = { '**/__tests__/**/*.+(ts|tsx|js)', '**/?(*.)+(spec|tests|test).+(ts|tsx|js)', ], - transform: { - '^.+\\.(t|j)sx?$': ['@swc/jest', { ...config, swcrc: false, exclude: [] }], - }, moduleNameMapper: { '^@/(.*)': '/src/$1', }, diff --git a/packages/fetcher/.npmignore b/packages/fetcher/.npmignore index 122f32f7..fcd829ee 100644 --- a/packages/fetcher/.npmignore +++ b/packages/fetcher/.npmignore @@ -1,5 +1,6 @@ +/src/tests/ +src/**/*.test.ts jest.config.js tsconfig.json tsconfig.build.json -postbuild.js -/src/tests +.swcrc diff --git a/.swcrc b/packages/fetcher/.swcrc similarity index 100% rename from .swcrc rename to packages/fetcher/.swcrc diff --git a/packages/fetcher/jest.config.js b/packages/fetcher/jest.config.js index cb9e24d6..6373bb98 100644 --- a/packages/fetcher/jest.config.js +++ b/packages/fetcher/jest.config.js @@ -1,3 +1,10 @@ +const fs = require('fs') +const config = JSON.parse(fs.readFileSync(`${__dirname}/.swcrc`, 'utf-8')) + module.exports = { ...require('../../jest.config.base.js'), + + transform: { + '^.+\\.(t|j)sx?$': ['@swc/jest', { ...config, swcrc: false, exclude: [] }], + }, }; diff --git a/packages/fetcher/package.json b/packages/fetcher/package.json index d852ea5b..1d72014a 100644 --- a/packages/fetcher/package.json +++ b/packages/fetcher/package.json @@ -34,8 +34,8 @@ "scripts": { "build": "yarn clean && yarn build:types && yarn build:cjs && yarn build:esm && yarn build:tsc-alias", "build:types": "tsc -p tsconfig.build.json --outDir ./dist/types --declaration --emitDeclarationOnly", - "build:cjs": "npx swc src -d ./dist/cjs --strip-leading-paths --config-file ../../.swcrc -C module.type=commonjs", - "build:esm": "npx swc src -d ./dist/esm --strip-leading-paths --out-file-extension mjs --config-file ../../.swcrc -C module.type=es6 isModule=true", + "build:cjs": "npx swc src -d ./dist/cjs --strip-leading-paths --config-file .swcrc -C module.type=commonjs", + "build:esm": "npx swc src -d ./dist/esm --strip-leading-paths --out-file-extension mjs --config-file .swcrc -C isModule=true", "build:tsc-alias": "tsc-alias -p tsconfig.json --outDir ./dist/types", "clean": "rm -rf dist", "test": "yarn jest --verbose", diff --git a/packages/jac/.npmignore b/packages/jac/.npmignore index e09d521a..fcd829ee 100644 --- a/packages/jac/.npmignore +++ b/packages/jac/.npmignore @@ -3,4 +3,4 @@ src/**/*.test.ts jest.config.js tsconfig.json tsconfig.build.json -postbuild.js +.swcrc diff --git a/packages/jac/.swcrc b/packages/jac/.swcrc new file mode 100644 index 00000000..982a3303 --- /dev/null +++ b/packages/jac/.swcrc @@ -0,0 +1,31 @@ +{ + "$schema": "https://json.schemastore.org/swcrc", + "jsc": { + "parser": { + "syntax": "typescript", + "jsx": false, + "dynamicImport": false, + "privateMethod": true, + "functionBind": false, + "exportDefaultFrom": false, + "exportNamespaceFrom": false, + "decorators": false, + "decoratorsBeforeExport": false, + "topLevelAwait": false, + "importMeta": false + }, + "baseUrl": ".", + "transform": null, + "target": "es2016", + "loose": false, + "externalHelpers": false, + "keepClassNames": true, + "preserveAllComments": true, + "paths": { + "@/*": ["src/*"] + } + }, + "exclude": ["examples","src/tests", ".test.ts"], + "minify": false, + "sourceMaps": "inline" +} diff --git a/packages/jac/jest.config.js b/packages/jac/jest.config.js index cb9e24d6..6373bb98 100644 --- a/packages/jac/jest.config.js +++ b/packages/jac/jest.config.js @@ -1,3 +1,10 @@ +const fs = require('fs') +const config = JSON.parse(fs.readFileSync(`${__dirname}/.swcrc`, 'utf-8')) + module.exports = { ...require('../../jest.config.base.js'), + + transform: { + '^.+\\.(t|j)sx?$': ['@swc/jest', { ...config, swcrc: false, exclude: [] }], + }, }; diff --git a/packages/jac/package.json b/packages/jac/package.json index c9364a0d..fad3c21e 100644 --- a/packages/jac/package.json +++ b/packages/jac/package.json @@ -34,8 +34,8 @@ "scripts": { "build": "yarn clean && yarn build:types && yarn build:cjs && yarn build:esm && yarn build:tsc-alias", "build:types": "tsc -p tsconfig.build.json --outDir ./dist/types --declaration --emitDeclarationOnly", - "build:cjs": "npx swc src -d ./dist/cjs --strip-leading-paths --config-file ../../.swcrc -C module.type=commonjs", - "build:esm": "npx swc src -d ./dist/esm --strip-leading-paths --out-file-extension mjs --config-file ../../.swcrc -C module.type=es6 isModule=true", + "build:cjs": "npx swc src -d ./dist/cjs --strip-leading-paths --config-file .swcrc -C module.type=commonjs", + "build:esm": "npx swc src -d ./dist/esm --strip-leading-paths --out-file-extension mjs --config-file .swcrc -C isModule=true", "build:tsc-alias": "tsc-alias -p tsconfig.json --outDir ./dist/types", "clean": "rm -rf dist", "test": "yarn jest --verbose", diff --git a/packages/reactivity/.npmignore b/packages/reactivity/.npmignore index e09d521a..fcd829ee 100644 --- a/packages/reactivity/.npmignore +++ b/packages/reactivity/.npmignore @@ -3,4 +3,4 @@ src/**/*.test.ts jest.config.js tsconfig.json tsconfig.build.json -postbuild.js +.swcrc diff --git a/packages/reactivity/.swcrc b/packages/reactivity/.swcrc new file mode 100644 index 00000000..982a3303 --- /dev/null +++ b/packages/reactivity/.swcrc @@ -0,0 +1,31 @@ +{ + "$schema": "https://json.schemastore.org/swcrc", + "jsc": { + "parser": { + "syntax": "typescript", + "jsx": false, + "dynamicImport": false, + "privateMethod": true, + "functionBind": false, + "exportDefaultFrom": false, + "exportNamespaceFrom": false, + "decorators": false, + "decoratorsBeforeExport": false, + "topLevelAwait": false, + "importMeta": false + }, + "baseUrl": ".", + "transform": null, + "target": "es2016", + "loose": false, + "externalHelpers": false, + "keepClassNames": true, + "preserveAllComments": true, + "paths": { + "@/*": ["src/*"] + } + }, + "exclude": ["examples","src/tests", ".test.ts"], + "minify": false, + "sourceMaps": "inline" +} diff --git a/packages/reactivity/jest.config.js b/packages/reactivity/jest.config.js index cb9e24d6..6373bb98 100644 --- a/packages/reactivity/jest.config.js +++ b/packages/reactivity/jest.config.js @@ -1,3 +1,10 @@ +const fs = require('fs') +const config = JSON.parse(fs.readFileSync(`${__dirname}/.swcrc`, 'utf-8')) + module.exports = { ...require('../../jest.config.base.js'), + + transform: { + '^.+\\.(t|j)sx?$': ['@swc/jest', { ...config, swcrc: false, exclude: [] }], + }, }; diff --git a/packages/reactivity/package.json b/packages/reactivity/package.json index ffefcbc3..a9dfaa52 100644 --- a/packages/reactivity/package.json +++ b/packages/reactivity/package.json @@ -34,8 +34,8 @@ "scripts": { "build": "yarn clean && yarn build:types && yarn build:cjs && yarn build:esm && yarn build:tsc-alias", "build:types": "tsc -p tsconfig.build.json --outDir ./dist/types --declaration --emitDeclarationOnly", - "build:cjs": "npx swc src -d ./dist/cjs --strip-leading-paths --config-file ../../.swcrc -C module.type=commonjs", - "build:esm": "npx swc src -d ./dist/esm --strip-leading-paths --out-file-extension mjs --config-file ../../.swcrc -C module.type=es6 isModule=true", + "build:cjs": "npx swc src -d ./dist/cjs --strip-leading-paths --config-file .swcrc -C module.type=commonjs", + "build:esm": "npx swc src -d ./dist/esm --strip-leading-paths --out-file-extension mjs --config-file .swcrc -C isModule=true", "build:tsc-alias": "tsc-alias -p tsconfig.json --outDir ./dist/types", "clean": "rm -rf dist", "test": "yarn jest --verbose", diff --git a/packages/tools/.npmignore b/packages/tools/.npmignore index ef7aa8ee..b626fc94 100644 --- a/packages/tools/.npmignore +++ b/packages/tools/.npmignore @@ -2,4 +2,4 @@ src/**/*.test.ts jest.config.js tsconfig.json tsconfig.build.json -postbuild.js +.swcrc diff --git a/packages/tools/.swcrc b/packages/tools/.swcrc new file mode 100644 index 00000000..982a3303 --- /dev/null +++ b/packages/tools/.swcrc @@ -0,0 +1,31 @@ +{ + "$schema": "https://json.schemastore.org/swcrc", + "jsc": { + "parser": { + "syntax": "typescript", + "jsx": false, + "dynamicImport": false, + "privateMethod": true, + "functionBind": false, + "exportDefaultFrom": false, + "exportNamespaceFrom": false, + "decorators": false, + "decoratorsBeforeExport": false, + "topLevelAwait": false, + "importMeta": false + }, + "baseUrl": ".", + "transform": null, + "target": "es2016", + "loose": false, + "externalHelpers": false, + "keepClassNames": true, + "preserveAllComments": true, + "paths": { + "@/*": ["src/*"] + } + }, + "exclude": ["examples","src/tests", ".test.ts"], + "minify": false, + "sourceMaps": "inline" +} diff --git a/packages/tools/jest.config.js b/packages/tools/jest.config.js index cb9e24d6..6373bb98 100644 --- a/packages/tools/jest.config.js +++ b/packages/tools/jest.config.js @@ -1,3 +1,10 @@ +const fs = require('fs') +const config = JSON.parse(fs.readFileSync(`${__dirname}/.swcrc`, 'utf-8')) + module.exports = { ...require('../../jest.config.base.js'), + + transform: { + '^.+\\.(t|j)sx?$': ['@swc/jest', { ...config, swcrc: false, exclude: [] }], + }, }; diff --git a/packages/tools/package.json b/packages/tools/package.json index c419482b..69ee5140 100644 --- a/packages/tools/package.json +++ b/packages/tools/package.json @@ -34,8 +34,8 @@ "scripts": { "build": "yarn clean && yarn build:types && yarn build:cjs && yarn build:esm && yarn build:tsc-alias", "build:types": "tsc -p tsconfig.build.json --outDir ./dist/types --declaration --emitDeclarationOnly", - "build:cjs": "npx swc src -d ./dist/cjs --strip-leading-paths --config-file ../../.swcrc -C module.type=commonjs", - "build:esm": "npx swc src -d ./dist/esm --strip-leading-paths --out-file-extension mjs --config-file ../../.swcrc -C module.type=es6 isModule=true", + "build:cjs": "npx swc src -d ./dist/cjs --strip-leading-paths --config-file .swcrc -C module.type=commonjs", + "build:esm": "npx swc src -d ./dist/esm --strip-leading-paths --out-file-extension mjs --config-file .swcrc -C isModule=true", "build:tsc-alias": "tsc-alias -p tsconfig.json --outDir ./dist/types", "clean": "rm -rf dist", "test": "yarn jest --verbose", diff --git a/packages/w3p/.npmignore b/packages/w3p/.npmignore index 635a3094..1ab122df 100644 --- a/packages/w3p/.npmignore +++ b/packages/w3p/.npmignore @@ -3,3 +3,4 @@ examples jest.config.js tsconfig.json tsconfig.build.json +.swcrc diff --git a/packages/w3p/.swcrc b/packages/w3p/.swcrc new file mode 100644 index 00000000..982a3303 --- /dev/null +++ b/packages/w3p/.swcrc @@ -0,0 +1,31 @@ +{ + "$schema": "https://json.schemastore.org/swcrc", + "jsc": { + "parser": { + "syntax": "typescript", + "jsx": false, + "dynamicImport": false, + "privateMethod": true, + "functionBind": false, + "exportDefaultFrom": false, + "exportNamespaceFrom": false, + "decorators": false, + "decoratorsBeforeExport": false, + "topLevelAwait": false, + "importMeta": false + }, + "baseUrl": ".", + "transform": null, + "target": "es2016", + "loose": false, + "externalHelpers": false, + "keepClassNames": true, + "preserveAllComments": true, + "paths": { + "@/*": ["src/*"] + } + }, + "exclude": ["examples","src/tests", ".test.ts"], + "minify": false, + "sourceMaps": "inline" +} diff --git a/packages/w3p/jest.config.js b/packages/w3p/jest.config.js index 62a14472..4a28f7a1 100644 --- a/packages/w3p/jest.config.js +++ b/packages/w3p/jest.config.js @@ -1,4 +1,11 @@ +const fs = require('fs') +const config = JSON.parse(fs.readFileSync(`${__dirname}/.swcrc`, 'utf-8')) + module.exports = { ...require('../../jest.config.base.js'), + + transform: { + '^.+\\.(t|j)sx?$': ['@swc/jest', { ...config, swcrc: false, exclude: [] }], + }, transformIgnorePatterns: ['/node_modules\/(?!@walletconnect/modal)(.*)'], }; diff --git a/packages/w3p/package.json b/packages/w3p/package.json index 19ea9a38..5516a68c 100644 --- a/packages/w3p/package.json +++ b/packages/w3p/package.json @@ -34,8 +34,8 @@ "scripts": { "build": "yarn clean && yarn build:types && yarn build:cjs && yarn build:esm && yarn build:tsc-alias", "build:types": "tsc -p tsconfig.build.json --outDir ./dist/types --declaration --emitDeclarationOnly", - "build:cjs": "npx swc src -d ./dist/cjs --strip-leading-paths --config-file ../../.swcrc -C module.type=commonjs", - "build:esm": "npx swc src -d ./dist/esm --strip-leading-paths --out-file-extension mjs --config-file ../../.swcrc -C module.type=es6 isModule=true", + "build:cjs": "npx swc src -d ./dist/cjs --strip-leading-paths --config-file .swcrc -C module.type=commonjs", + "build:esm": "npx swc src -d ./dist/esm --strip-leading-paths --out-file-extension mjs --config-file .swcrc -C isModule=true", "build:tsc-alias": "tsc-alias -p tsconfig.json --outDir ./dist/types", "clean": "rm -rf dist", "test": "yarn jest --verbose",