Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Files outside of app directory will not be transpiled #5666
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:
I have set up a simple repo here, based on the next-typescript example:
Whatever I import should be transpiled like everything else, period.
Related issue (possibly a duplicate?): zeit/next-plugins#234
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: https://github.com/zeit/next-plugins/blob/be21851f63e82845387e576f5f2ed3e5c448cb97/packages/next-typescript/index.js#L51 // See: https://github.com/zeit/next-plugins/issues/234 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: https://babeljs.io/docs/en/options#root // So we just pass a path to the babelrc manually here defaultLoaders.babel.options.configFile = path.join(__dirname, '.babelrc')