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

Joycon don't recognize .mjs saofile #160

@ghost

Description

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions