-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1.16.3 by default generates at least ECMAScript 2015, while it was ECMASCRIPT3 in 1.16.2 and earlier #81
Comments
Another good default for |
Another example of setting |
@dasa thanks for the suggestion, this sounds reasonable. @jandppw I think the default option should only be applied if the build profile has configured Google Closure Compiler as the optimizer. This logic has been implemented in #83. In my testing |
@msssk Thx for the fix. I reviewed, and it looks ok to me. I do suggest a tad of documentation somewhere. In our case, given the ancient target, I am glad to keep an explicit I would be glad to test, but I cannot guarantee I will find the time over the next few weeks. Work on this project is intermittent. If a new dojo 1 version is released with the patch when we return to the project, it will be used. I'll see what I can do in the mean time, but don't hold off on our account. I'm curious: if a 1.17 would be released, what are the plans for this this default? |
After more investigation and consideration I think given the importance of legacy support for Dojo we should probably strive to maintain the same behavior for builds. Prior to 86f0042 Dojo's build behavior was:
The way to maintain this behavior is to provide explicit default settings (which can of course be configured in the build profile to different values): {
optimizeOptions: {
languageIn: 'ECMASCRIPT3',
languageOut: 'ECMASCRIPT3'
} Unfortunately we can't completely provide the same behavior because the behavior of the Google Closure Compiler has changed. Prior to the introduction of block scope in ES6 Closure accepted function declarations within blocks without complaint. Once Closure added support for ES6 and block scope it became impractical to allow block-scoped functions in pre-ES6 code (see google/closure-compiler#3189). In order for Dojo builds to work with the newer Closure releases and language set to Application code that previously built fine will start seeing Closure compiler errors for block-scoped function use. There are two options to fix it:
|
Neither option sounds good. An alternative would be to revert the Closure upgrade, and add support for Terser as an alternative optimizer. |
@dasa agreed, after thinking about and discussing this more our current inclination is to set the default build configuration as follows: {
optimizeOptions: {
languageIn: 'ECMASCRIPT_2017',
languageOut: 'ECMASCRIPT3'
}
} This allows existing Dojo builds that work to continue working. What is lost is the ability to receive errors from the build process about ES5+ code (if you are expecting all your source to be ES3). We will update Dojo's code to remove use of block-scoped functions so that developers can change the build configuration to |
In
1.16.2
->1.16.3
, the closure compiler was updated.1.16.2
1.16.3
That's quite a jump, of over 3 years.
A new build, created with util
[email protected]
, fails on legacy infrastructure.The reason is that the closure compiler outputs a more modern version of JavaScript. As an example,
1.16.3
outputs shorthand property names:where
1.16.2
does not:As far as I know, shorthand property names are an ECMAScript 2015 feature.
From the closure compiler release notes, I learn that a command line property
--language_out
was added in releaseThe release notes for
v20170806
sayThe release notes for
v20170806
sayI can find no other references to changes in the output language level in the release notes, so I need to assume that it is
still (intended to be) ES5. So either this is wrong, or the dojo build system is actively requesting another output language level. I cannot find prove of this. Yet, experiments show that the new setup by default generates at least
ECMASCRIPT_2015
.Workaround
The more recent closure compiler supports a
--language_out
command line property;v20200112
--help
says:After much searching, I found out that we can add a
optimizeOptions
property to our build profilebuild.profile.js
:that generates a working build.
languageOut: "ECMASCRIPT5"
generated a build that does not work, so it seems that1.16.2
->1.16.3
does a jump fromECMASCRIPT3
toECMASCRIPT_2015
or later.The use of
optimizeOptions
in the build profile is not documented. But, in our build process at least, it is copied intobc
, which is included fromutil/build/buildControl.js
, which is used inutil/build/transforms/optimizer/sendJob.js
which callsutil/build/optimizeRunner.js
, where it is used as command line argument in therunJava
call.Suggestion
This is quite a jump for a patch version
1.16.2
->1.16.3
.I suggest
1.16.4
where--languageOut
parameter passed to the closure compiler defaults to"ECMASCRIPT3"
(by adding it inutil/build/buildControlBase.js
, which would then be used both byutil/build/transforms/optimizer/sendJob.js
andutil/build/transforms/optimizer/closure.js
); alternatively, we can try to use the closure compiler option--browser_featureset_year
optimizeOptions.languageOut
in the build profile is documented--languageOut
parameter passed to the closure compiler not earlier than1.17
The text was updated successfully, but these errors were encountered: