{"id":16994540,"url":"https://github.com/dandv/es-module-example-mjs","last_synced_at":"2025-03-22T05:43:24.636Z","repository":{"id":57298725,"uuid":"104707363","full_name":"dandv/es-module-example-mjs","owner":"dandv","description":"ES module (.mjs) that can be used natively from node 8.5.0+, without transpilers","archived":false,"fork":false,"pushed_at":"2017-09-25T06:02:35.000Z","size":4,"stargazers_count":1,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-02T03:52:26.634Z","etag":null,"topics":["es-module","es6","es6-modules","example","javascript","sample"],"latest_commit_sha":null,"homepage":"https://medium.com/@dandv/publishing-native-es-modules-with-node-v8-5-0-730736e0f612","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dandv.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-25T05:39:14.000Z","updated_at":"2021-01-21T09:40:35.000Z","dependencies_parsed_at":"2022-08-26T17:00:54.466Z","dependency_job_id":null,"html_url":"https://github.com/dandv/es-module-example-mjs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dandv%2Fes-module-example-mjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dandv%2Fes-module-example-mjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dandv%2Fes-module-example-mjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dandv%2Fes-module-example-mjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dandv","download_url":"https://codeload.github.com/dandv/es-module-example-mjs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244913005,"owners_count":20530769,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["es-module","es6","es6-modules","example","javascript","sample"],"created_at":"2024-10-14T03:45:51.950Z","updated_at":"2025-03-22T05:43:24.619Z","avatar_url":"https://github.com/dandv.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# es-module-example-mjs\nES module (.mjs) that can be used natively from node 8.5.0+, without transpilers.\n\nStarting with version 8.5.0, Node.js supports ES modules natively, behind a command line option. Read more at [2ality - Using ES modules natively in Node.js](http://2ality.com/2017/09/native-esm-node.html).\n\n## How this works\n\nTo publish a native ES module, simply define `main` [in `package.json`](https://github.com/dandv/es-module-example-mjs/blob/master/package.json#L5) to point to a file with the `.mjs` extension:\n\n```json\n{\n  \"name\": \"mjs-example\",\n  \"version\": \"1.0.2\",\n  \"description\": \"ES native module (.mjs) - requires node 8.5.0+\",\n  \"main\": \"example.mjs\"\n}\n```\n\nThat's the only change. Your [existing transpilation process](https://github.com/dandv/local-iso-dt/blob/master/package.json#L13) to support older Node versions will work as before - just make sure to point Babel to the `.mjs` file(s).\n\n## Usage\n\n1. Install the module:\n\n```bash\nyarn add mjs-example\n# or, npm install mjs-example\n```\n\n2. Create a [test file](https://github.com/dandv/es-module-example-mjs/blob/master/mjs-test.mjs):\n\n```js\nimport {hello} from 'mjs-example';\nconsole.log(hello);\n```\n\n3. Run `node` (v8.5.0+) with the `--experimental-modules` flag:\n\n```bash\nnode --experimental-modules mjs-test.mjs\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdandv%2Fes-module-example-mjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdandv%2Fes-module-example-mjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdandv%2Fes-module-example-mjs/lists"}