Skip to content
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

Failing to resolve implied index file when using module_resolution=node #3668

Open
thelgevold opened this issue Aug 31, 2020 · 2 comments
Open
Assignees

Comments

@thelgevold
Copy link

thelgevold commented Aug 31, 2020

There appears to be an issue with module_resolution=node when using .mjs files.

In my sample project I am unable to get Closure to resolve relative short hand module imports like ../internal to ../internal/index.mjs. As far as I understand, this should be a standard node resolution operation where index is implied if internal is a folder.

If this was my own code I would just change the import to use the long hand notation, but this happens in a third party library (Svelte). As a workaround I have created a SED script for manually rewriting the imports, but it would be great if these types of imports were resolved. Bundlers like Rollup resolve them just fine.

Including relevant parts of my flag file below:

--compilation_level=ADVANCED_OPTIMIZATIONS
--language_out ECMASCRIPT_2015
--language_in ECMASCRIPT_2015
--js_output_file=public/build/bundle-closure.js

--rewrite_polyfills=false

--warning_level=QUIET

--rewrite_polyfills=false
--jscomp_off=checkVars

--package_json_entry_names es2015,module,jsnext:main
--module_resolution=node

--js node_modules/svelte/package.json
--js node_modules/svelte/index.mjs

--js node_modules/svelte/internal/package.json
--js node_modules/svelte/internal/index.mjs

--js node_modules/svelte/store/package.json
--js node_modules/svelte/store/index.mjs

--js node_modules/svelte/transition/package.json
--js node_modules/svelte/transition/index.mjs

--js node_modules/svelte/easing/package.json
--js node_modules/svelte/easing/index.mjs

--js src/**.js
--entry_point=src/main.js

I have a repro of this in my project here: https://github.com/thelgevold/svelte-closure-sample.

Skipping to run the rewrite script (resplace.sh) will reproduce the problem.

Version of Closure: "google-closure-compiler": "20200719.0.0" (npm)

@lauraharker
Copy link
Contributor

@ChadKillingsworth do you know if this is the expected behavior?

@ChadKillingsworth
Copy link
Collaborator

This does indeed look to be a bug. I'm guessing the compiler doesn't look for .mjs extension files at all right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants