Does Closure Compiler support Import Maps?

148 views
Skip to first unread message

Kaban Oid

unread,
Aug 4, 2021, 4:54:53 AM8/4/21
to Closure Compiler Discuss
Hi All,

ESM brings new possibilities for Web developers. There is Import Maps proposal among other useful ESM features. It gives us ability to define path to actual file on disk for our "bare import specifiers" without any plugins or build tools.

Closure Compiler documentation says:
import foo from 'folder/source' - this import would be looked for in the appropriate node_modules folder

I have couple of questions about this:
- Is this possible to tell Closure Compiler (without using 3rd party libs) where actual "folder/source" file is located on our disk if it's not located in node_modules folder?
- Do you have plans to add support for importmap in Closure Compiler if it's not there yet?

Many Thanks,
Pavel

Bradford Smith

unread,
Aug 11, 2021, 1:24:56 PM8/11/21
to Closure Compiler Discuss
Hi Pavel,

The core closure-compiler team has no current plans to support import maps.
We have to support a large body of code built upon the `goog.module` system that was created before ES modules existed.
Also the way ES modules work is incompatible with several aspects of how the compiler works and the way it was designed for building applications.
As a result our support for ES modules is somewhat limited and improving it is not likely to be a high priority in the near future.

Sorry,
Bradford

Jackie Han

unread,
Aug 12, 2021, 6:09:27 AM8/12/21
to Closure Compiler Discuss
> As a result our support for ES modules is somewhat limited and improving it is not likely to be a high priority in the near future.
Sad to hear that.

Chad Killingsworth

unread,
Aug 15, 2021, 1:55:18 PM8/15/21
to Closure Compiler Discuss
I've looked into implementing import maps, but so far have not found a need. I actively use import maps in both dev and production, but have not yet found a need to provide an input import map to Closure Compiler. I produce an output import map from the compilation results (but haven't needed the compiler for that either).

Do you have a specific use case or problem in mind that's not covered by other tools?

Chad Killingsworth

Kaban Oid

unread,
Aug 16, 2021, 6:51:58 AM8/16/21
to Closure Compiler Discuss

JS libs/deps might not be located inside node_modules folder. For example, snowpack creates it's own folder - web_modules. NPM is optional tool, one project may not have npm as dependency at all. MVN's Closure Compiler can be used in such project as a transpiler from ES.next to ES6. In other words, Import Maps (or bare specifier) is not NPM proposal, it is ES.next proposal.
Reply all
Reply to author
Forward
0 new messages