ip-address
ip-address copied to clipboard
Support for ECMAScript Modules
This implements the changes discussed in #153. Feel free to accept or to use this PR as a starting point for your own work.
This adds support to import this package from ECMAScript Modules. The changes are fairly broad since some non-compliant tooling and experimental features were relied on.
- Add
"type": "module"
to top-level package.json. Remove nested package.json generation. See: https://nodejs.org/api/packages.html#dual-commonjses-module-packages - Add file extensions to relative file imports. This also updates the eslint configuration to enforce the practice. See: https://nodejs.org/api/packages.html#extensions-in-subpaths
- Remove
source-map-support
since this was now failing to load, and nodejs has supported--enable-source-maps
since v12. - Remove
ts-node
since this module has lousy module support [https://github.com/TypeStrong/ts-node/issues/935 and https://github.com/TypeStrong/ts-node/issues/1007]. This was only used for testing, so instead tests are run from the transpiled .js files created by TypeScript. .npmignore has been updated to ignore these files. - Add JSON import assertions to import test files. JSON import has been an experimental nodejs feature but ts-node was letting the imports work against specification. These imports now require an import assertion, which has been added. This required a TypeScript version bump, and now the tests can only run under nodejs v18. The Travis-CI configuration has been updated with this in mind. There are workarounds to get this running under older versions of nodejs but I don't think it's worth the engineering time.