google / google/closure-compiler

manifest file does not preserve order of entry points

Open
#1,474 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
7.7k
Forks
1.2k
Avg merge
2d 12h
Merged PRs (30d)
6

Description

Use case:

I would like to use the ability of the compiler to manage dependencies and build a modularized app (as in closure compiler modules). Up to this point I have been using the calcdeps.py script, but unfortunately it does not support the new goog.module/goog.require method of declaring namespaces.

The sample app is consisting of 3 modules: html_init, app_init and settings_init. The html module is 'empty' module - it does nothing but console.log - in real application it would contain the soy templates and a call to render it on the page and not much more - the idea being to display the html asap - we usually inline this module in the html response. Note that it does not contain the module management and loading code (it does not require 'goog.module.*'

The second module (app_init) contains the bulk of the app and the module management/loading code and is loaded with script tag: it is also responsible to mark the html module and itself (app) as loaded for the module management to work. It also contains code to load the third module.

The third module contains namespaces that are not used in any other module.

Here is the command used (python script from closure library):

```
python ../../library/closure/bin/calcdeps.py \
--path js/ \
--path build/gen/ \
--path build/tpl/en/ \
--path ../../library/ \
--path ../smjs/ \
--path ../pstj/ \
--path ../../templates/ \
-i js/modules/html_init.js \
-i js/modules/app_init.js \
-i js/modules/settings_init.js \
-o list \
-e ../../templates/src/ \
-e ../pstj/tpl/ \
-e ../smjs/tpl/ > build/modules.txt
```

And the result is this (note the correctly arranged dependencies: first module does nothing so it does not require anything, second module contains the module management and third requires some additional namespaces):

```
../../library/closure/goog/base.js
js/modules/html_init.js
../../library/closure/goog/functions/functions.js
../../library/closure/goog/promise/thenable.js
../../library/closure/goog/debug/error.js
../../library/closure/goog/dom/nodetype.js
../../library/closure/goog/string/string.js
../../library/closure/goog/asserts/asserts.js
../../library/closure/goog/async/freelist.js
../../library/closure/goog/async/workqueue.js
../../library/closure/goog/debug/entrypointregistry.js
../../library/closure/goog/dom/tagname.js
../../library/closure/goog/array/array.js
../../library/closure/goog/labs/useragent/util.js
../../library/closure/goog/object/object.js
../../library/closure/goog/labs/useragent/browser.js
../../library/closure/goog/labs/useragent/engine.js
../../library/closure/goog/async/nexttick.js
../../library/closure/goog/async/run.js
../../library/closure/goog/promise/resolver.js
../../library/closure/goog/promise/promise.js
../../library/closure/goog/disposable/idisposable.js
../../library/closure/goog/disposable/disposable.js
../../library/closure/goog/labs/useragent/platform.js
../../library/closure/goog/useragent/useragent.js
../../library/closure/goog/events/browserfeature.js
../../library/closure/goog/events/eventid.js
../../library/closure/goog/events/event.js
../../library/closure/goog/events/eventtype.js
../../library/closure/goog/reflect/reflect.js
../../library/closure/goog/events/browserevent.js
../../library/closure/goog/events/listenable.js
../../library/closure/goog/events/listener.js
../../library/closure/goog/events/listenermap.js
../../library/closure/goog/events/events.js
../../library/closure/goog/events/eventtarget.js
../../library/closure/goog/timer/timer.js
../../library/closure/goog/events/eventhandler.js
../../library/closure/goog/dom/tags.js
../../library/closure/goog/string/typedstring.js
../../library/closure/goog/string/const.js
../../library/closure/goog/html/safestyle.js
../../library/closure/goog/html/safestylesheet.js
../../library/closure/goog/fs/url.js
../../library/closure/goog/i18n/bidi.js
../../library/closure/goog/html/safeurl.js
../../library/closure/goog/html/trustedresourceurl.js
../../library/closure/goog/html/safehtml.js
../../library/closure/goog/html/safescript.js
../../library/closure/goog/html/uncheckedconversions.js
../../library/closure/goog/structs/structs.js
../../library/closure/goog/structs/collection.js
../../library/closure/goog/math/math.js
../../library/closure/goog/iter/iter.js
../../library/closure/goog/structs/map.js
../../library/closure/goog/structs/set.js
../../library/closure/goog/debug/debug.js
../../library/closure/goog/debug/logrecord.js
../../library/closure/goog/debug/logbuffer.js
../../library/closure/goog/debug/logger.js
../../library/closure/goog/log/log.js
../../library/closure/goog/module/module.js
../../library/closure/goog/module/abstractmoduleloader.js
../../library/closure/goog/net/bulkloaderhelper.js
../../library/closure/goog/net/eventtype.js
../../library/closure/goog/json/json.js
../../library/closure/goog/net/errorcode.js
../../library/closure/goog/net/httpstatus.js
../../library/closure/goog/net/xhrlike.js
../../library/closure/goog/net/xmlhttpfactory.js
../../library/closure/goog/net/wrapperxmlhttpfactory.js
../../library/closure/goog/net/xmlhttp.js
../../library/closure/goog/uri/utils.js
../../library/closure/goog/net/xhrio.js
../../library/closure/goog/net/bulkloader.js
../../library/third_party/closure/goog/mochikit/async/deferred.js
../../library/closure/goog/dom/browserfeature.js
../../library/closure/goog/dom/safe.js
../../library/closure/goog/math/coordinate.js
../../library/closure/goog/math/size.js
../../library/closure/goog/dom/dom.js
../../library/closure/goog/net/jsloader.js
../../library/closure/goog/useragent/product.js
../../library/closure/goog/module/moduleloader.js
../../library/closure/goog/structs/simplepool.js
../../library/closure/goog/debug/tracer.js
../../library/closure/goog/module/basemodule.js
../../library/closure/goog/module/moduleloadcallback.js
../../library/closure/goog/module/moduleinfo.js
../../library/closure/goog/module/modulemanager.js
js/modules/app_init.js
../../library/closure/goog/async/animationdelay.js
../../library/closure/goog/dom/classlist.js
../../library/closure/goog/dom/vendor.js
../../library/closure/goog/math/box.js
../../library/closure/goog/math/rect.js
../../library/closure/goog/style/style.js
../../library/closure/goog/ui/idgenerator.js
../../library/closure/goog/ui/component.js
../../library/closure/goog/events/keycodes.js
../../library/closure/goog/events/keyhandler.js
../../library/closure/goog/ui/controlcontent.js
../../library/closure/goog/a11y/aria/roles.js
../../library/closure/goog/a11y/aria/attributes.js
../../library/closure/goog/a11y/aria/datatables.js
../../library/closure/goog/a11y/aria/aria.js
../../library/closure/goog/ui/controlrenderer.js
../../library/closure/goog/ui/registry.js
../../library/closure/goog/ui/decorate.js
../../library/closure/goog/ui/control.js
../../library/closure/goog/async/delay.js
../../library/closure/goog/pubsub/topicid.js
../../library/closure/goog/pubsub/pubsub.js
../../library/closure/goog/pubsub/typedpubsub.js
../pstj/debug/pubsub.js
../pstj/ds/cache.js
../pstj/ui/agents/agent.js
../pstj/ui/agents/pointer.js
../pstj/ui/agents/scroll.js
../pstj/ds/dtobase.js
../pstj/ds/ilistitem.js
../pstj/object/object.js
../pstj/ds/listitem.js
../../library/closure/goog/dom/dataset.js
../../library/closure/goog/structs/queue.js
../../library/closure/goog/structs/pool.js
../pstj/ng/ifilter.js
../../library/closure/goog/date/datelike.js
../../library/closure/goog/i18n/datetimesymbols.js
../../library/closure/goog/date/date.js
../../library/closure/goog/i18n/timezone.js
../../library/closure/goog/i18n/datetimeformat.js
../pstj/date/utils.js
../pstj/ng/filters.js
../pstj/ds/ngmodel.js
../pstj/material/eventmaps.js
../pstj/material/state.js
../../library/closure/goog/structs/inversionmap.js
../../library/closure/goog/i18n/graphemebreak.js
../../library/closure/goog/format/format.js
../../library/closure/goog/html/legacyconversions.js
../../library/closure/goog/i18n/bidiformatter.js
../../library/closure/goog/soy/data.js
../../library/closure/goog/soy/soy.js
../../library/closure/goog/string/stringbuffer.js
../../templates/soyutils_usegoog.js
build/tpl/en/material.soy.js
../pstj/material/elements/element.js
build/tpl/en/app.soy.js
js/component/tilerenderer.js
js/component/tile.js
js/modules/settings_init.js
```

The command I am trying to use to make the same thing with ccompiler is as follows (notice that I am passing in several entry points and in the order I would expect them to be used):

```
java -jar ../../compiler/compiler.jar \
--dependency_mode=STRICT \
--entry_point=goog:html_init \
--entry_point=goog:app_init \
--entry_point=goog:settings_init \
--output_manifest build/modules.filelist.txt \
--js_output_file /tmp/closure_compiler_build \
--js="js/**.js" --js="build/gen/**.js" --js="build/tpl/en/**.js" --js="../../templates/soyutils_usegoog.js" --js="../../library/closure/goog/**.js" --js="../../library/third_party/closure/goog/mochikit/async/deferred.js" --js="../../library/third_party/closure/goog/mochikit/async/deferredlist.js" --js="../pstj/animation/**.js" --js="../pstj/app/**.js" --js="../pstj/autogenerated/**.js" --js="../pstj/cast/**.js" --js="../pstj/color/**.js" --js="../pstj/config/**.js" --js="../pstj/control/**.js" --js="../pstj/date/**.js" --js="../pstj/debug/**.js" --js="../pstj/ds/**.js" --js="../pstj/element/**.js" --js="../pstj/error/**.js" --js="../pstj/fx/**.js" --js="../pstj/graphics/**.js" --js="../pstj/material/**.js" --js="../pstj/math/**.js" --js="../pstj/mvc/**.js" --js="../pstj/ng/**.js" --js="../pstj/object/**.js" --js="../pstj/options/**.js" --js="../pstj/resource/**.js" --js="../pstj/sourcegen/**.js" --js="../pstj/storage/**.js" --js="../pstj/style/**.js" --js="../pstj/themes/**.js" --js="../pstj/ui/**.js" --js="../pstj/worker/**.js" --js="../smjs/ds/**.js" --js="../smjs/element/**.js" --js="../smjs/persistence/**.js" --js="../smjs/player/**.js" --js="../smjs/remotecontrol/**.js" --js="../smjs/transport/**.js" --js="../smjs/tv/**.js" --js="../smjs/widgets/**.js" --js="!**_test.js"
```

However the output is different: all dependencies are put before the first module which is now the app module, then the first and third module are added with all of their deps attached to the first module.
compiler manifest output:

```
../../library/closure/goog/base.js
../../library/closure/goog/debug/error.js
../../library/closure/goog/dom/nodetype.js
../../library/closure/goog/string/string.js
../../library/closure/goog/asserts/asserts.js
../../library/closure/goog/array/array.js
../../library/closure/goog/labs/useragent/util.js
../../library/closure/goog/labs/useragent/engine.js
../../library/closure/goog/labs/useragent/platform.js
../../library/closure/goog/object/object.js
../../library/closure/goog/labs/useragent/browser.js
../../library/closure/goog/useragent/useragent.js
../../library/closure/goog/events/browserfeature.js
../../library/closure/goog/events/eventid.js
../../library/closure/goog/events/listenable.js
../../library/closure/goog/events/eventtype.js
../../library/closure/goog/reflect/reflect.js
../../library/closure/goog/disposable/idisposable.js
../../library/closure/goog/disposable/disposable.js
../../library/closure/goog/events/event.js
../../library/closure/goog/events/browserevent.js
../../library/closure/goog/debug/entrypointregistry.js
../../library/closure/goog/events/listener.js
../../library/closure/goog/events/listenermap.js
../../library/closure/goog/events/events.js
../../library/closure/goog/async/freelist.js
../../library/closure/goog/async/workqueue.js
../../library/closure/goog/dom/tagname.js
../../library/closure/goog/functions/functions.js
../../library/closure/goog/async/nexttick.js
../../library/closure/goog/async/run.js
../../library/closure/goog/pubsub/pubsub.js
../../library/closure/goog/pubsub/typedpubsub.js
../../library/closure/goog/pubsub/topicid.js
../pstj/debug/pubsub.js
../../library/closure/goog/i18n/bidi.js
../../library/closure/goog/fs/url.js
../../library/closure/goog/string/typedstring.js
../../library/closure/goog/string/const.js
../../library/closure/goog/html/safeurl.js
../../library/closure/goog/html/safestyle.js
../../library/closure/goog/html/safestylesheet.js
../../library/closure/goog/html/trustedresourceurl.js
../../library/closure/goog/dom/tags.js
../../library/closure/goog/html/safehtml.js
../../library/closure/goog/html/safescript.js
../../library/closure/goog/html/uncheckedconversions.js
../../library/closure/goog/structs/collection.js
../../library/closure/goog/math/math.js
../../library/closure/goog/iter/iter.js
../../library/closure/goog/structs/map.js
../../library/closure/goog/structs/structs.js
../../library/closure/goog/structs/set.js
../../library/closure/goog/debug/debug.js
../../library/closure/goog/debug/logrecord.js
../../library/closure/goog/debug/logbuffer.js
../../library/closure/goog/debug/logger.js
../../library/closure/goog/log/log.js
../pstj/ds/cache.js
../pstj/ui/agents/agent.js
../../library/closure/goog/async/animationdelay.js
../pstj/ui/agents/scroll.js
../../library/closure/goog/dom/classlist.js
../../library/closure/goog/ui/registry.js
../../library/closure/goog/useragent/product.js
../../library/closure/goog/dom/dataset.js
../../library/closure/goog/structs/queue.js
../../library/closure/goog/structs/pool.js
../../library/closure/goog/math/size.js
../../library/closure/goog/math/coordinate.js
../../library/closure/goog/math/box.js
../../library/closure/goog/math/rect.js
../../library/closure/goog/dom/safe.js
../../library/closure/goog/dom/browserfeature.js
../../library/closure/goog/dom/dom.js
../../library/closure/goog/dom/vendor.js
../../library/closure/goog/style/style.js
../../library/closure/goog/i18n/datetimesymbols.js
../../library/closure/goog/date/datelike.js
../../library/closure/goog/date/date.js
../../library/closure/goog/i18n/timezone.js
../../library/closure/goog/i18n/datetimeformat.js
../pstj/date/utils.js
../pstj/ng/ifilter.js
../pstj/ng/filters.js
../pstj/ds/ngmodel.js
../../library/closure/goog/soy/data.js
../../library/closure/goog/string/stringbuffer.js
../../library/closure/goog/html/legacyconversions.js
../../library/closure/goog/i18n/bidiformatter.js
../../library/closure/goog/soy/soy.js
../../library/closure/goog/structs/inversionmap.js
../../library/closure/goog/i18n/graphemebreak.js
../../library/closure/goog/format/format.js
../../templates/soyutils_usegoog.js
../../library/closure/goog/ui/idgenerator.js
../../library/closure/goog/events/eventtarget.js
../../library/closure/goog/events/eventhandler.js
../../library/closure/goog/ui/component.js
../../library/closure/goog/ui/decorate.js
../../library/closure/goog/a11y/aria/roles.js
../../library/closure/goog/a11y/aria/attributes.js
../../library/closure/goog/a11y/aria/datatables.js
../../library/closure/goog/a11y/aria/aria.js
../../library/closure/goog/ui/controlrenderer.js
../../library/closure/goog/events/keycodes.js
../../library/closure/goog/events/keyhandler.js
../../library/closure/goog/ui/controlcontent.js
../../library/closure/goog/ui/control.js
../pstj/ds/ilistitem.js
../pstj/object/object.js
../pstj/ds/listitem.js
../../library/closure/goog/promise/thenable.js
../../library/closure/goog/promise/resolver.js
../../library/closure/goog/promise/promise.js
../../library/closure/goog/timer/timer.js
../../library/closure/goog/async/delay.js
../pstj/ui/agents/pointer.js
../pstj/material/state.js
../pstj/ds/dtobase.js
build/tpl/en/material.soy.js
../pstj/material/eventmaps.js
../pstj/material/elements/element.js
build/tpl/en/app.soy.js
js/component/tilerenderer.js
js/component/tile.js
../../library/closure/goog/module/module.js
../../library/closure/goog/module/abstractmoduleloader.js
../../library/closure/goog/net/bulkloaderhelper.js
../../library/closure/goog/net/eventtype.js
../../library/closure/goog/uri/utils.js
../../library/closure/goog/net/errorcode.js
../../library/closure/goog/json/json.js
../../library/closure/goog/net/xhrlike.js
../../library/closure/goog/net/xmlhttpfactory.js
../../library/closure/goog/net/wrapperxmlhttpfactory.js
../../library/closure/goog/net/xmlhttp.js
../../library/closure/goog/net/httpstatus.js
../../library/closure/goog/net/xhrio.js
../../library/closure/goog/net/bulkloader.js
../../library/third_party/closure/goog/mochikit/async/deferred.js
../../library/closure/goog/net/jsloader.js
../../library/closure/goog/module/moduleloader.js
../../library/closure/goog/module/basemodule.js
../../library/closure/goog/module/moduleloadcallback.js
../../library/closure/goog/module/moduleinfo.js
../../library/closure/goog/structs/simplepool.js
../../library/closure/goog/debug/tracer.js
../../library/closure/goog/module/modulemanager.js
js/modules/app_init.js
js/modules/html_init.js
js/modules/settings_init.js
```

I am aware that during compilation the compiler is able to move code from one module to the other but this order of files leaves no chance of separating the app into chunks, it makes the module separation unusable as it bulks everything into the first module that is now the one that will be loaded second and thus the actually loaded first will not work at all.

Is there a way to accomplish module separation as described with the compiler only or alternatively to update the calcdeps file to support goog.module/goog.require syntax?

I would like to note that using the compiler to output manifest for non-modularized compiles is working correctly.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.