Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Support of .mjs #8

Open
ilyaigpetrov opened this issue Jun 9, 2019 · 0 comments · May be fixed by #9
Open

Feature Request: Support of .mjs #8

ilyaigpetrov opened this issue Jun 9, 2019 · 0 comments · May be fixed by #9

Comments

@ilyaigpetrov
Copy link

The main field of your package.json points to index.js but it's internally is in ES6 format. I guess it will break npm expecting main to point to commonjs packages. Instead module field is proposed for ES6 modules and the extension is .mjs, so index.mjs.

I experiment with modules in Node v12 and currently this code:

// node --experimental-modules this-file.mjs
import LocalEchoController from 'local-echo';

throws:

.../node_modules/local-echo/index.js:1
import LocalEchoController from "./lib/LocalEchoController";
       ^^^^^^^^^^^^^^^^^^^

SyntaxError: Unexpected identifier
    at Module._compile (internal/modules/cjs/loader.js:718:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)
    at Module.load (internal/modules/cjs/loader.js:641:32)
    at Function.Module._load (internal/modules/cjs/loader.js:556:12)
    at internal/modules/esm/translators.js:87:15
    at Object.meta.done (internal/modules/esm/create_dynamic_module.js:45:9)
    at file:///home/ilyaigpetrov/Projects/subterm/node_modules/local-echo/index.js:10:13                                                                     
    at ModuleJob.run (internal/modules/esm/module_job.js:111:37)
    at async Loader.import (internal/modules/esm/loader.js:128:24)
@ilyaigpetrov ilyaigpetrov linked a pull request Jun 9, 2019 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant