Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The output of getCustomTransformers makes compiling fail when tsconfig.json contains rootDir. #597

Closed
zheeeng opened this issue Aug 9, 2017 · 3 comments · Fixed by #598

Comments

@zheeeng
Copy link

zheeeng commented Aug 9, 2017

versions:

"typescript": "~2.4.0",
"ts-loader": "^2.2.1",

The test code:

// webpack.config.js
// path: module.rules

      {
        test: /\.(ts|tsx)$/,
        include: paths.appSrc,
        loader: require.resolve('ts-loader'),
        options: {
          transpileOnly: true,
          getCustomTransformers: () => ({
            before: [ content => node => node ] // Issue caused by here!!!!!!!!!!
          }),
        },
      }

complier print:

error TS6059: File 'index.tsx' is not under 'rootDir' '/Users/Zheeeng/Workspace/project/src'. 'rootDir' is expected to contain all source files.

The tsconfig.json:

"compilerOptions": {
    "rootDir": "src"
}

Does the getCustomTransformers saved the temp content to other place and fails the compiling?

I encountered this issue while I'm using ts-import-plugin, and reported it at ts-plugin/ts-import-plugin#5. After a simple test, I find it's something wrong with ts-loader.

@johnnyreilly
Copy link
Member

Do you have any ideas @longlho or @Igorbek?

@Brooooooklyn
Copy link
Contributor

Brooooooklyn commented Aug 9, 2017

This issue is actually cased by transpileOnly option.
if this option was passed to ts-loader, it would use ts.compiler.transpileModule.

Because of https://github.com/Microsoft/TypeScript/blob/master/src/services/transpile.ts#L92 and https://github.com/Microsoft/TypeScript/blob/master/src/compiler/program.ts#L1797
we shouldn't pass rootDir to compiler.transpileModule.

I will fix it later with a pull request.

@zheeeng
Copy link
Author

zheeeng commented Aug 9, 2017

@Brooooooklyn Thx for your work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants