I wanted to import ES6 modules inside of the eleventy configuration file but had no success with it. When serving the files it always exits with a Unexpected identifier (SyntaxError) error. I also scanned the configurations of a lot of other eleventy projects, but couldn鈥檛 find any usage of ES6 module imports.
Does that mean eleventy only understands the ES5/CommonJS way of exporting and requiring dependencies?
Just out of curiosity I wanted to know if it there is a way to make this work. Maybe with the usage of @babel/cli (I played around with it with no success)?
Would be grateful for any tips or hints. Thanks.
Eleventy runs on Node.js which doesn鈥檛 have stable support for ES modules. Stable support is coming and there is already a --experimental-modules flag which allows Node programs to use ES modules. I鈥檓 not sure whether Eleventy could support them once stable support lands in Node. That鈥檚 up to @zachleat.
That's the fact: 11ty uses Node module way but not (yet...) ES6 one.
I'd vote for this enhancement.
Hmm, I'm fine putting this in the enhancement queue but my hunch is that I'm not really interested in adding a babel dependency just for this?
ES6 will be supported in Node!
This repository is now using lodash style issue management for enhancements. This means enhancement issues will now be closed instead of leaving them open.
The enhancement backlog can be found here: https://github.com/11ty/eleventy/issues?utf8=%E2%9C%93&q=label%3Aneeds-votes+sort%3Areactions-%2B1-desc+
Don鈥檛 forget to upvote the top comment with 馃憤!
I think we should wait for Node鈥檚 stable release. Being able to use ES modules would be nice-to-have, but I don鈥檛 think it鈥檚 very important.
I agree w/ @kleinfreund, as much as I'd love for it to be available out of the box
I've just been including --experimental-modules in my package.json scripts
I agree w/ @kleinfreund, as much as I'd love for it to be available out of the box
I've just been including--experimental-modulesin mypackage.jsonscripts
@kleinfreund Would you mind sharing your configuration?
@re1 I do not use Eleventy with any ES modules. I think you meant to ask @jevets. :)
@kleinfreund Now that es6 modules are now ready in node 14 can we get an update on this ticket?
Any updates on this one?
I'd be interested in how people have been configuring this (if at all)?
Most helpful comment
@kleinfreund Now that es6 modules are now ready in node 14 can we get an update on this ticket?