-
-
Notifications
You must be signed in to change notification settings - Fork 51
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
fix: forward options when calling this.resolve
#128
fix: forward options when calling this.resolve
#128
Conversation
if (importer && !relativeImportRE.test(id) && !isAbsolute(id)) { | ||
const viteResolve: ViteResolve = async (id, importer) => | ||
(await this.resolve(id, importer, { skipSelf: true }))?.id | ||
(await this.resolve(id, importer, options))?.id |
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.
It still needs skipSelf: true
I think?
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.
From the Vite docs for this.resolve
:
The default of
skipSelf
istrue
But no harm (I think?) in setting it explicitly too if you prefer.
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.
Oh nice. That's a welcome change from Rollup :)
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.
Isn't this a breaking changes for people still using Vite 3-4?
Rollup changed the default into v4, which is used by Vite 5, thus this is a breaking change and would need a proper major release
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.
@IlCallo Ah good point! I think I'll explicitly set skipSelf: true
for backwards compatibility.
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.
Fixed in v4.2.3
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 😁
Released in v4.2.2 |
@aleclarson so swift! 🙏 |
Currently, passing only
skipSelf
and not forwardingoptions
causescustom
to be set toundefined
, but other plugins rely on the presence ofcustom
for correctness.For example, Remix would like to throw whenever
.server
modules are resolved from the client bundle. We'd like to show something like:We need the resolved ID to check if the actual file path contains
.server
, but we need the original ID for the error message. So we callthis.resolve
to get the resolved ID. To make sure our plugin doesn't participate in further resolution, we rely oncustom
to setup some custom logic. But sincevite-tsconfig-paths
is also used in this project and it setsoptions
withcustom
asundefined
implicitly, the data set incustom
is lost and our custom logic never triggers.Additionally, omitting
options
altogether results in this warning from@rollup/plugin-commonjs
:Since they can't reliably check that you forwarded the options, they just check that
options
was passed in at all, but its clear from the message that the intent is to forwardoptions
.