{"id":17974734,"url":"https://github.com/vadorequest/es2018-esm-examples","last_synced_at":"2026-04-11T07:35:52.209Z","repository":{"id":73629753,"uuid":"172267635","full_name":"Vadorequest/es2018-esm-examples","owner":"Vadorequest","description":"Showcase usages of ESM and how it compares to using node, no babel, no webpack, no rollup needed!","archived":false,"fork":false,"pushed_at":"2019-02-23T22:33:46.000Z","size":28,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-01T01:40:04.655Z","etag":null,"topics":["babel","esm","node","rollup","webpack"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Vadorequest.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-23T21:45:34.000Z","updated_at":"2022-05-19T14:36:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"34520b87-b78d-4a4f-a9f0-30546abcf811","html_url":"https://github.com/Vadorequest/es2018-esm-examples","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Vadorequest/es2018-esm-examples","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vadorequest%2Fes2018-esm-examples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vadorequest%2Fes2018-esm-examples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vadorequest%2Fes2018-esm-examples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vadorequest%2Fes2018-esm-examples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Vadorequest","download_url":"https://codeload.github.com/Vadorequest/es2018-esm-examples/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vadorequest%2Fes2018-esm-examples/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31673067,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-10T17:19:37.612Z","status":"online","status_checked_at":"2026-04-11T02:00:05.776Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["babel","esm","node","rollup","webpack"],"created_at":"2024-10-29T17:15:19.564Z","updated_at":"2026-04-11T07:35:52.188Z","avatar_url":"https://github.com/Vadorequest.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ES2018 examples using ESM\n\n\u003e This is a minimal example about the different usages of ESM and how it compares to using node directly\n\u003e It shows how **easy** it is to use ESM with no additional configuration (webpack, babel, rollup, etc.) \nwhich is just perfect when you want to get things done fast \nwithout spending/wasting time configuring all the boilerplate for ES2018 or import/export features!\n\nBasically, this is a showcase of the 2 different usages of [ESM](https://github.com/standard-things/esm)\n\n- through custom `require` (main file loader), see `./esm-loader.js`\n- through `node -r esm script.js` which requires `esm` before requiring the `script.js`, and therefore support import/export in node 6+\n\nNote that special stuff like spread operator do require node v8.6.0+, support of such features (ES2018) is not provided by ESM\n\n## Testing it out yourself!\n\n- `yarn run node` will load index.js using `node` and fail due to lack of support of node in any existing version (node 6 to 11)\n```bash\nyarn run v1.13.0\n$ node ./index.js\n/Users/vadorequest/dev/es2018-esm-examples/index.js:1\n(function (exports, require, module, __filename, __dirname) { import map from 'lodash.map'; // import/export won't work with standard node not loaded through ESM\n                                                              ^^^^^^\n\nSyntaxError: Unexpected token import\n    at createScript (vm.js:80:10)\n    at Object.runInThisContext (vm.js:139:10)\n    at Module._compile (module.js:616:28)\n    at Object.Module._extensions..js (module.js:663:10)\n    at Module.load (module.js:565:32)\n    at tryModuleLoad (module.js:505:12)\n    at Function.Module._load (module.js:497:3)\n    at Function.Module.runMain (module.js:693:10)\n    at startup (bootstrap_node.js:188:16)\n    at bootstrap_node.js:609:3\nerror Command failed with exit code 1.\ninfo Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.\n\n```\n\n- `yarn run esm-loader` will load index.js through esm-loader.js and fail if node version is \u003c8.6.0, but will work if higher version of node is used\n```bash\nyarn run v1.13.0\n$ node esm-loader.js\n1\n2\n3\n{ '0': 4, '1': 5, '2': 6 }\n✨  Done in 0.22s.\n\n```\n\n- `yarn run node-with-esm` will load index.js using `node` with esm compatible mode and fail if node version is \u003c8.6.0, but will work if higher version of node is used\n```bash\nyarn run v1.13.0\n$ node -r esm ./index.js\n1\n2\n3\n{ '0': 4, '1': 5, '2': 6 }\n✨  Done in 0.22s.\n\n```\n\n- `yarn run node-with-esm:watch` will load index.js using `nodemon` with esm compatible mode and fail if node version is \u003c8.6.0, but will work if higher version of node is used\n```bash\nyarn run v1.13.0\n$ nodemon -r esm ./index.js\n[nodemon] 1.18.10\n[nodemon] to restart at any time, enter `rs`\n[nodemon] watching: *.*\n[nodemon] starting `node -r esm ./index.js`\n1\n2\n3\n{ '0': 4, '1': 5, '2': 6 }\n[nodemon] clean exit - waiting for changes before restart\n```\n\nNodemon is great for scripting/prototyping hence the fact it's in the showcase :)\n\n\nSee `package.json:scripts`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvadorequest%2Fes2018-esm-examples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvadorequest%2Fes2018-esm-examples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvadorequest%2Fes2018-esm-examples/lists"}