Git Product home page Git Product logo

Comments (7)

chrisDupuis avatar chrisDupuis commented on June 3, 2024 1

My solution is to replace @nx/esbuild:esbuild with
the @nx/webpack:webpack
and configure correctly the web pack config.

from nx-firebase.

Gurey avatar Gurey commented on June 3, 2024 1

We also solved it by using webpack instead of esbuild

This was some time ago so i am not 100% sure this config works today.

but in the project.json file set the targets.build to

    "build": {
      "executor": "@nx/webpack:webpack",
      "outputs": ["{options.outputPath}"],
      "defaultConfiguration": "production",
      "options": {
        "target": "node",
        "compiler": "tsc",
        "outputPath": "dist/apps/<APP_NAME>",
        "main": "apps/<APP_NAME>/src/main.ts",
        "tsConfig": "apps/<APP_NAME>/tsconfig.app.json",
        "assets": [
          "apps/<APP_NAME>/src/assets",
          {
            "glob": "**/*",
            "input": "apps/firebase/environment",
            "output": "."
          }
        ],
        "isolatedConfig": true,
        "webpackConfig": "apps/<APP_NAME>/webpack.config.js",
        "generatePackageJson": true
      },
      "configurations": {
        "development": {},
        "production": {}
      }
    },

And the webpack.config.js looks like

const { composePlugins, withNx } = require('@nx/webpack')

// Nx plugins for webpack.
module.exports = composePlugins(withNx(), config => {
  // Update the webpack config as needed here.
  // e.g. `config.plugins.push(new MyPlugin())`
  return config
})

from nx-firebase.

simondotm avatar simondotm commented on June 3, 2024

That's interesting to know @chrisDupuis thanks.

Yes, the plugin's use of esbuild for bundling functions is just one option. Webpack or rollup are also possible, just with the necessary changes to project.json for your functions.

from nx-firebase.

simondotm avatar simondotm commented on June 3, 2024

I would be interested in any links you might have for how esbuild might not be compatible with NestJs.

from nx-firebase.

simondotm avatar simondotm commented on June 3, 2024

Ah, just done a little research and I understand the issue now - esbuild by design does not handle typescript decorators. That is not great news and I didnt know this about esbuild.

Someone here is talking about using an esbuild plugin to pre-compile typescript before esbuild gets it.

https://hackernoon.com/using-typescript-decorators-with-esbuild

from nx-firebase.

simondotm avatar simondotm commented on June 3, 2024

Thanks @Gurey
I think at some point I'll look into making the choice of bundler an option for functions.

from nx-firebase.

simondotm avatar simondotm commented on June 3, 2024

As mentioned in the article I linked above, this esbuild plugin seems to be the way to go for decorators with esbuild.

https://github.com/thomaschaaf/esbuild-plugin-tsc

Would require an esbuild config for function projects that use decorators, so if anyone is able to experiment with this and share their solution that would be great.

https://nx.dev/nx-api/esbuild/executors/esbuild#esbuildconfig

from nx-firebase.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.