You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We bundle our server app to give users more freedom with how they write their imports paths i.e. they can use the .js suffix or can leave it out.
One thing we noticed is that in our bundle, the wasp/ package is not bundled and we have to copy over the Wasp SDK when building the server Docker image: #2362 (comment)
We are missing the@rollup/plugin-node-resolve plugin which enables Rollup to bundle packages from node_modules.
Here's a working rollup.config.js file that bundles the Wasp SDK:
importesbuildfrom'rollup-plugin-esbuild'importnodeResolvefrom"@rollup/plugin-node-resolve";exportdefault[createBundle('src/server.ts','bundle/server.js'),createBundle('src/dbSeed.ts','bundle/dbSeed.js'),]/** * @param {string} inputFilePath * @param {string} outputFilePath * @returns {import('rollup').RollupOptions} */functioncreateBundle(inputFilePath,outputFilePath){return{input: inputFilePath,output: {file: outputFilePath,format: 'es',sourcemap: true,},plugins: [esbuild({target: 'esnext',}),// Using `modulesOnly` because I found it here: https://stackoverflow.com/questions/45707711/does-rollup-bundle-node-modules-into-bundle-jsnodeResolve({modulesOnly: true})],external: (id)=>{// Anything that's not a relative or absolute import or a wasp/ module - should not be bundled e.g. Express won't be bundledreturn!id.startsWith('.')&&!id.startsWith('/')&&!id.startsWith('wasp/')},treeshake: 'smallest'}}
The text was updated successfully, but these errors were encountered:
We bundle our server app to give users more freedom with how they write their imports paths i.e. they can use the
.js
suffix or can leave it out.One thing we noticed is that in our bundle, the
wasp/
package is not bundled and we have to copy over the Wasp SDK when building the server Docker image: #2362 (comment)We are missing the
@rollup/plugin-node-resolve
plugin which enables Rollup to bundle packages fromnode_modules
.Here's a working
rollup.config.js
file that bundles the Wasp SDK:The text was updated successfully, but these errors were encountered: