-
Notifications
You must be signed in to change notification settings - Fork 121
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
refactor: use webpack instead of webpack-sources #431
Conversation
commit: |
I will have a look at the failing test later today. |
🤔 It doesn't seem to be super deterministic either. |
Do you know why the test is failing @sxzz? |
It's OK. I'll check it out when I have time. |
Thank you so much for looking into it. I'll have a better look, I don't understand why it's not always failing though. unplugin/src/webpack/context.ts Lines 48 to 58 in dd9d184
I'll double check how webpack 4 works there, |
So, I couldn't find a good solution for webpack 4. What I propose, to keep the best compatibility possible between
This way we keep the compatibility most of the time, and do our best for webpack 4.
WDYT @sxzz ? |
I went a different route after all. In our case we wanted to require the same Doing: import { createRequire } from 'module'
[...]
const webpackRequire = createRequire(require.resolve('webpack'))
const RawSource = webpackRequire('webpack-sources').RawSource Makes it require the correct (But, plugin developers should still declare their plugin's bundler as And it seems to pass the tests now 🙌 |
I need to test the PR more, please hold on. |
So sorry to ping you again @sxzz. |
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.
LGTM
Coming from the discussion unjs/community#37
Having a dependency on
webpack-sources
forces plugin developers to break the compatibilitywebpack
/webpack-sources
by having them declare a dependency onwebpack-sources
instead of a peerDependency onwebpack
.Instead, we could require
webpack-sources
aswebpack
using:And remove any dependency on
webpack-sources
orwebpack
.The change "should" be mostly invisible.