ts_library outputs .mjs files with invalid import statements
π bug report
Affected Rule
The issue is caused by the rule: ts_libraryIs this a regression?
UnlikelyDescription
ts_library outputs the JSEcmaScriptModuleInfo provider, but the files it creates don't completely match the ECMAScript spec. Specifically, import statements do not have file extensions for relative imports. More details in the minimal reproduction.
Perhaps ts_library could rewrite relative imports in .mjs so that they include the .mjs extension. These rewrites would only happen if the imported file was from another JSEcmaScriptModuleInfo provider. This is probably very difficult, though.
π¬ Minimal Reproduction
https://github.com/mattsoulanille/ts_library_invalid_import
π₯ Exception or Error
Causes this exception when consuming .mjs outputs in webpack:
BREAKING CHANGE: The request './src/foo' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
π Your Environment
Operating System:
MacOS 12.2 arm, but this is not OS-dependent
Output of bazel version:
Build label: 5.0.0
Build target: bazel-out/darwin_arm64-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Wed Jan 19 14:16:16 2022 (1642601776)
Build timestamp: 1642601776
Build timestamp as int: 1642601776
Rules_nodejs version:
(Please check that you have matching versions between WORKSPACE file and @bazel/* npm packages.)
5.1.0
Anything else relevant?
This issue has been automatically marked as stale because it has not had any activity for 6 months. It will be closed if no further activity occurs in 30 days. Collaborators can add a "cleanup" or "need: discussion" label to keep it open indefinitely. Thanks for your contributions to rules_nodejs!
This issue was automatically closed because it went 30 days without any activity since it was labeled "Can Close?"