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.
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
chore: make terser an optional dependency #8049
chore: make terser an optional dependency #8049
Changes from 17 commits
de7f351
cc697cf
faac5cd
715ca98
e077d7e
ecfc295
caacc4e
18c1d59
9278fc2
ec34abf
0b054fc
f3d8450
27e1c18
925fd58
593df66
eb0cc61
706840f
c8d2e2d
80de213
6385a9b
d784dff
d449ace
b6ec807
8e1d22b
92113ec
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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 can use
createRequire
here instead https://nodejs.org/docs/latest-v14.x/api/module.html#module_module_createrequire_filenameThere 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.
Actually the one used in the CSS plugin should be changed to
createRequire
tooThere 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.
Is it safe to remove resolving from
root
? I now found these related things: ddfcbce, #3988, #2612.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.
Instead of
I think it's safer to use:
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.
See import-js/eslint-plugin-import#1591
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.
Wait 🤔 This problem is more complicated than I thought…
To clarify, I'm concerned about the
require
method used here is not "clean" (would be interfered with byrequire.cache
, etc.).Both
require
andrequire.resolve
should be created from the root path so that we can get a fresh instance ofterser
,sass
, etc. The point is thatrequire
should be returned fromcreateRequire(some-file-in-the-root-dir)
too.Here comes the complexity:
_require
used incss.ts
now is a newly created function, which doesn't inheritrequire.resolve.paths
from the framework that wraps Vite https://github.com/sapphi-red/vite/blob/b6ec807e863e0e27cb16846f995c8e3a5c48b9fd/packages/vite/src/node/plugins/css.ts#L1282There 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.
Anyway, my original suggestion is to make
requireResolveFromRootWithFallback
requireFromRootWithFallback
(that is, put therequire
part into the function too).It's a nice-to-have.
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'm leaving this for now because I tried now but I didn't make it work.
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.
@sodatea do you think we could merge this then? And then work on your request as an enhancement? Or is this still blocking the 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.
Yeah the PR looks good to me. It's not a blocking change.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.