-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
Replace warning with tiny-warning #14167
Conversation
TrySound
commented
Jan 12, 2019
- esm support
- not stuck with mirroring facebook internals once in a year
- jss v10 already migrated to it so size improvement will come in mui v4
- tiny-warning is really console.warn; red wall in console is scary
- I have followed (at least) the PR section of the contributing guide.
- esm support - not stuck with mirroring facebook internals once in a year - jss v10 already migrated to it so size improvement will come in mui v4 - tiny-warning is really console.warn; red wall in console is scary
a7c0c82
to
f7f83fc
Compare
@TrySound From my end, the only argument I will consider is the bundle size, larger we close, smaller we merge. I don't think that any of the other dimension matters. Unless I'm missing one? It's a dev dependency designed to have a minimal overhead in production. |
@oliviertassinari I'm thinking about cleaning jss v9 from my bundle (via aliasing) and installing |
@TrySound Using |
The size-limit stats using webpack (and not rollup). I believe it's using the esm version when available:
@TrySound What's the other advantage I miss? How does esm support matter? How is a package that hasn't changed for ten years that works an issue? React use console.error right? JSS can always go back to warning if it's better cc @kof. |
@oliviertassinari The size is changed because of jss miss. Some warnings are not wrapped with NODE_ENV condition. Ideally this will not change the size because it's always stripped from production builds. An issue is commonjs which produces lots of bugs for us (I saw a lot of great projects with just overengineered exports). ESM is a good replacement. But we should replace cjs with it without waiting for miracle. And as I said warning maintainers are stuck on facebook internals. They are mirroring facebook. They said so. Are they the same? Nope. They just don't care much about it. Think it's dead. https://github.com/BerkeleyTrue/warning/blob/master/warning.js react-router and formik migrated too. Nobody regret about legacy. |
I see by the way warning package from |
These stats are specifically |
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 would vote for rejecting this change because:
- It's making having to handle console.warn and console.error. It's not consistent and introduces a testing overhead. React is using console.error
- It's increasing the bundle size.
The funny thing uglify was able to inline constant flags but seems like that shit is broken again. Rollup is the best here. And it consumes only ESM. React uses error for historical reasons. So it's a legacy we should not follow. |
|
Personally, I think these PRs with negligibly smaller or negligibly more performant alternatives are a distraction we could do without. @TrySound please consider putting your time to something more productive. |
Fuck the ecosystem, somebody else will fix it, right? I'll see. |
I think the biggest point here is really to migrate to ESM, a few bytes doesn't matter here. I prefer in general to depend on better maintained and more modern packages. Also I preferred to not reject a PR because even if it doesn't matter that much, I always support people who care and if a person invests time to improve ecosystem, its worth supporting, even if this particular change isn't that important. |
"If it ain't broke, don't fix it." |
Its not broken enough to call it broken. Its really about ecosystem and people. |
Since @TrySound can't engage in adult conversation and explain the problem this is trying to solve, and feels abusive language is the way to get this PR merged, that ends the discussion as far as I'm concerned. |
Sorry. I'm tired from these conversations. It feels like nobody listen to me. So I became angry. My point as @kof said is ecosystem. Not just bytes. I want to move the ecosystem to a single and powerful module system which can be always statically analyzed and optimised. So I'm tried to cover as much as possible packages in my node_modules with esm. Material-ui will end up with the same. This is the idea I promote for such packages #13391 If we stay on our chairs then programming doesn't make sense. We should move ecosystem forward to get rid from all complexities one day and start to solve new problems. I like to solve technical debt. And I'm trying to solve it here. Will you let me do this? |
I can totally understand you because I have the same issue in #14152 with you. You keep saying that it matters if a single function module is in esm or cjs and I keep posting examples where this is not the case. If you want to move the ecosystem forward why not start with the people and explain how a single function module in esm contributes to the treeshakability of the hole bundle? If we could understand this then we can work on other modules where we are involved instead of only you going around and simply saying "do it this way. it's right.". I get your frustration but I'm also frustrated if I'm supposed to accept changes to problems that I can't reproduce.
I'd like to move together. We don't have to all be able to implement the solution but we should know what the problem is and how you solve it. Overall I do agree with moving some warnings to console.warn instead of console.error. react did the same and I would follow their lead that we should choose on a case by case basis if something should be logged as an error or warning. The issue is that we can't really apply this to deprecation warnings in props here. Some of the warnings currently would be better place in |
Alright, this is mostly political change. ESM was suggested to classNames but still not accepted because of adoption fear. And this is a problem, without adoption there won't be adoption. Users won't will think it's okay to consume two different module systems which often cannot communicate well with each other. ESM was suggested to ESM is important step for javascript. It opened the door for improvements which was not considered before or at least didn't have so much success like scope hoisting and treeshaking. It has important constraints like only top-level imports which forces us to consider different ways of dynamic imports like package.json fields and My app previously used webpack for bundling. Everything went good enough. Our bundle was 6mb (splitted with chunks) and it's ok. Then rollup introduced code splitting and I tried it. As a result I dropped 300kB from all chunks. But there was a problem with many packages. They use commonjs. And not in the best way. For example react-map-gl had Another example. CJS require from ESM interop does not always work. Because of this react-event-listener is still cjs. Why migrate to ESM? Well, at least to not have this in your bundle. Why migrate small one-function modules? This is political. Such big project like material-ui will force users to consume the same dependencies. Will force to consume more ESM and less CJS. This will move the whole community forward. I think after three years of spec it's reasonable goal. ESM can be run out of the box in browser. Tools like unpkg resolves dependencies. |
@TrySound Thank you for this summary. I'm closing for consistency with React usage of console.error.
It's partially true, most of their warnings are using console.error: @TrySound Maybe tiny-warning could add an option to chose between warning and error? |
Regarding the ESM vs CJS. I'm glad there are people like you @TrySound to promote its usage in the community. Thank you for that! It's going in the right direction. I wish we could just kill the CJS version, encourage people to use https://github.com/standard-things/esm on Node and move forward. But I doubt we can do that, yet. Now, as a maintainer of Material-UI, I have limited bandwidth. I focus my energy on the problems that have solutions our users can benefit from the most. I believe that migrating |
For more context on the long term vision for the warning package. I wish that https://github.com/oliviertassinari/babel-plugin-transform-dev-warning was able to remove the warning imports in production. I'm not sure if it's possible with ESM. Or https://github.com/4Catalyzer/babel-plugin-dev-expression, I can't remember why I have forked it. |