-
Notifications
You must be signed in to change notification settings - Fork 27.8k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
next/babel preset hard-codes directory path in output #1160
Comments
Poking around, I think it might work to remove all of the path up to and including the first instance of “node_modules/”:
Does that make sense as something to do? |
This seems to be an issue even when compiling directly on Heroku, as the build-time path and the runtime path are different. Note that I'm using the |
Looks like the webpack config is doing this, too. Here’s what it looks like in Heroku logs:
Note how Heroku built in a tmp directory but is running from an /app directory. I can have a PR for this up pretty soon. |
Without this, modules built with Babel or Webpack would have hard-coded absolute paths all the way back to the root of the filesystem. This prevented compilation and running on different machines or even from different directories on the same machine. With this change, paths are hard-coded to the top-most node_madules directory found, which should make them portable relative to the app. Fixes vercel#1160
There's some more context for you in #198 and #360! The current solution is using a Heroku buildpack: mars/heroku-nextjs I had hoped it would be as simple as removing everything up to |
Are the concerns in #361 still valid? React is now a peerDependency. The relative importing of I guess I also don't understand why the |
There are a few remaining concerns (though like you say, React as a peer mitigates one of them!) The I had toyed around with adding a "we are not running tests so pretty please don't use aliases on next modules" flag (or vice versa) - maybe this is something to be revisited.
There's also some issues surrounding using |
If the aliases are only needed for running Next.js’s own tests, it seems like the burden should be on the Next.js dev/test setup to get those right, rather than on every developer to manage the surprise of these hard-coded paths on their own. Compiling JS in one place and serving it somewhere else doesn't seem like so esoteric a pattern to me that it shouldn't be supported out-of-the-box. |
Without this, modules built with Babel or Webpack would have hard-coded absolute paths all the way back to the root of the filesystem. This prevented compilation and running on different machines or even from different directories on the same machine. With this change, paths are hard-coded to the top-most node_madules directory found, which should make them portable relative to the app. Fixes vercel#1160
Without this, modules built with Babel or Webpack would have hard-coded absolute paths all the way back to the root of the filesystem. This prevented compilation and running on different machines or even from different directories on the same machine. With this change, paths are hard-coded to the top-most node_madules directory found, which should make them portable relative to the app. Fixes vercel#1160
Without this, modules built with Babel or Webpack would have hard-coded absolute paths all the way back to the root of the filesystem. This prevented compilation and running on different machines or even from different directories on the same machine. With this change, paths are hard-coded to the top-most node_madules directory found, which should make them portable relative to the app. Fixes vercel#1160
Without this, modules built with Babel or Webpack would have hard-coded absolute paths all the way back to the root of the filesystem. This prevented compilation and running on different machines or even from different directories on the same machine. With this change, paths are hard-coded to the top-most node_madules directory found, which should make them portable relative to the app. Fixes #1160
The
babelRuntimePath
at the beginning of thebabel/preset.js
file results in the absolute path to the babel runtime being hard-coded into babel output. This means that e.g. server code cannot be babel-compiled in one location and run on another.I'm running into this by babel-compiling my server code on one machine and deploying the compiled versions to a server and running them there.
The text was updated successfully, but these errors were encountered: