question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support ES modules with `@std/esm`

See original GitHub issue

Support ES modules with @std/esm

PR used in this proposal: https://github.com/Turfjs/turf/pull/975

Using @std/esm seems to work perfectly with NodeJS (4+ compatible) and works well with our tape testing suite, ~unfortunately… it doesn’t like it when you use .js for ES Modules~ (Added @std/esm to fix this)

SyntaxError: 'import' and 'export' may only be used in ES modules

~😢 … Going to refactor everything back to .js => .mjs (dropping .es5.js files) once this is done, a fresh git clone would be required.~

🥇 Easy to use

When @std/esm is included as a devDependency, you can easily execute the tape tests using the following:

$ node -r @std/esm test.js
$ node -r @std/esm bench.js
$ node -r @std/esm index.js

🎉 🚀 Omg…! No Rollup pretest was required for this test to run successfully.

Publishing

The Rollup pretest will be changed to => prepublish to transpile the index.js (ES Modules) => dist/index.js (CommonJS) before publishing a new release.

❌ Not happening

  • No Babel on index files
  • No Rollup on test files (tests can be ES Modules or CommonJS 🎉 )

This is such a pain 😢 … (it will be worth it at the end of this madness)

CC: @Turfjs/ownership

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
DenisCarrierecommented, Oct 16, 2017

@jdalton Sorry for the 17+ day response, I still haven’t forgotten about your comment. As for feedback, so far @std/esm is working out just great!

I’ll make sure to send some feedback on @std/esm issues, so far it looks great! 👍

1reaction
rowanwinscommented, Sep 26, 2017

🍻

Read more comments on GitHub >

github_iconTop Results From Across the Web

Steam - DCS World
How to transfer keyless DCS modules purchased on STEAM? Steam modules are not authorized; How do I add command line arguments to a...
Read more >
Question: Plans for Node.js ESM Module Support? #1946
Has there been any talk about how the Node side of the project is going to address to coming ESM/ES6 module migration that...
Read more >
Error [ERR_REQUIRE_ESM]: require() of ES Module not ...
I'm trying to make a Discord bot that just says if someone is online on the game. However I keep getting this message:...
Read more >
Steam Transfers now available via DCS Account Profile
How to transfer keyless DCS modules purchased on STEAM? Please note, all future DCS World DLC released on Steam from 12th May 2017...
Read more >
How to Use ECMAScript Modules With Node.js - How-To Geek
The simple answer is yes. ES Modules are the standardized way to import and export JavaScript code. CJS gave Node a module system...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found