Rollup-plugin-typescript2: Pleas move check-tsconfig after merge config

Created on 21 Jun 2019  ·  4Comments  ·  Source: ezolenko/rollup-plugin-typescript2

We use "module": "commonjs" in tsconfig and in tsconfigOverride set to module: "es2015", this cause error:

Error: Incompatible tsconfig option. Module resolves to 'CommonJS'. This is incompatible with rollup, please use 'module: "ES2015"' or 'module: "ESNext"'.

I think is better to move check tsconfig logic after merge all config.

Most helpful comment

Ah, yeah, you need to start one level above: tsconfigOverride: { compilerOptions : { module: "es2015" } }

All 4 comments

Check is already after all overrides...

Could you post your rollup config and first part of plugin output at verbosity 3 (where it prints settings and parsed tsconfig)

The rollup config:

export async function buildCore() {
    const bundler = await rollup({
        context: 'null',
        input: {
            index: 'src/index.ts'
        },
        plugins: [
            typescript({
                verbosity: 3,
                clean: true,
                check: true,
                tsconfigOverride: {
                    module: "es2015"
                },
                tsconfig: './src/tsconfig.json',
                typescript: require('typescript'),
                useTsconfigDeclarationDir: true
            }),
        ]
    });

    await bundler.write({
        format: 'umd',
        dir: 'dist',
        name: 'kook',
        extend: false,
        sourcemap: true,
        esModule: false,
        banner: '/* Test banner */'
    });
}

The log:

[22:06:48] Requiring external module ts-node/register
[22:06:51] Using gulpfile ~Desktop\kookjs\core\gulpfile.ts
[22:06:51] Starting 'default'...
[22:06:51] Starting 'buildCore'...
[22:06:51] 'buildCore' errored after 123 ms
[22:06:51] Error: Incompatible tsconfig option. Module resolves to 'CommonJS'. This is incompatible with rollup, please use 'module: "ES2015"' or 'module: "ESNext"'.
at checkTsConfig (C:\Users\AlirezaDesktop\kookjs\core\node_modulesrollup-plugin-typescript2src\check-tsconfig.ts:9:9)
at parseTsConfig (C:\Users\AlirezaDesktop\kookjs\core\node_modulesrollup-plugin-typescript2src\parse-tsconfig.ts:50:2)
at Object.options (C:\Users\AlirezaDesktop\kookjs\core\node_modulesrollup-plugin-typescript2srcindex.ts:80:64)
at applyOptionHook (C:\Users\AlirezaDesktop\kookjs\core\node_modulesrollupdistrollup.js:17147:31)
at Array.reduce ()
at getInputOptions$1 (C:\Users\AlirezaDesktop\kookjs\core\node_modulesrollupdistrollup.js:17165:41)
at Object.rollup (C:\Users\AlirezaDesktop\kookjs\core\node_modulesrollupdistrollup.js:17209:30)
at C:\Users\AlirezaDesktop\kookjs\core\gulpfile.ts:17:27
at step (C:\Users\AlirezaDesktop\kookjs\core\node_modules\tslib\tslib.js:136:27)
at Object.next (C:\Users\AlirezaDesktop\kookjs\core\node_modules\tslib\tslib.js:117:57)
[22:06:51] 'default' errored after

Ah, yeah, you need to start one level above: tsconfigOverride: { compilerOptions : { module: "es2015" } }

Ah, yeah, you need to start one level above: tsconfigOverride: { compilerOptions : { module: "es2015" } }

这很棒,他解决了我的问题,Thanks

Was this page helpful?
0 / 5 - 0 ratings