nmea-simple icon indicating copy to clipboard operation
nmea-simple copied to clipboard

Library Upgrades and Updated Module Format

Open 101100 opened this issue 3 years ago • 4 comments

This upgrades to the latest TypeScript version and updates the output to target ES6 and use ES6 modules. Based on my research, this requires node.js version 14, so I've updated the required node version in the package.json to match.

I've published this version with a beta tag as [email protected]. If anyone gives it a test, please let me know if it works/doesn't work for you.

Fixes #18.

101100 avatar Mar 27 '22 17:03 101100

@becseya This PR was meant to fix #18, but I want to make sure it will work in all cases before I publish it. I've published [email protected] with your changes that are in v3.3.0 as well as the updates to the module format. If it works, I'll make this v4. If not, I'll publish a second copy of the library that uses the module format instead.

101100 avatar Jan 10 '23 18:01 101100

Unfortunately 4.0.0-beta4 breaks my application with error SyntaxError: Cannot use import statement outside a module when attempting to run it.

I've rebased the changes of #19 to 3.2.0 and I'm getting the same error, so I think #20 is unrelated of this issue.

I don't have much experience with node build systems, so it's possible that I'm doing something wrong.

becseya avatar Jan 11 '23 22:01 becseya

@becseya Thanks for the checks and useful feedback. I had a suspicion that this change might be problematic, but didn't have a good project to test it in. I think I'll separate out an nmea-simple-module package to address #18 so current users aren't affected by this.

101100 avatar Jan 11 '23 23:01 101100

Some more fixes in https://github.com/101100/nmea-simple/pull/25 to help with ESM. At the very least, we need dist/index.js to be marked as using modules. The two approaches are:

  1. rename it to index.mjs
  2. set package.json#type: "module" (either in the top level package.json or in some dist/package.json).

I went with the second since I think it's the cleanest.

Instead of releasing a second package, you can make import, require use different entry points.

rotu avatar Oct 19 '23 19:10 rotu