How to get polyfills with Babel 7 and Webpack

  Рет қаралды 12,953

Swashbuckling with Code

Swashbuckling with Code

Күн бұрын

Пікірлер: 107
@davidfromnorth7836
@davidfromnorth7836 3 жыл бұрын
I'm just going through all "Webpack 5" series, the quality of content is outstanding,,,
@SwashbucklingwithCode
@SwashbucklingwithCode 3 жыл бұрын
Lovely to hear, ty.
@ksorv
@ksorv 4 жыл бұрын
Just wanted to let you know that what you've started is great. Please keep making these videos. I can see you getting the attention soo. ❤️
@SwashbucklingwithCode
@SwashbucklingwithCode 4 жыл бұрын
I really appreciate that, and I shall keep doing my best.
@9gager87
@9gager87 3 жыл бұрын
I was about to buy a webpack course on Udemy but then I came across your channel and never looked back. Your videos are really awesome. Don't ever stop making them!
@SwashbucklingwithCode
@SwashbucklingwithCode 3 жыл бұрын
Thank you, that's cool to hear.
@alberuniazad4412
@alberuniazad4412 Жыл бұрын
Great explanation! This is what I was looking for all day!
@johnthirlaway67
@johnthirlaway67 3 жыл бұрын
Massive thank you, I had a CoreJS gotcha and couldn't work it out till I found your tutorial!
@SwashbucklingwithCode
@SwashbucklingwithCode 3 жыл бұрын
Awesome!
@dechobarca
@dechobarca 3 жыл бұрын
I don't comment often on videos, but honestly thank you so much for this and the previous 40 min video of the series. Started learning Babel a day or two ago, only to find out that I also need Webpack. But their documentation is not user-friendly or beginner friendly at all, like they tell you "do this, but also there are 3 separate ways to do this, and by the way while doing A, keeping in mind that it might require B for it to work properly, also here are a bunch of other tools we use that you also need to learn about". So it got overwhelming pretty fast. I think you've done an excellent job here explaining how to set this up properly while also covering many of the potential caveats and stuff, but MOST importantly what is actually going on behind the scenes which is really important, otherwise we're just hacking/cheating our way through. So cheers once again, you have no idea how much time and frustration this saved me.
@SwashbucklingwithCode
@SwashbucklingwithCode 3 жыл бұрын
Thank you for taking the time to write this. I went through the same struggles awhile ago, and just carried on copy pasting things until they worked. At some point I decided I wanted to spend some time and try to understand what was going on so it wasn't all so mysterious. Well, it still is, but I figured I should try making the video I would have wanted back then.
@dechobarca
@dechobarca 3 жыл бұрын
Copying and pasting configs from the docs until they all failed for one reason or another was pretty much where I got stuck as well, having really hard time to comprehend what exactly is going on. And I've read a couple of other tutorial articles online, but they either didn't go in such depth to explain how or why something is happening, or were outdated or related to React and so on, which only made things more complex for my case. Well now after watching this I rebuild my configs from scratch (they are almost the same as your github repo) and even learned how to use SourceMapDevToolPlugin, which would have been an absolute mind-f**ck before watching your video. So thanks once again, you did a pretty nice job at making the video you would have wanted, it happens that it worked great for me as well. Best of luck to your channel (which I will be keeping an eye on) :)
@nishant.c
@nishant.c 3 жыл бұрын
Stumbled upon this channel while searching for webpack bundle optimisation tips, and I am highly impressed with the quality of content in this channel. It's certainly more than just "Yet another tutorial channel", You are doing a great job here, really appreciate your effort and time, looking forward to more from your channel.
@SwashbucklingwithCode
@SwashbucklingwithCode 3 жыл бұрын
A lovely thing to hear on a Friday morning, thank you.
@dynerushd7517
@dynerushd7517 4 жыл бұрын
These webpack series really helped me out, Thanks!
@SwashbucklingwithCode
@SwashbucklingwithCode 4 жыл бұрын
My pleasure, thanks for saying so!
@normamendonca
@normamendonca 2 жыл бұрын
Awesome! Really appreciate the areas you've focused on.
@SwashbucklingwithCode
@SwashbucklingwithCode 2 жыл бұрын
Cool to hear, ty.
@miladkarimi8112
@miladkarimi8112 2 жыл бұрын
the quality of content is really excellent!👍
@SwashbucklingwithCode
@SwashbucklingwithCode 2 жыл бұрын
Thank you.
@smaragd_
@smaragd_ 2 жыл бұрын
Very nice video and well covered topic with key issues occurring out of it. Thank you!
@spondzi911
@spondzi911 2 жыл бұрын
Hey! Just wanted to tell you that I love your intro. Such a great climate.
@SwashbucklingwithCode
@SwashbucklingwithCode 2 жыл бұрын
Thank you. I put a lot of effort into it so that means a lot to me.
@cryptobrarry
@cryptobrarry 11 ай бұрын
Thans for video. How do you think is it any sense to compile two main.js files? with polyfils and with polyfils? Second would be pretty small. And we can check on server side by user-agent the browesr and connect different main.js in the src attribute?
@adconde1
@adconde1 3 жыл бұрын
Just wanted to say thank you for sharing this knowledge. It is very good content, keep it up.
@SwashbucklingwithCode
@SwashbucklingwithCode 3 жыл бұрын
You are welcome, and thank you the feedback.
@WarriorPega
@WarriorPega 4 жыл бұрын
This is incredibly thorough! Really appreciate all the insight you provided. I'm very new to bundlers, webpack, babel - the whole lot of them. This cleared up a lot of what was confusing to me about setting up specific targets and taking advantage of newer features!
@SwashbucklingwithCode
@SwashbucklingwithCode 4 жыл бұрын
Awesome! Yah, it's a wild world to get into at first. I put off learning it for the longest time and I wish I had not. Thus the motivations for this series to teach others.
@santhoshraghavpidathala3701
@santhoshraghavpidathala3701 4 жыл бұрын
Indepth tutorial, very very nice 👌. Please continue series on webpack with postcss, purifycss, corejs etc
@thangha8289
@thangha8289 3 жыл бұрын
Hey dude, that is the exact thing I have to deal with. Thank you so much, really clear!
@SwashbucklingwithCode
@SwashbucklingwithCode 3 жыл бұрын
Awesome, thank you for letting me know.
@zoachim
@zoachim 4 жыл бұрын
25:10 agree on the less anxiety :D funny. great vid, looking forward to the React stuff.
@zoachim
@zoachim 4 жыл бұрын
5:10 IE and their "document mode" has been a huge pain in my #. I was hoping to find some answers here :D my latest app at my job shifts document mode to IE10, while everyone else's to IE11. In your case though it's probably because of some missing html meta tags, try . IE=Edge means "The highest supported document mode of the browser"
@SwashbucklingwithCode
@SwashbucklingwithCode 4 жыл бұрын
Oh, interesting. My work finally moved to just supporting Edge, now that it's all chromium, after we showed user percentages a bunch of times. So I, fortunately, don't have to deal with it much these days.
@evalarumbe
@evalarumbe 4 жыл бұрын
Thanks for the clear demo and explanations! This vid helps the docs make more sense, adding some useful background and detail
@SwashbucklingwithCode
@SwashbucklingwithCode 4 жыл бұрын
Fantastic. Thank you for letting me know.
@gimba9052
@gimba9052 3 жыл бұрын
your videos are exceptional, they are easy to understand even for beginners. keep up the good work❤❤
@SwashbucklingwithCode
@SwashbucklingwithCode 3 жыл бұрын
Thank you.
@yurirech9301
@yurirech9301 2 жыл бұрын
I love you man, you saved my day!!! Thanks a lot!
@SwashbucklingwithCode
@SwashbucklingwithCode 2 жыл бұрын
Awesome.
@jsherborne92
@jsherborne92 2 жыл бұрын
Fantastic content, very helpful.
@SwashbucklingwithCode
@SwashbucklingwithCode 2 жыл бұрын
Glad to hear it.
@shreshthmohan
@shreshthmohan 2 жыл бұрын
Thanks for making this video. Finding these things in the documentation isn't that easy.
@augustom.gouveia9392
@augustom.gouveia9392 2 жыл бұрын
Very insightful, thanks a lot!
@SwashbucklingwithCode
@SwashbucklingwithCode 2 жыл бұрын
Awesome.
@lukmankodir5838
@lukmankodir5838 3 жыл бұрын
Thank you so much Mr.!
@ivan89pln
@ivan89pln 3 жыл бұрын
Great video, especially for the IE Emulation tab gotcha.
@SwashbucklingwithCode
@SwashbucklingwithCode 3 жыл бұрын
Thank you for the feedback, glad it was useful.
@ivan89pln
@ivan89pln 3 жыл бұрын
@@SwashbucklingwithCode It really was, thanks!
@ss.rajkgupta
@ss.rajkgupta 3 жыл бұрын
I was looking for just one minor solution and I already knew a lot of things in webpack 5 but then I ended up watching the whole playlist. I don't know why; probably the knowledge in your tutorials. Are you a Coding-Wizard from Gryffindor?😊
@britti73
@britti73 3 жыл бұрын
This was really excellent! Thank you so much for sharing! ❤️
@rinotovar327
@rinotovar327 2 жыл бұрын
Very sweet content, thank you.
@SwashbucklingwithCode
@SwashbucklingwithCode 2 жыл бұрын
noice.
@KustomJulius
@KustomJulius 4 жыл бұрын
Great video, helped me out a ton!
@vivekranjan437
@vivekranjan437 3 жыл бұрын
Thank you for this explanation
@kevinmorte3959
@kevinmorte3959 3 жыл бұрын
Thanks. Greate video. As usual.
@SwashbucklingwithCode
@SwashbucklingwithCode 3 жыл бұрын
Good to hear, ty.
@Amir-zi1hj
@Amir-zi1hj 2 жыл бұрын
I need more of these videos 🤩
@SwashbucklingwithCode
@SwashbucklingwithCode 2 жыл бұрын
haha, nice. have you already checked out the Webpack playlist?
@Amir-zi1hj
@Amir-zi1hj 2 жыл бұрын
@@SwashbucklingwithCode Yeah I added some of them to my watch list, I like the ones that are explaining specific things, like this one and visualization ...
@SwashbucklingwithCode
@SwashbucklingwithCode 2 жыл бұрын
@@Amir-zi1hj I see. They seem to be a little less popular but they are valuable things to know (at least I wish I knew them earlier).
@vikram87in
@vikram87in 2 жыл бұрын
Thanks a lot. Great video again. 😍 Just one thing. Isn't the --save option the default while installing any package. Can't we just do 'npm install xyz'?
@SwashbucklingwithCode
@SwashbucklingwithCode 2 жыл бұрын
Thank you. Good question, yes it is the default option now but that's a relatively recent change and many people don't update their Node or NPM very often.
@vikram87in
@vikram87in 2 жыл бұрын
@@SwashbucklingwithCode thanks 😊
@musedoom
@musedoom 3 жыл бұрын
Thanks for the video. I had some troubles transpiling the code but that was because I named incorrectly the file .babelrc with babelrc (without the point)...silly me. I saw my mistake the next day and everything was perfect :D
@SwashbucklingwithCode
@SwashbucklingwithCode 3 жыл бұрын
Easy mistake to make. There are so many things to keep in mind when covering a project setup, thanks for the reminder on that one.
@gno3939
@gno3939 3 жыл бұрын
4:26 - reason why you had to create .browserlistrc and add defaults query for webpack and not babel is because: entry property defaults to 'web' and when no browserslsit is configured it goes back 2 versions (doesn't resort to browsers list defaults).. when entry is 'node' it does the same. but when browserslist is configured webpack will look in there so it'll turn you bootstrap arrow func -> func declaration
@SwashbucklingwithCode
@SwashbucklingwithCode 3 жыл бұрын
Interesting, thanks for the insight.
@zoachim
@zoachim 4 жыл бұрын
21:10 do you know if Create-React-App does this all of this for us? Would be interesting to understand what's going on under the hood
@SwashbucklingwithCode
@SwashbucklingwithCode 4 жыл бұрын
Good question, I don't believe they put polyfills in automatically. But how I'd test it is just look at the final output before and after a method (e.g. object.values) similar to how I did in this video.
@dmtoptech
@dmtoptech 4 жыл бұрын
Thanks for great video. I get error when i use same project as yours with sass loader and post css specially when i use includes method in my JavaScript code can please suggest a solution cause i tried a lot of things but no one work the exact error appear in es.array.includes.js and this affect mini-css-extract-loader ans sass loader to not compile
@SwashbucklingwithCode
@SwashbucklingwithCode 4 жыл бұрын
Strange, I don't have that issue at all, and I've double checked by adding all the css loaders and plugins to this branch just in case. This is happening while using `"useBuiltIns": "usage", "corejs": "3.8"` in your babel file like in this videos example?
@dmtoptech
@dmtoptech 4 жыл бұрын
@@SwashbucklingwithCode thanks i get your code from github and I get same error but after adding exclude node_modules in css/sass/scss loader in webpack config the problem solved and i realize that sass file which cause the error. Thank you for your videos i hope you make more cause you give details that we need as beginners
@JoeBoo532
@JoeBoo532 4 жыл бұрын
Thank you for such a useful video! :D I have a question if you don't mind asking. What about spreads operator or optional chaining? how can we turn those on?
@SwashbucklingwithCode
@SwashbucklingwithCode 4 жыл бұрын
Spread operators are part of the default syntax that has been included for awhile through `@babel/preset-env`. Optional chaining is new, but recently added to the latest version of ES, so it is also automatically included as far as I've seen. I don't use anything for my projects that is in earlier stages of proposal, but Babel has docs covering how to use "proposed" syntax now that they've deprecated the "stage-0" type plugins.
@none0n
@none0n 3 жыл бұрын
My main.js is weirdly 39.5 KiB. Is there a reason why?
@lcoronelp
@lcoronelp 4 жыл бұрын
Cool functionality to avoid dead weight in the main.js. But i think, normally the polyfills will be for IE11 (not all but the worst), webpack can put the polyfills in another file and load only if is IE11? (to avoid the weight in the most of browsers that didn't need that polyfills)
@SwashbucklingwithCode
@SwashbucklingwithCode 4 жыл бұрын
A good portion will but it totally depends on what ES version you are using, and sometimes browsers lag behind for various reasons as well. It's a great idea to serve only to IE, but the problem that arises is that you need a server to make that decision, and that also adds time. There are frameworks that do it but there are tradeoffs.
@lcoronelp
@lcoronelp 4 жыл бұрын
​@@SwashbucklingwithCode Could we use JS check to include the file (as the old times)? Something like: window.MSInputMethodContext && document.documentMode && document.write(''); Seeing those polyfills as a LOT of dead weight, i think maybe it would be worth. Thanks for share your knowledge and experience! :)
@SwashbucklingwithCode
@SwashbucklingwithCode 4 жыл бұрын
@@lcoronelp Ah ok, so a script that will fetch and load depending on browser after document is downloaded. It may definitely be worth it, though it would need to fetch and run as it parses that script if I'm understanding it correctly. That could totally be fine, just depends on "when" the code needs to run. Thanks for sharing.
@usmankiyani5209
@usmankiyani5209 4 жыл бұрын
Thank you John Wick coding dude 👏🏻
@SwashbucklingwithCode
@SwashbucklingwithCode 4 жыл бұрын
You are welcome. I will take this as a compliment.
@zivtamary
@zivtamary 3 жыл бұрын
Instead of creating.browserlistrc you can add "browserslist" to package.json and it will work the same! :)
@SwashbucklingwithCode
@SwashbucklingwithCode 3 жыл бұрын
You can, but I always prefer to have config files to keep package.json succinct and make it obvious with a glance at the files what types of packages are set up in the project.
@grantmoss4937
@grantmoss4937 3 жыл бұрын
super useful vid. thanks
@alibidjandy6313
@alibidjandy6313 3 жыл бұрын
hi thank you for your video but I need to say you forgot to point in fetch because it doesn't work with core-js
@SwashbucklingwithCode
@SwashbucklingwithCode 3 жыл бұрын
Not sure what you mean. You mean importing `node-fetch`? If so, I don't really see that as a polyfill concern, that's just a browser functionality that doesn't exist with node, but perhaps I'm misunderstanding you.
@GauravKumar-ue7nz
@GauravKumar-ue7nz Жыл бұрын
You are soooooooooo Good.
@maksymdudyk1718
@maksymdudyk1718 3 жыл бұрын
Thanks a lot!!
@SwashbucklingwithCode
@SwashbucklingwithCode 3 жыл бұрын
You are quite welcome.
@lifeisbeautifu1
@lifeisbeautifu1 3 ай бұрын
Thank you!
@Iammrunkown
@Iammrunkown 3 жыл бұрын
Your subscriber from India
@SwashbucklingwithCode
@SwashbucklingwithCode 3 жыл бұрын
Thank you, and welcome!
@babyloniane
@babyloniane 3 жыл бұрын
Hellooo, that's SO helpful, i spent a week to figure out how to make my shit work on ie11 lol. Huge time saving. btw do you know why template.content.cloneNode(true) dont work in ie11? what plugin are necessary to make it work ._.
@SwashbucklingwithCode
@SwashbucklingwithCode 3 жыл бұрын
I have not worked with html content template's yet, sorry. That does seem like a tricky one if it isn't directly importable from 'core-js'. You might need to find another polyfill source.
@babyloniane
@babyloniane 3 жыл бұрын
@@SwashbucklingwithCode I solved it by importing another polyfill. But thanks anyway, it's a nightmare to set up xD
@SwashbucklingwithCode
@SwashbucklingwithCode 3 жыл бұрын
@@babyloniane Glad you got it figured out. It can be quite exhausting to configure.
@mohamedyoussef8835
@mohamedyoussef8835 3 жыл бұрын
Awesome Video ++++++++++++++
@undercontr
@undercontr Жыл бұрын
THANK YOU JESUS!
Know your Webpack bundle better with visualization
35:57
Swashbuckling with Code
Рет қаралды 10 М.
The evil clown plays a prank on the angel
00:39
超人夫妇
Рет қаралды 53 МЛН
Support each other🤝
00:31
ISSEI / いっせい
Рет қаралды 81 МЛН
BAYGUYSTAN | 1 СЕРИЯ | bayGUYS
36:55
bayGUYS
Рет қаралды 1,9 МЛН
malicious javascript injected into 100,000 websites
12:28
Low Level
Рет қаралды 218 М.
Webpack 5 CSS Walkthrough: Sass, PostCSS and more!
37:26
Swashbuckling with Code
Рет қаралды 28 М.
Mocking Asynchronous Functions with Jest
21:50
Swashbuckling with Code
Рет қаралды 73 М.
Getting Started with Webpack 5 in 2021
43:34
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 33 М.
Webpack crash course | easy way
32:07
Hitesh Choudhary
Рет қаралды 62 М.
Dear Game Developers, Stop Messing This Up!
22:19
Jonas Tyroller
Рет қаралды 785 М.
Getting Started With Babel - Transpiling Javascript
13:59
Monsterlessons Academy
Рет қаралды 26 М.
Creating and Understanding a Basic Webpack 5 Setup
41:49
Swashbuckling with Code
Рет қаралды 61 М.
CSS Modules: Why are they great?
12:03
Harry Wolff
Рет қаралды 40 М.
The evil clown plays a prank on the angel
00:39
超人夫妇
Рет қаралды 53 МЛН