Repository navigation
Also rewrite requires in page templates with Webpack - #95446
Merged
Merged
Conversation
Member
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Contributor
Tests PassedCommit: 3a82587 |
Contributor
Stats cancelledCommit: 3a82587 |
mischnic
force-pushed
the
mischnic/webpack-tempalte-require-rerwite
branch
from
July 3, 2026 07:57
4f31060 to
3a82587
Compare
Ziiyodullayevv
left a comment
There was a problem hiding this comment.
Nice improvement to the import path regex. The changes:
- Adding require() support alongside from and import
- Using LazyLock for regex compilation is efficient
- The capture group handling with or_else is clean
One observation: The regex now handles three cases (from, import, require). Consider adding a comment explaining why require support was added - was there a specific use case?
The code is well-structured and the refactoring makes it more maintainable.
mischnic
marked this pull request as ready for review
July 3, 2026 09:33
sokra
approved these changes
Jul 6, 2026
m-kawafuji
pushed a commit
to m-kawafuji/next.js
that referenced
this pull request
Aug 8, 2026
Thus far, it wasn't possible to use `require()` in a template file with
Webpack.
But I needed to add a `if(NEXT_RUNTIME !== "edge") { const x =
require("../../something"); }`
Turbopack doesn't do any regex rewrite hacks, so this just worked
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Thus far, it wasn't possible to use
require()in a template file with Webpack.But I needed to add a
if(NEXT_RUNTIME !== "edge") { const x = require("../../something"); }Turbopack doesn't do any regex rewrite hacks, so this just worked