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

Files outside of app directory will not be transpiled #5666

Swatinem opened this Issue Nov 13, 2018 · 2 comments


2 participants
Copy link

Swatinem commented Nov 13, 2018

Bug report

Describe the bug

I have a monorepo usecase, where I want to share code between the next app and other modules that are located outside of the app folder.

It will end up with this error:

{ Error: (client) ../foo.ts 1:0
Module parse failed: The keyword 'interface' is reserved (1:0)
You may need an appropriate loader to handle this file type.
> interface Foo {
|   prop: string;
| }
 @ ./pages/index.tsx 4:0-28 8:5-8
 @ multi ./pages/index.tsx

To Reproduce

I have set up a simple repo here, based on the next-typescript example:

Expected behavior

Whatever I import should be transpiled like everything else, period.

System information

  • OS: linux
  • Version of Next.js: next@7.0.2

Additional context

Related issue (possibly a duplicate?): zeit/next-plugins#234
Also related maybe:


This comment has been minimized.

Copy link

timneutkens commented Nov 13, 2018

Sounds like this is a duplicate of #706


This comment has been minimized.

Copy link

Swatinem commented Nov 14, 2018

Just for reference, this is the extremely ugly workaround I found for this:

    // NOTE(swatinem): we just assume the typescript loader is configured last
    const tsxRules = config.module.rules[config.module.rules.length - 1]

    // By default next-typescript only includes things in the app root for no real reason -_-
    // See:
    // See:
    tsxRules.include = undefined

    // Also, apparently babel does not search for the `.babelrc` based on the `root`
    // option correctly when the file to transpile is outside of the root.
    // See:
    // So we just pass a path to the babelrc manually here
    defaultLoaders.babel.options.configFile = path.join(__dirname, '.babelrc')

skmdev added a commit to skmdev/koa-next-ts that referenced this issue Dec 14, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment