"use strict"; prepended blindly to scripts in the wild

felix felix8a at gmail.com
Wed Sep 8 19:18:16 PDT 2010


On 9/8/10 19:08, felix wrote:
> On 9/8/10 18:52, Brendan Eich wrote:
>> There's no easy way to support concatenation and "use strict" (or
>> private x). But the "ease" of concatenative programming in JS is an
>> illusion already. Accumulating properties in the global object is a
>> constant source of bugs and confusion. Modern JS libraries minimize
>> their global binding sets.
>
> right. but it's common for sites to develop with separate js scripts as
> "modules" and then combine them into a single script for speed when
> deployed to end-users. global conflicts can be found and solved when the
> js scripts are included separately, and naive concatenation does not
> change how the scripts behave.
>
> except file-level directives like "use script" change that. now I need
> to either
> - test the concatenation.
> - use a smarter rewriting-concatenator, which is probably complex enough
> that the result will need testing anyway.
> - validate the individual js files as naive-concatenation-safe before
> doing the concatenation.

- or js could barf/warn on file-level directives, basically making the 
previous option built-in.
- or js could invent some way for me to say "this is the end of the 
scope of a file-level directive" within a single file.

> this probably should happen even if I use the module-with-exports
> pattern in my code, since who knows if some other js lib I use has
> file-level directives or not, and it's no fun to inspect it manually on
> every update.


More information about the es-discuss mailing list