0

Is there a way to run a post-build action(target) in a NX monorepo that will run a babel plugin stored inside that same monorepo, for transforming some values in prebuilt javascript code?

I'm trying something like this:

project.json:

"post-build": {
      "executor": "@nrwl/webpack:webpack",
      "outputs": ["{options.outputPath}"],
      "options": {
        "compiler": "babel",
        "outputPath": "dist/packages/mylib",
        "main": "packages/mylib/src/index.ts",
        "tsConfig": "packages/mylib/tsconfig.lib.json"
      }
 }

.babelrc:

{
  "plugins": [
    "@myworkplace/my-custom-babel-plugin"
  ]
}

tsconfig.json:

{
  
  "compilerOptions": {
    "rootDir": ".",
    "baseUrl": ".",
    ....
    "paths": {
      "@myworkplace/my-custom-babel-plugin": ["packages/my-custom-babel-plugin/src/index.ts"]
    }
  }
}

Unfortunately, with this approach I always receive the following error: UnhandledPromiseRejectionWarning: Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@myworkplace/my-custom-babel-plugin' imported from C:\Users\user\...\babel-virtual-resolve-base.js.

Mordred
  • 3,734
  • 3
  • 36
  • 55

0 Answers0