:wave: Is it expected that the `.mjs` output file ...
# javascript
n
👋 Is it expected that the
.mjs
output file of my module contains types that I haven’t marked with @JsExport? More info in thread.
My main
.mjs
file, named
spoiless-root.mjs
contains a huge list of imports on the top that it’s trying to import from itself:
Copy code
//... Many others...
  get_commonDataModule2u77pvjm58352 as   get_commonDataModule,
  get_deepLinksModule3esna0a3drdgs as get_deepLinksModule,
  get_pushDataModule2jv5av0b2jnhu as get_pushDataModule,
  get_lifecycleModule2m2wpb3mye1uh as get_lifecycleModule,
  UserRepository1qgsoxuwadb1q as UserRepository,
  DiTokens_getInstance19at4048hu77e as DiTokens_getInstance,
  jsExport131nsgrfmqfh7 as jsExport,
} from './spoiless-root.mjs';
This is crashing on typescript, stating:
Copy code
Attempted import error: 'X' is not exported from './spoiless-root.mjs' (imported as 'Y').
To be more clear, I don’t want these classes to be exported since they are not going to be used from JavaScript, they are internal.
a
Hey. Firstly, no, it's not expected to file import itself. Secondly, it will contain some exports to give access to declarations defined in the current module/file that are used in other modules/files (just to link them). The only difference, that the declarations annotated with the @JsExport annotation will have stable name without any suffix like
2m2wpb3mye1uh
.
n
Thanks for your answer! Yeah, that makes sense. So what could be the reason for this file to be importing itself? This is the gradle configuration:
Copy code
js(IR) {
  moduleName = "spoiless-root"
  browser()
  binaries.library()
  useEsModules()
  generateTypeScriptDefinitions()
}
a
It seems like it's a bug inside the compiler. Could you please make a small reproducer and make an issue on YouTrack?
n
I'll try, sure!!
🙏 1
It’s not happening on a smaller project, and I don’t know what could be causing it 😞.
Ah đŸ€Š, it was all about two modules having the same value set to
moduleName
, hence the import to “itself”, it wasn’t itself, it was trying to import another module but the naming was the same.
a
đŸ«‚