-
Notifications
You must be signed in to change notification settings - Fork 1k
fix(@lit-labs/nextjs): update webpackModuleRulesTest regex for cross-… #5067
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
base: main
Are you sure you want to change the base?
fix(@lit-labs/nextjs): update webpackModuleRulesTest regex for cross-… #5067
Conversation
…platform (Windows & Linux) path matching
🦋 Changeset detectedLatest commit: 20df2b9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ChellappanRajan!
Just a couple of comments, and this needs a changeset. Run: npm run changeset, select this package, choose "patch" and enter a description.
packages/labs/nextjs/src/index.ts
Outdated
| const { | ||
| addDeclarativeShadowDomPolyfill = true, | ||
| webpackModuleRulesTest = /\/pages\/.*\.(?:j|t)sx?$|\/app\/.*\.(?:j|t)sx?$/, | ||
| webpackModuleRulesTest = /[\\/]pages[\\/].*\.(?:j|t)sx?$|[\\/]app[\\/].*\.(?:j|t)sx?$/, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only thing I worry about is \ being a valid file name character on Unixes. Can we construct the regex dynamically based on which operating system we're running on?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think it would be better to use the Node.js path package (https://nodejs.org/api/path.html#pathsep such as path.sep) to construct and check paths dynamically depending on the operating system?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that would be a good way to do it, along with the RegExp constructor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for confirming. I am currently away from my laptop. I will apply the changes and update the PR once I am back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback. I have addressed the comments — please take another look
packages/labs/nextjs/src/index.ts
Outdated
| addDeclarativeShadowDomPolyfill = true, | ||
| webpackModuleRulesTest = /\/pages\/.*\.(?:j|t)sx?$|\/app\/.*\.(?:j|t)sx?$/, | ||
| webpackModuleRulesTest = /[\\/]pages[\\/].*\.(?:j|t)sx?$|[\\/]app[\\/].*\.(?:j|t)sx?$/, | ||
| webpackModuleRulesExclude = [/next\/dist\//, /node_modules/], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to update the separators here too.
…ormalized path handling - Applied changes based on PR review comments - Ensured regex works cross-platform by normalizing path separators
…RulesTest regex update
Fix #5046