Browse Source

wip: rspack

nc-rspack-swc
DarkPhoenix2704 2 weeks ago
parent
commit
d85d8e91c7
  1. 96
      packages/nocodb/rspack.dev.base.config.js
  2. 7
      packages/nocodb/src/Noco.ts

96
packages/nocodb/rspack.dev.base.config.js

@ -0,0 +1,96 @@
const { join } = require('path');
const { rspack } = require('@rspack/core');
const NodeExternals = require('webpack-node-externals');
const { RunScriptWebpackPlugin } = require('run-script-webpack-plugin');
const baseDevConfig = {
mode: 'development',
target: 'node',
devtool: 'eval-source-map',
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',
},
},
},
],
},
externals: [
NodeExternals({
allowlist: ['webpack/hot/poll?1000'],
}),
{
'@nestjs/microservices': '@nestjs/microservices',
'@nestjs/microservices/microservices-module':
'@nestjs/microservices/microservices-module',
sharp: 'commonjs sharp',
'nocodb-sdk': 'nocodb-sdk',
'pg-query-stream': 'pg-query-stream',
'better-sqlite3': 'better-sqlite3',
oracledb: 'oracledb',
'pg-native': 'pg-native',
'@nestjs/graphql': '@nestjs/graphql',
pg: 'commonjs pg',
knex: 'commonjs knex',
},
],
resolve: {
extensions: ['.tsx', '.ts', '.js', '.json', '.node'],
},
optimization: {
minimize: false,
nodeEnv: false,
},
plugins: [
new rspack.EnvironmentPlugin({
EE: true,
NODE_ENV: 'development',
}),
new RunScriptWebpackPlugin({
name: 'main.js',
autoRestart: true,
}),
],
output: {
path: join(__dirname, 'dist'),
filename: 'main.js',
library: {
type: 'commonjs2',
},
clean: true,
},
devServer: {
devMiddleware: {
writeToDisk: true,
},
port: 9001,
},
};
module.exports = baseDevConfig;

7
packages/nocodb/src/Noco.ts

@ -96,6 +96,8 @@ export default class Noco {
return (this.ee = false);
}
declare module: any;
static async init(param: any, httpServer: http.Server, server: Express) {
const nestApp = await NestFactory.create(AppModule, {
bufferLogs: true,
@ -103,6 +105,11 @@ export default class Noco {
this.initCustomLogger(nestApp);
nestApp.flushLogs();
if (module.hot) {
module.hot.accept();
module.hot.dispose(() => nestApp.close());
}
try {
this.sharp = (await import('sharp')).default;
} catch {

Loading…
Cancel
Save