Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@jsepia
Copy link
Contributor

@jsepia jsepia commented Jun 27, 2023

Overview

This change allows consumers to import reurl using either import or require.

I added support for require because I want to use reurl in a legacy project that does not support ESM imports.

Feel free to take or leave this change. It does add more complexity and maintenance overhead so I completely understand if you'd rather keep reurl ESM-only. People can always make forks.

Testing this change

  1. Clone my test repo:
git clone https://github.com/jsepia/reurl-test.git

The test repo contains two files:

  • test.js imports reurl using the import syntax
  • test.cjs imports reurl using require
  1. Run the test scripts:
# node v12
$ nvm use v12
Now using node v12.22.12 (npm v6.14.16)
$ npm run test:esm

> [email protected] test:esm /path/to/reurl-test2
> node --experimental-modules test.js

[class Url]
[class RawUrl extends Url]
$ npm run test:commonjs

> [email protected] test:commonjs /path/to/reurl-test2
> node test.cjs

{ RawUrl: [Getter], Url: [Getter], version: [Getter] }
[class _Url]
[class RawUrl extends _Url]

jsepia added 2 commits June 24, 2023 18:16
This allows consumers to import reurl from CommonJS projects using the require() syntax.
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.

2 participants