You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 19, 2018. It is now read-only.
CoffeeScript by default adds a top-level function safety wrapper around all the code in each file. It’s just (function(){ ... })();. It can be disabled by setting the --bare flag.
Per the ES2015 spec, import or export statements must appear at the topmost scope, and cannot be within a function block like this. So when modules support was added, we automatically set bare to enabled for any file with module statements.
For 2.0, do we want to get rid of this safety wrapper? ”Bare” mode would become the default, and we would remove the --bare flag as well. Is there any reason to keep them in an ESNext-outputting version of CoffeeScript?
The text was updated successfully, but these errors were encountered:
I’ve given this a lot of thought 🤔 and it occurs to me there is one big and probably fairly common use case where the safety wrapper is needed: people who concatenate the output of a bunch of compiled .coffee files. You know, the first example in the documentation:
coffee --compile --output lib/ src/
Without the safety wrapper, any variables declared at the top scope in one file would remain declared at the start of the next file, and so on. Obviously this isn’t an issue for a project using ES modules, so we’re fine ditching the safety wrapper there. But as a default for general projects, we should probably leave the safety wrapper as it is.
CoffeeScript by default adds a top-level function safety wrapper around all the code in each file. It’s just
(function(){ ... })();
. It can be disabled by setting the--bare
flag.Per the ES2015 spec,
import
orexport
statements must appear at the topmost scope, and cannot be within a function block like this. So when modules support was added, we automatically setbare
to enabled for any file with module statements.For 2.0, do we want to get rid of this safety wrapper? ”Bare” mode would become the default, and we would remove the
--bare
flag as well. Is there any reason to keep them in an ESNext-outputting version of CoffeeScript?The text was updated successfully, but these errors were encountered: