Skip to content

Commit

Permalink
fix swc compiled paths resolving, added strip leading paths, fix jest…
Browse files Browse the repository at this point in the history
… paths
  • Loading branch information
napalmpapalam committed Feb 27, 2024
1 parent 22180e1 commit 8fbee6e
Show file tree
Hide file tree
Showing 21 changed files with 176 additions and 20 deletions.
5 changes: 0 additions & 5 deletions jest.config.base.js
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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: {
'^@/(.*)': '<rootDir>/src/$1',
},
Expand Down
5 changes: 3 additions & 2 deletions packages/fetcher/.npmignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/src/tests/
src/**/*.test.ts
jest.config.js
tsconfig.json
tsconfig.build.json
postbuild.js
/src/tests
.swcrc
File renamed without changes.
7 changes: 7 additions & 0 deletions packages/fetcher/jest.config.js
Original file line number Diff line number Diff line change
@@ -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: [] }],
},
};
4 changes: 2 additions & 2 deletions packages/fetcher/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/jac/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ src/**/*.test.ts
jest.config.js
tsconfig.json
tsconfig.build.json
postbuild.js
.swcrc
31 changes: 31 additions & 0 deletions packages/jac/.swcrc
Original file line number Diff line number Diff line change
@@ -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"
}
7 changes: 7 additions & 0 deletions packages/jac/jest.config.js
Original file line number Diff line number Diff line change
@@ -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: [] }],
},
};
4 changes: 2 additions & 2 deletions packages/jac/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/reactivity/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ src/**/*.test.ts
jest.config.js
tsconfig.json
tsconfig.build.json
postbuild.js
.swcrc
31 changes: 31 additions & 0 deletions packages/reactivity/.swcrc
Original file line number Diff line number Diff line change
@@ -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"
}
7 changes: 7 additions & 0 deletions packages/reactivity/jest.config.js
Original file line number Diff line number Diff line change
@@ -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: [] }],
},
};
4 changes: 2 additions & 2 deletions packages/reactivity/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/tools/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ src/**/*.test.ts
jest.config.js
tsconfig.json
tsconfig.build.json
postbuild.js
.swcrc
31 changes: 31 additions & 0 deletions packages/tools/.swcrc
Original file line number Diff line number Diff line change
@@ -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"
}
7 changes: 7 additions & 0 deletions packages/tools/jest.config.js
Original file line number Diff line number Diff line change
@@ -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: [] }],
},
};
4 changes: 2 additions & 2 deletions packages/tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions packages/w3p/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ examples
jest.config.js
tsconfig.json
tsconfig.build.json
.swcrc
31 changes: 31 additions & 0 deletions packages/w3p/.swcrc
Original file line number Diff line number Diff line change
@@ -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"
}
7 changes: 7 additions & 0 deletions packages/w3p/jest.config.js
Original file line number Diff line number Diff line change
@@ -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)(.*)'],
};
4 changes: 2 additions & 2 deletions packages/w3p/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 8fbee6e

Please sign in to comment.