Sorry for the load of q…

1 minute read

(Sorry for the load of questions). I’m not sure if I’m misunderstanding something obvious here but I generated a new node app (it’s an aws lambda). It has a dependency on mysql. However, whenever I build it using ng build [app], it doesn’t bundle the mysql library with it. I’ve tried copying over the production settings in angular.json from my angular app and running a prod build but it still seems to only reference mysql, not bundle it. Do I have to do something special? I’ve looked through https://github.com/angular/angular-cli/wiki/build but non of these seem to work. Even enabling the separate vendor chunk doesn’t create a vendor chunk. GitHub: angular/angular-cli

Responses:

Turns out I had my module setting in tsconfig set to esnext when it should have been commonjs. That was the fix.

Never mind. Seems like it picked up my custom webpack config when I ran ng build from the directory of the app.

As of now, it looks like I need a custom config:

module.exports = context => ({
  ...context,
  target: 'node',
})

Double never mind. Even referencing the above in angular.json doesn’t seem to make ng build work from the root directory.

we ended up mantaining a second package.json in the folder of the app that gets copied over into dist by a preaffected:build npm script into dist/apps/myapp

Then, on the production server, we npm install deps from that package.json and start the application

I should mention the script that copies the package.json file is a custom node script launched via npm

We could’ve done it with webpack, but we didn’t want to eject the config or use some third party library to avoid ejecting

Updated: