nx monorepo - NX Generators - Set module to "ESNext" instead of "commonjs" in tsconfig.json

I want to create an NX generator to ensure that newly generated projects e.g. of type @nxjs:library ha

I want to create an NX generator to ensure that newly generated projects e.g. of type @nx/js:library have their compilerOptions module value set to "ESNext" and not "commonjs" at creation.

I tried adding the following generator to my nx.json file (without success):

"generators": {
    "@nx/js:library": {
        "compilerOptions": {
            "module": "ESNext"
        }
    }
}

I continue to generate the nx project using:

NX  Generating @nx/js:library

UPDATE package.json
CREATE libs/test/tsconfig.lib.json
CREATE libs/test/tsconfig.json
CREATE libs/test/src/index.ts
CREATE libs/test/src/lib/test.spec.ts
CREATE libs/test/src/lib/test.ts
CREATE libs/test/README.md
CREATE libs/test/package.json
UPDATE nx.json
CREATE libs/test/project.json
CREATE libs/test/.eslintrc.json
CREATE libs/test/jest.config.ts
CREATE libs/test/tsconfig.spec.json
UPDATE tsconfig.base.json

UPDATE nx.json*  Executing task: npx nx generate @nx/js:library libs/test --name=test --no-interactive --dry-run

The outcome of the generated project's tsconfig.json always ends up with "module": "commonjs":

{
    "extends": "../../tsconfig.base.json",
    "compilerOptions": {
        "module": "commonjs",
        "forceConsistentCasingInFileNames": true,
        "strict": true,
        "noImplicitOverride": true,
        "noImplicitReturns": true,
        "noFallthroughCasesInSwitch": true,
        "noPropertyAccessFromIndexSignature": true
    },
    "files": [],
    "include": [],
    "references": [
        {
            "path": "./tsconfig.lib.json"
        },
        {
            "path": "./tsconfig.spec.json"
        }
    ]
}

The tsconfig.base.json file do have "module" set to "ESNext". Maybe this does not make a difference, but I want to clarify it is not set to "commonjs" in the base tsconfig file.

How can I achieve what I wish for? Thanks!

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745125009a4612636.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信