Comment by tlrobinson
11 years ago
I'm not sure it's worth publishing both ES6 and ES5 transpiled versions when you could just glue the transpiler into Node's "require": http://6to5.org/docs/setup/#require-hook
11 years ago
I'm not sure it's worth publishing both ES6 and ES5 transpiled versions when you could just glue the transpiler into Node's "require": http://6to5.org/docs/setup/#require-hook
Please don't rely on require hooks in libraries. They are kind of evil in applications already (because they amplify the "synchronous require" problem). Test your library against a version of 6to5, compile, publish, and remove that paragraph in font size 48 from your README.*
(*) I hope you add such a paragraph when your library relies on a global require hook that changes the default behavior of require for all .js files in all libraries.
What is 'the "synchronous require" problem'?
I've never run into issues with the CoffeeScript require hook, for example.
With a lot of files app startup can be delayed and the event loop be blocked. Which messes with timeouts among other things. The problem is that each file is loaded from disk and parsed in series without any level of parallelism (no real way around that in a pre-ES6 world). With CoffeeScript you put the time it takes to compile to JavaScript on top of that. If you have a big app with a lot of CoffeeScript files, it might be worth trying to compile them ahead-of-time instead. Though your mileage may vary in how much it changes.
4 replies →