8000 chore: build using rspack and swc by DarkPhoenix2704 · Pull Request #9836 · nocodb/nocodb · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

chore: build using rspack and swc #9836

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release-timely-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jobs:
run: |
# build nocodb ( pack nocodb-sdk and nc-gui )
cd packages/nocodb &&
EE=true pnpm exec webpack --config webpack.timely.config.js &&
EE=true pnpm exec rspack --config rspack.timely.config.js &&
# remove bundled libraries (nocodb-sdk, knex-snowflake)
pnpm uninstall --save-prod nocodb-sdk

Expand Down
77 changes: 77 additions & 0 deletions packages/nocodb/docker/rspack.config.js
10000
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
const path = require('path');
const { rspack } = require('@rspack/core');
const { resolveTsAliases } = require('../build-utils/resolveTsAliases');
const nodeExternals = require('webpack-node-externals');
module.exports = {
entry: './src/run/dockerEntry.ts',
module: {
rules: [
{
test: /\.node$/,
loader: 'node-loader',
options: {
name: '[path][name].[ext]',
},
},
{
test: /\.tsx?$/,
exclude: /node_modules/,
loader: 'builtin:swc-loader',
options: {
jsc: {
parser: {
syntax: 'typescript',
tsx: true,
decorators: true,
dynamicImport: true,
},
transform: {
legacyDecorator: true,
decoratorMetadata: true,
},
target: 'es2017',
},
module: {
type: 'commonjs',
},
},
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js', '.json'],
alias: resolveTsAliases(path.resolve('tsconfig.json')),
},
output: {
path: require('path').resolve('./docker'),
filename: 'main.js',
library: 'libs',
libraryTarget: 'umd',
globalObject: "typeof self !== 'undefined' ? self : this",
},
optimization: {
minimize: true, //Update this to true or false
minimizer: [
new rspack.SwcJsMinimizerRspackPlugin({
minimizerOptions: {
compress: {
keep_classnames: true,
},
},
}),
],
nodeEnv: false,
},
externals: [nodeExternals({
allowlist: ['nocodb-sdk']
})],
plugins: [
new rspack.EnvironmentPlugin({
EE: true,
}),
],
target: 'node',
node: {
__dirname: false,
},
};
51 changes: 0 additions & 51 deletions packages/nocodb/docker/webpack.config.js

This file was deleted.

41 changes: 21 additions & 20 deletions packages/nocodb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"license": "AGPL-3.0-or-later",
"scripts": {
"build": "pnpm run docker:build",
"build:obfuscate": "EE=true webpack --config webpack.config.js",
"build:cli:module": "EE=true webpack --config webpack.cli.config.js",
"build:obfuscate": "EE=true rspack --config rspack.config.js",
"build:cli:module": "EE=true rspack --config rspack.cli.config.js",
"obfuscate:build:publish": "pnpm run build:obfuscate && pnpm publish .",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "pnpm run watch:run",
Expand All @@ -31,19 +31,19 @@
"test": "jest --runInBand --forceExit",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r @swc-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json",
"watch:run": "cross-env NC_DISABLE_TELE=true NODE_ENV=development EE=true nodemon -e ts,js -w ./src -x \"ts-node src/run/docker --log-error --project tsconfig.json\"",
"watch:run:mysql": "cross-env NC_DISABLE_TELE=true NODE_ENV=development EE=true nodemon -e ts,js -w ./src -x \"ts-node src/run/dockerRunMysql --log-error --project tsconfig.json\"",
"watch:run:pg": "cross-env NC_DISABLE_TELE=true NODE_ENV=development EE=true nodemon -e ts,js -w ./src -x \"ts-node src/run/dockerRunPG --log-error --project tsconfig.json\"",
"watch:run:playwright:mysql": "rm -f ./test_noco.db; cross-env DB_TYPE=mysql NC_DB=\"mysql2://localhost:3306?u=root&p=password&d=pw_ncdb\" PLAYWRIGHT_TEST=true NODE_ENV=test NC_DISABLE_TELE=true EE=true nodemon -e ts,js -w ./src -x \"ts-node src/run/testDocker --log-error --project tsconfig.json\"",
"watch:run:playwright:pg": "rm -f ./test_noco.db; cross-env DB_TYPE=pg NC_DB=\"pg://localhost:5432?u=postgres&p=password&d=pw_ncdb\" PLAYWRIGHT_TEST=true NODE_ENV=test NC_DISABLE_TELE=true EE=true nodemon -e ts,js -w ./src -x \"ts-node src/run/testDocker --log-error --project tsconfig.json\"",
"watch:run:playwright": "rm -f ./test_*.db; cross-env DB_TYPE=sqlite DATABASE_URL=sqlite:./test_noco.db PLAYWRIGHT_TEST=true NODE_ENV=test NC_DISABLE_TELE=true EE=true NC_SNAPSHOT_WINDOW_SEC=3 nodemon -e ts,js -w ./src -x \"ts-node src/run/testDocker --log-error --project tsconfig.json\"",
"watch:run:playwright:quick": "rm -f ./test_noco.db; cp ../../tests/playwright/fixtures/noco_0_91_7.db ./test_noco.db; cross-env NODE_ENV=test DATABASE_URL=sqlite:./test_noco.db NC_DISABLE_TELE=true EE=true nodemon -e ts,js -w ./src -x \"ts-node src/run/docker --log-error --project tsconfig.json\"",
"watch:run:playwright:pg:cyquick": "rm -f ./test_noco.db; cp ../../tests/playwright/fixtures/noco_0_91_7.db ./test_noco.db; cross-env NODE_ENV=test NC_DISABLE_TELE=true EE=true nodemon -e ts,js -w ./src -x \"ts-node src/run/dockerRunPG_CyQuick.ts --log-error --project tsconfig.json\"",
"test:unit": "cross-env EE=false NODE_ENV=test TS_NODE_PROJECT=./tests/unit/tsconfig.json mocha -r ts-node/register tests/unit/index.test.ts --recursive --timeout 300000 --exit --delay",
"test:unit:pg": "cp tests/unit/.pg.env tests/unit/.env; cross-env NODE_ENV=test EE=false TS_NODE_PROJECT=./tests/unit/tsconfig.json mocha -r ts-node/register tests/unit/index.test.ts --recursive --timeout 300000 --exit --delay",
"docker:build": "EE=\"true-xc-test\" webpack --config docker/webpack.config.js"
"watch:run": "cross-env NODE_ENV=development NC_DISABLE_TELE=true rspack serve --config rspack.dev.config.js --entry src/run/docker",
"watch:run:mysql": "cross-env NODE_ENV=development NC_DISABLE_TELE=true rspack serve --config rspack.dev.config.js --entry src/run/dockerRunMysql",
"watch:run:pg": "cross-env NODE_ENV=development NC_DISABLE_TELE=true rspack serve --config rspack.dev.config.js --entry src/run/dockerRunPG",
"watch:run:playwright": "rm -f ./test_*.db; cross-env DB_TYPE=sqlite DATABASE_URL=sqlite:./test_noco.db PLAYWRIGHT_TEST=true NODE_ENV=test NC_DISABLE_TELE=true NC_SNAPSHOT_WINDOW_SEC=3 rspack serve --config rspack.dev.config.js --entry src/run/testDocker",
"watch:run:playwright:mysql": "rm -f ./test_noco.db; cross-env DB_TYPE=mysql NC_DB=\"mysql2://localhost:3306?u=root&p=password&d=pw_ncdb\" PLAYWRIGHT_TEST=true NODE_ENV=test NC_DISABLE_TELE=true rspack serve --config rspack.dev.config.js --entry src/run/testDocker",
"watch:run:playwright:pg": "rm -f ./test_noco.db; cross-env DB_TYPE=pg NC_DB=\"pg://localhost:5432?u=postgres&p=password&d=pw_ncdb\" PLAYWRIGHT_TEST=true NODE_ENV=test NC_DISABLE_TELE=true rspack serve --config rspack.dev.config.js --entry src/run/testDocker", 5D39
"watch:run:playwright:quick": "rm -f ./test_noco.db; cp ../../tests/playwright/fixtures/noco_0_91_7.db ./test_noco.db; cross-env NODE_ENV=test DATABASE_URL=sqlite:./test_noco.db NC_DISABLE_TELE=true rspack serve --config rspack.dev.config.js --entry src/run/docker",
"watch:run:playwright:pg:cyquick": "rm -f ./test_noco.db; cp ../../tests/playwright/fixtures/noco_0_91_7.db ./test_noco.db; cross-env NODE_ENV=test NC_DISABLE_TELE=true rspack serve --config rspack.dev.config.js --entry src/run/dockerRunPG_CyQuick.ts",
"test:unit": "cross-env NODE_ENV=test TS_NODE_PROJECT=./tests/unit/tsconfig.json mocha --require @swc-node/register tests/unit/index.test.ts --recursive --timeout 300000 --exit --delay",
"test:unit:pg": "cp tests/unit/.pg.env tests/unit/.env; cross-env NODE_ENV=test TS_NODE_PROJECT=./tests/unit/tsconfig.json mocha --require @swc-node/register tests/unit/index.test.ts --recursive --timeout 300000 --exit --delay",
"docker:build": "EE=\"true-xc-test\" rspack --config docker/rspack.config.js"
},
"dependencies": {
"@aws-sdk/client-kafka": "^3.620.0",
Expand Down Expand Up @@ -163,6 +163,9 @@
"@nestjs/schematics": "^10.1.1",
"@nestjs/testing": "^10.3.8",
"@nestjsplus/dyn-schematics": "^1.0.12",
"@rspack/cli": "^1.1.1",
"@rspack/core": "^1.1.1",
"@swc-node/register": "^1.10.9",
"@types/content-disposition": "^0.5.8",
"@types/ejs": "^3.1.5",
"@types/express": "^4.17.21",
Expand All @@ -176,25 +179,23 @@
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"chai": "^4.4.1",
"copy-webpack-plugin": "^11.0.0",
"cross-env": "^7.0.3",
"eslint": "^8.56.0",
"eslint-config-prettier": "^8.10.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-functional": "^5.0.8",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-prettier": "^4.2.1",
"fork-ts-checker-webpack-plugin": "^9.0.2",
"jest": "29.7.0",
"mocha": "^10.3.0",
"node-loader": "^2.1.0",
"nodemon": "^3.0.3",
"prettier": "^2.8.8",
"source-map-support": "^0.5.21",
"run-script-webpack-plugin": "^0.2.0",
"supertest": "^6.3.4",
"ts-jest": "29.1.2",
"ts-loader": "^9.5.1",
"ts-node": "^10.9.2",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.3.3",
"webpack-cli": "^5.1.4"
"typescript": "^5.3.3"
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
const path = require('path');
const nodeExternals = require('webpack-node-externals');
const webpack = require('webpack');
const TerserPlugin = require('terser-webpack-plugin');
const { rspack } = require('@rspack/core');
const { resolveTsAliases } = require('./build-utils/resolveTsAliases');
const nodeExternals = require('webpack-node-externals');

module.exports = {
entry: './src/cli.ts',
Expand All @@ -20,21 +19,22 @@ module.exports = {
},
],
},

optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
extractComments: false,
new rspack.SwcJsMinimizerRspackPlugin({
minimizerOptions: {
format: {
comments: false,
},
},
}),
],
nodeEnv: false,
},
externals: [
nodeExternals({
allowlist: ['nocodb-sdk'],
}),
],
externals: [nodeExternals({
allowlist: ['nocodb-sdk']
})],
resolve: {
extensions: ['.tsx', '.ts', '.js', '.json'],
alias: resolveTsAliases(path.resolve('tsconfig.json')),
Expand All @@ -51,10 +51,12 @@ module.exports = {
__dirname: false,
},
plugins: [
new webpack.EnvironmentPlugin(['EE']),
new webpack.BannerPlugin({
new rspack.EnvironmentPlugin({
EE: true,
}),
new rspack.BannerPlugin({
banner: 'This is a generated file. Do not edit',
entryOnly:true
entryOnly: true,
}),
],
target: 'node',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,39 @@
const path = require('path');
const nodeExternals = require('webpack-node-externals');
const webpack = require('webpack');
const CopyPlugin = require('copy-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const { rspack } = require('@rspack/core');
const { resolveTsAliases } = require('./build-utils/resolveTsAliases');
const nodeExternals = require('webpack-node-externals');

module.exports = {
entry: './src/index.ts',
module: {
rules: [
{
test: /\.node$/,
loader: 'node-loader',
options: {
name: '[path][name].[ext]',
},
},
{
test: /\.tsx?$/,
exclude: /node_modules/,
use: {
loader: 'ts-loader',
options: {
transpileOnly: true,
loader: 'builtin:swc-loader',
options: {
jsc: {
parser: {
syntax: 'typescript',
tsx: true,
decorators: true,
dynamicImport: true,
},
transform: {
legacyDecorator: true,
decoratorMetadata: true,
},
target: 'es2017',
},
module: {
type: 'commonjs',
},
},
},
Expand All @@ -25,15 +43,19 @@ module.exports = {
optimization: {
minimize: true, //Update this to true or false
minimizer: [
new TerserPlugin({
terserOptions: {
keep_classnames: true,
new rspack.SwcJsMinimizerRspackPlugin({
minimizerOptions: {
compress: {
keep_classnames: true,
},
},
}),
],
nodeEnv: false,
},
externals: [nodeExternals()],
externals: [nodeExternals({
allowlist: ['nocodb-sdk']
})],
resolve: {
extensions: ['.tsx', '.ts', '.js', '.json'],
alias: resolveTsAliases(path.resolve('tsconfig.json')),
Expand All @@ -50,11 +72,12 @@ module.exports = {
__dirname: false,
},
plugins: [
new webpack.EnvironmentPlugin(['EE']),
new CopyPlugin({
new rspack.EnvironmentPlugin({
EE: true,
}),
new rspack.CopyRspackPlugin({
patterns: [{ from: 'src/public', to: 'public' }],
}),
],

target: 'node',
};
Loading
Loading
0