Skip to content
This repository has been archived by the owner on Feb 5, 2022. It is now read-only.

Joycon don't recognize .mjs saofile #160

Open
ghost opened this issue Dec 3, 2020 · 0 comments
Open

Joycon don't recognize .mjs saofile #160

ghost opened this issue Dec 3, 2020 · 0 comments

Comments

@ghost
Copy link

ghost commented Dec 3, 2020

Hey there, @egoist!

Recently, i made a PR for including support for .mjs files, but after some tests and bug tracking, i've noticed a unexpected behavior coming from joycon

According to the docs:

By default only .js and .json file are parsed, otherwise raw data will be returned, so you can add custom loader to parse them

So, that means .mjs files are excluded as valid configuration files, expect, if they are properly parsed and interpreted, and this can be done with the .addLoader() method, right after the warning above

joycon.addLoader({
  test: /\.mjs$/,
  load: async filepath => (await import(filepath)).default
})

But this solution reaches to a dead end road, as the project is written with commonjs module system, consequently, being unable to import anything esm-ishy, simply migrating everything to esm seems cumbersome (i've tried, with no success), also, i thought on some other possible solutions like:

  • Using acorn to parse the .mjs saofile
  • Relying on fs.readFileSync() to accomplish this task

But both methods above seems really hacky and overcomplicated, do you have any insight on how to include .mjs files into the parsing process? (the same way that happens with .js files)

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

No branches or pull requests

0 participants