Skip to content

Make the module ES modules compatible#33

Open
qubyte wants to merge 8 commits intomapbox:mainfrom
qubyte:esm
Open

Make the module ES modules compatible#33
qubyte wants to merge 8 commits intomapbox:mainfrom
qubyte:esm

Conversation

@qubyte
Copy link

@qubyte qubyte commented Aug 19, 2021

This PR updates the code to be in ES modules, and adds a build to retain compatibility with CJS contexts. To CJS users there should be no obvious change. One thing to note though, is that the CLI will now only work with Node 12.22 and up (all maintained versions of node are supported).

Closes #29

@qubyte qubyte force-pushed the esm branch 2 times, most recently from 0931d1a to 7c9f5b6 Compare August 19, 2021 16:54
argv = require('minimist')(process.argv.slice(2), {
boolean: 'clockwise'
});
import rewind from "@mapbox/geojson-rewind";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not import local module?

Copy link
Author

@qubyte qubyte Aug 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is the local module :)

This is a quirk/benefit of how the exports field in the package.json file works. It's a little safer because it allows the entry point to be renamed without breaking. I've done the same in the test module. Unfortunately import rewind from "./" doesn't seem to work, so the direct translation from CJS isn't an option (at least, I haven't managed to reproduce that behaviour).

The alternative is the direct local import, which would look like import rewind from "./index.js";. Happy to change to that if you prefer, though it is (very slightly) less robust.

@qubyte qubyte force-pushed the esm branch 2 times, most recently from 4fda323 to 35b189c Compare August 21, 2021 20:53
@qubyte
Copy link
Author

qubyte commented Sep 2, 2021

Is there a way to get CI to run by the way, or is that something which has to be triggered by an admin? If there are travis issues I'd be happy to follow up with a GitHub Actions workflow for CI tasks.

@qubyte
Copy link
Author

qubyte commented Sep 22, 2021

Sorry to bump again. I'd love to make progress with this.

@qubyte
Copy link
Author

qubyte commented Oct 4, 2021

@mourner (you're the latest to commit, so apologies if I'm attracting the attention of the wrong person), I'd like to avoid this stagnating if I can...

qubyte added 4 commits July 30, 2023 14:22
@qubyte qubyte force-pushed the esm branch 2 times, most recently from 79b76db to 8c38b58 Compare July 30, 2023 13:30
@qubyte
Copy link
Author

qubyte commented Jul 30, 2023

Rebased and updated the relevant bits.

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 this pull request may close these issues.

Introduce bundler or export an es module

2 participants