-
-
Notifications
You must be signed in to change notification settings - Fork 375
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
Build error with preact-material-components #42
Comments
Oops, BTW, |
Thanks! @developit I'm pretty sure it has to do with the Although this method "expects" export { Tabs, Menu, FormField, ... } ... and to be imported via import { FormField } from 'preact-material-components' ... I don't think @prateekbh is wrong to export components the way he has. So, perhaps (??), we should |
@cedric-marcone It looks like So, I know the documentation says to do what you've done, but I'd try this & see if it works: import { FormField, Radio } from 'preact-material-components'
import 'preact-material-components/FormField/style.css'
import 'preact-material-components/Radio/style.css'
|
Thanks ! Your suggestion didn't work right away because there is an inconsistency in preact-material-components regarding the naming of the FormField component (FormField vs Formfield) => I'll report there ;) I tried with the following and it works perfectly : import {Formfield, Radio} from 'preact-material-components'
import 'preact-material-components/FormField/style.css'
import 'preact-material-components/Radio/style.css' The only problem I can see is that initial method of importing components was advertized as the best way to prevent bundling unused components. Am I wrong ? |
Cool! I'm pretty certain that because it's using the module syntax, webpack will treeshake the rest away. The best way to check, though, is to do a before-after and check the bundle size of each. That's what I would do. |
I'll do it. |
@lukeed @cedric-marcone So here's a few pointers
|
Also i could really use as a ver good data point if you want the individual components to be transpiled into es5 format as well(which will make me sad though). |
using it as so babel/babili aims to tackle that problem - might be worth including inside webpack config for smaller bundle sizes. (personally haven't used it so I don't know what challenges come with it) |
@rkostrzewski thanks for pointing it out! It makes total sense to me now. but even with above info the need to add components separately does stand valid. |
Ah, right! That's why I felt hesitant. I do believe that this approach solves the issue. I've used it in a few projects and I think I remember it being beneficial: export { default as Foo } from './foo'
export { default as Bar } from './bar' |
@lukeed lemme try this, if this works it will make using |
Sure! Please let me know. It's been a while since I stumbled on it, not sure if my memory serves correctly. =P |
😞 sry but the above doesn't help, everything is still in the final bundle |
For the components part, I guess at this stage it does demand to be included separately. Please let me know if I can be any help here, I'll try if I can fix and send a PR but could really use some help |
hmm - |
just a note, this function is returning true from first condition itself, but not transpiling them |
I can confirm this with linkState ultility. Just import it to anyfile and you'll see syntax errors |
Hmmm. I wonder if the babel config is manually excluding node_modules. |
ok so I confirmed this by playing with preact-router.
|
so in either case it's not getting babel-loader applied? |
yep, in both cases, any es6 found in |
k. something's up with that plugin. this might be related: |
@developit are we using this in webpack? |
@developit we are trying to run |
prerendering is kicked off from a function call within the HTML template. It's handled in this file: |
@developit i did tried changing that however i got following error
|
so it seems,, if yes i'll raise a PR |
Yup. However, I think that in this case (unless @prateekbh has updated his module?), we are only importing & paying attention to the Later tonight, I want to check that our custom import FormField from 'preact-material-components/FormField'
import Radio from 'preact-material-components/Radio' |
@lukeed i havent really changed anything in the module, because tree shaking isn't perfect so far. I will check if the cuatom import works |
@lukeed it is failing with this error:
however when i tried removing uglify from all the places it fell back to the same error as earlier. |
I've been playing with it for longer than I'd like to admit. At this moment, I'm convinced that the |
@lukeed also I must admit, after banging my head with webpack for a while I just started feeling comfortable with loaders and then came |
@lukeed so are we changing anything then? |
I have the same issue @prateekbh . |
@prateekbh @developit I would like to move from the However, I was still struggling to include custom directories. I was also looking into this built-in but couldn't quite figure it out either. The idea with the latter is to move contexts when webpack recognizes an import is coming from within a @developit Should maybe cut the new release now & get this fix in as soon as it's solved. Altho it is important, it's not big enough to delay all the other improvements that have been made. |
This sounds good to me, also with loader if you do no say
definitely we should not wait for this, we'll do a minor version bump later on. |
@lukeed is it ok if I PR to make it to babel-loader? |
@prateekbh Yeah, I think so. I believe @developit signed off on it too. As for doing it, you can modify this group to be a |
Hello,
Linking a component from preact-material-components works like a charm in dev mode but when trying to build for production it fails.
Steps to reproduce
=> npm start : OK
=> npm run build : Fails
Any idea ?
The text was updated successfully, but these errors were encountered: