Skip to content

json-6 require not working? #48

@JakobJingleheimer

Description

@JakobJingleheimer

Sorry, I'm not sure exactly what the problem is, but it appears json-6/lib/require doesn't work (and I'm seeing that require.extensions is deprecated).

When I try to import a .json6 file and run it with mochajs/mocha (which I think uses standard-things/esm), I get the following error:

TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".json6"
for …/dummy-data.json6
    at new NodeError (node:internal/errors:259:15)
    at Loader.defaultGetFormat [as _getFormat] (node:internal/modules/esm/get_format:65:15)
    at Loader.getFormat (node:internal/modules/esm/loader:101:42)
    at Loader.getModuleJob (node:internal/modules/esm/loader:230:31)
    at async ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:53:21)
    at async Promise.all (index 0)
    at async link (node:internal/modules/esm/module_job:58:9)

I've included json-6/lib/require in mocha's --require and confirmed the file is executed; however, the function set for '.json6' never executes.

I see that there is specific mention of JSON6 in esm's readme, so I tried adding the cited config to my package.json, but to no effect:

"esm": {
  "JSON6": true
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions