-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Allow for easier custom builds #1979
Conversation
Other things that can be supported with this setup:
|
Regarding the build failure, I likely missed an export or two. It is tedious work. Will get back to it later. |
Another thing to note (based on the build failures). This means you can no longer make a symbol or property exportable without documenting it. Previously, it was possible to add something to an exports file that didn't appear anywhere in the source. For example, @ahocevar mentioned that this discussion has happened before, but here's another summary: If you want to export a method, it needs to be documented in the source. Put another way, there is no longer a way to assign and document |
dc82784 gets rid of regex parsing of source files for collecting exports. |
Added a build task and documentation. Feedback welcome. |
My feedback so far: awesome! On 11. April 2014 21:35:39 MESZ, Tim Schaub notifications@github.com wrote:
Marc Jansen, terrestris GmbH & Co. KG |
The build task now lets you build 3rd party code together with the library. I updated the doc to describe the {
"exports": [],
"src": ["src/**/*.js", "examples/simple.js"],
"compile": {
"js": ["externs/olx.js"],
"externs": [
"externs/bingmaps.js",
"externs/geojson.js",
"externs/oli.js",
"externs/proj4js.js",
"externs/tilejson.js",
"externs/topojson.js",
"externs/vbarray.js"
],
"define": [
"goog.dom.ASSUME_STANDARDS_MODE=true",
"goog.DEBUG=false"
],
"compilation_level": "ADVANCED_OPTIMIZATIONS",
"output_wrapper": "(function(){%output%})();",
"use_types_for_optimization": true
}
} Note that the I could use another set of eyes to determine why this is significantly different than the result of
|
@tschaub I'll try to help you figure out why the sizes of compiled examples plus library is so significantly different on Monday. In the meantime, I have changed the JSDoc exports plugin to make it readable by anyone, made the whole documentation story really consistent, and documented the few remaining ol3 specific conventions for JSDoc usage: 494f238. Since this is based on your work here, I think it would make sense to make it either part of this pull request, or rebase it once this pull request is merged. So feel free to cherry-pick or not 😄. |
@elemoine This is what I was referring to, and what I wanted to help figure out. However, I'd much appreciate if you could also take a look, because you know more about the Closure compiler than I do. |
Another commit that builds on top of this work: 74b525b - it adds usage documentation for |
A far as I can tell, a lot of unused goog.async is included in that build. I have not found out yet why though. |
Success! And the file size is now even smaller than with plovr. All you need to do is add {
"exports": [],
"src": ["src/**/*.js", "examples/simple.js"],
"compile": {
"js": ["externs/olx.js"],
"externs": [
"externs/example.js",
"externs/bingmaps.js",
"externs/geojson.js",
"externs/oli.js",
"externs/proj4js.js",
"externs/tilejson.js",
"externs/topojson.js",
"externs/vbarray.js"
],
"define": [
"goog.dom.ASSUME_STANDARDS_MODE=true",
"goog.DEBUG=false"
],
"compilation_level": "ADVANCED_OPTIMIZATIONS",
"output_wrapper": "(function(){%output%})();",
"use_types_for_optimization": true,
"manage_closure_dependencies": true
}
} |
Awesome @ahocevar - thanks for the find. Previously, I was always compiling with a "main" script that With |
Ok, it turns out that the build time is not reduced by having Closure Compiler do all the dependency resolution. Here are the two scenarios I tried:
Using the same compiler options as above (mentioned in @ahocevar's comment), I timed Scenario 1:
Scenario 2:
(The So the second scenario is ~4s faster (10 fewer CPU seconds) and produces a build that is ~1K smaller. This means passing everything to Closure Compiler is not necessarily the best idea. The Anyway, this is very promising to me. |
abae3e8 inlines typedefs from olx.js into the class documentation. This does not look good currently with nested object literals of object literals, but that should improve with a new template. |
@ahocevar and I just discussed making another simplification here. The To support the idea of packages, we can later add a separate |
|
As discussed, 6227bd2 moves the exclusion of |
Remaining tasks:
Update - I'll handle the defines in a separate pull request after this is merged. |
a couple of comments after playing around with the build task a bit:
|
Without the extra quotes, I get the expected output (and no errors): (function(){/**... source here */})(); This may vary by OS. I'm on OSX. |
Are you talking about a specific Closure Compiler option? With the |
Not sure I understand. This is the way things are currently. As mentioned above, once the |
This commit simplifies the exports.js plugin so it only relies on the stability notes to generate the documentation, which completely decouples it from the exportable API. As a rule of thumb, whenever something has an 'api' annotation, it should also have a 'stability' annotation. A more verbose documentation of ol3 specific annotation usage is available in the new 'apidoc/readme.md' file. This commit also modifies all source files to implement these usage suggestions.
This change adds a stability value to the api annotation, with 'experimental' as default value. enum, typedef and event annotations are never exportable, but api annotations are needed there to make them appear in the docs. Nested typedefs are no longer inlined recursively, because the resulting tables get too wide with the current template.
Because ol.proj.EPSG4326 et al. extend ol.proj.Projection which has exportable methods, these constructors need to be exportable as well (e.g. so ol.proj.EPSG4326.prototype is defined in exports.js when calling goog.exportProperty on getCode etc.). If we really don't want these to be exportable, they should be removed or made private (and named like ol.proj.EPSG4326_) for internal use only.
With this change, the only two remaining generated scripts are build/exports.js and build/test/requireall.js. Both are only required by Plovr. With the Node based build task, a temporary exports.js file is created. The Node based server can be used to run the tests without build/test/requireall.js.
The build/exports.js file passes gjslint and jshint, so the separate linting task is not needed.
Thanks for the review @elemoine. Rebased with your comments addressed. I'll merge when the build passes. Thanks for the great collaboration on this @ahocevar. I'm looking forward to making additional changes to better support the hosted build tool, and there will likely be other changes once we further test the builds, but I think this is a solid foundation to work on. |
Annotation for exportable methods. Node based tasks for generating exports and a custom build. Fixes #613.
now that this is in, I'll cut beta5 unless I hear any objections to do so in the next hour or so |
+1 for me. Thanks Bart. (The mailing list may have been a better a place for this.) |
So what should I do if want to build my application and ol3 together? Should I add both |
I built the vector-layer example with the following config: {
"exports": [],
"src": ["src/**/*.js", "examples/vector-layer.js"],
"compile": {
"js": ["externs/olx.js"],
"externs": [
"externs/bingmaps.js",
"externs/example.js",
"externs/geojson.js",
"externs/oli.js",
"externs/proj4js.js",
"externs/tilejson.js",
"externs/topojson.js",
"externs/vbarray.js"
],
"define": [
"goog.dom.ASSUME_STANDARDS_MODE=true",
"goog.DEBUG=false"
],
"compilation_level": "ADVANCED_OPTIMIZATIONS",
"output_wrapper": "(function(){%output%})();",
"use_types_for_optimization": true
}
} The resulting build's size is 66K (gzipped), while vector-layer.combined.js built with Plovr is 56K. Can I get the same build size? How? Thanks. |
@elemoine Add |
Ok, I saw your comment about this indeed. But @tschaub also said that closure-lib is faster than the compiler at resolving dependencies. So I don't know what should be used. |
But yes using |
If you use this setting, the already reduced list of source files (which |
Thanks Andreas. Interested in information @tschaub may have on this. |
I also get good results by adding {
"exports": [],
"src": ["src/**/*.js"],
"compile": {
"js": ["examples/vector-layer.js", "externs/olx.js"],
"closure_entry_point": "app",
"externs": [
"externs/bingmaps.js",
"externs/example.js",
"externs/geojson.js",
"externs/oli.js",
"externs/proj4js.js",
"externs/tilejson.js",
"externs/topojson.js",
"externs/vbarray.js"
],
"define": [
"goog.dom.ASSUME_STANDARDS_MODE=true",
"goog.DEBUG=false"
],
"compilation_level": "ADVANCED_OPTIMIZATIONS",
"output_wrapper": "(function(){%output%})();",
"use_types_for_optimization": true
}
} Here But that still does not explain why having the compiler "manage" dependencies reduces the build size. That doesn't make too much sense to me. |
@elemoine |
Thanks @probins. I wonder if |
I would imagine that plovr uses it, but I know little about plovr |
This changes a number of things in support of a configurable build tool:
*.exports
files are removed in favor of@todo api
annotation in the source files (this will become@api
when we move on from Plovr)tasks/generate-symbols.js
task produces abuild/symbols.json
file with metadata about exportable symbolstasks/generate-exports.js
task produces abuild/exports.js
script withgoog.exportProperty
andgoog.exportSymbol
callsbuild.py
script has been modified to call the above tasksCurrently, the way the
generate-exports.js
task is called, it generates anexports.js
file that exports all exportable symbols. This task also supports generating exports for a subset of all symbols by passing it a JSON configuration file with a list of symbols or symbol patterns. An example configuration file might look like this:Items in the
exports
array that end with*
are patterns. Patterns match symbol names that start with the string before the*
. The#
indicates a prototype property. So the above configuration would generate exports for theol.Map
constructor, theol.layer.Vector
constructor, all vector layer methods (including inherited ones that are also exportable), and all constants in theol.BrowserFeature
namespace.This is the first part of a build configuration. The next part is a set of options for the compiler. A config file with both of these parts will get passed to a
tasks/build.js
script that 1) generates exports, 2) sorts lib files in dependency order, and 3) drives the compiler.