We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
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
System: OS: macOS 14.6.1 CPU: (10) arm64 Apple M1 Max Memory: 1.20 GB / 32.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 20.18.0 - ~/.nvm/versions/node/v20.18.0/bin/node npm: 10.8.2 - ~/.nvm/versions/node/v20.18.0/bin/npm pnpm: 9.12.3 - ~/.nvm/versions/node/v20.18.0/bin/pnpm bun: 1.0.0 - ~/.bun/bin/bun Browsers: Chrome: 136.0.7103.114 Safari: 17.6 npmPackages: @rspack/cli: catalog: => 1.3.8 @rspack/core: catalog: => 1.3.8
I'm struggling to set up nestjs in my local app.
I see a lot of issues that look like this:
I also saw a lot of issues that look like this:
Inspired by #2741
I created an rspack config that looks like this:
const { RunScriptWebpackPlugin } = require('run-script-webpack-plugin'); const { rspack } = require('@rspack/core'); /** @type {import('@rspack/cli').Configuration} */ const config = { context: __dirname, target: 'node', entry: { main: ['@rspack/core/hot/poll?100', './src/main.ts'], }, resolve: { extensions: ['...', '.ts', '.tsx', '.jsx'], }, module: { rules: [ { test: /\.ts$/, use: { loader: 'builtin:swc-loader', options: { jsc: { parser: { syntax: 'typescript', decorators: true, }, transform: { legacyDecorator: true, decoratorMetadata: true, }, }, }, }, }, ], }, optimization: { minimize: false, minimizer: [ new rspack.SwcJsMinimizerRspackPlugin({ minimizerOptions: { // We need to disable mangling and compression for class names and function names for Nest.js to work properly // The execution context class returns a reference to the class/handler function, which is for example used for applying metadata using decorators // https://docs.nestjs.com/fundamentals/execution-context#executioncontext-class compress: { keep_classnames: true, keep_fnames: true, }, mangle: { keep_classnames: true, keep_fnames: true, }, }, }), ], }, externalsType: 'commonjs', plugins: [ !process.env.BUILD && new RunScriptWebpackPlugin({ name: 'main.js', autoRestart: false, }), ].filter(Boolean), devServer: { devMiddleware: { writeToDisk: true, }, }, externals: [ function (obj, callback) { const resource = obj.request; const lazyImports = [ '@nestjs/core', '@nestjs/microservices', '@nestjs/platform-express', 'cache-manager', 'class-validator', 'class-transformer', // ADD THIS '@nestjs/microservices/microservices-module', '@nestjs/microservices/server', '@nestjs/websockets', 'amqplib', 'nats', 'socket.io-adapter', 'utf-8-validate', 'bufferutil', 'kerberos', '@mongodb-js/zstd', 'snappy', '@aws-sdk/credential-providers', 'mongodb-client-encryption', '@nestjs/websockets/socket-module', 'bson-ext', 'snappy/package.json', 'aws4', 'lua', 'sharp', 'amqp-connection-manager', 'swc-loader', 'node-gyp', 'pg-native', 'loader-utils', 'fsevents', 'kafkajs', 'mqtt', '@swc/wasm', '@swc/core', '@swc/core-darwin-arm64', 'swc+core-darwin-arm64', '@apollo/gateway', 'apollo-server-fastify', 'mock-aws-s3', '@mapbox+node-pre-gyp', 'ts-morph', ]; const requireImports = ['node-gyp', 'shard', 'sharp', 'fsevents']; if (requireImports.includes(resource)) { require.resolve(resource); callback(null, resource); return; } if (!lazyImports.includes(resource)) { return callback(); } try { require.resolve(resource); } catch (err) { callback(null, resource); } callback(); }, ], }; module.exports = config;
https://github.com/MIreland/nestjs-rspack
The text was updated successfully, but these errors were encountered:
Also, how do I know what I should/shouldn't be putting in lazyImports in that config?
lazyImports
Sorry, something went wrong.
No branches or pull requests
System Info
Details
I'm struggling to set up nestjs in my local app.
I see a lot of issues that look like this:
I also saw a lot of issues that look like this:
Inspired by #2741
I created an rspack config that looks like this:
Reproduce link
https://github.com/MIreland/nestjs-rspack
Reproduce Steps
The text was updated successfully, but these errors were encountered: