Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Neutral JavaScript runtime support (Deno, Bun, etc) #580

Closed
sgammon opened this issue Mar 31, 2024 · 0 comments
Closed

Neutral JavaScript runtime support (Deno, Bun, etc) #580

sgammon opened this issue Mar 31, 2024 · 0 comments

Comments

@sgammon
Copy link
Contributor

sgammon commented Mar 31, 2024

Hello there, @isaacs!

I'm a big fan of node-glob, having used it in several projects now. It is super fast and generally just works great 😄 however, in a tool downstream, hashlock, I am trying to make it runtime-neutral, so that consuming users can use it on whatever runtime they want (Deno, Bun, Node, are my targets).

glob already works fantastically well on Node and Bun, but Deno seems to hiccup, because it wants node:-prefixed imports for builtins. Not shipping with these was quite sensible. Now that Node 16 is EOL, though, there really should be very few Node instances out in the wild that are running pre-16 versions, so node:-prefixed imports can be relied upon.

Using these imports works universally across Node, Bun, and Deno, and so for a very small change glob can be used anywhere. See below for the diff that I generated with patch-package, and a PR is incoming shortly.

Note

For glob to be fully compatible with Deno, changes are needed path-scurry and minipass as well. Those PRs and issues will tag this one for easy reference.

Related issues:

diff --git a/node_modules/glob/dist/commonjs/glob.js b/node_modules/glob/dist/commonjs/glob.js
index 5e37335..f961ccc 100644
--- a/node_modules/glob/dist/commonjs/glob.js
+++ b/node_modules/glob/dist/commonjs/glob.js
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
 exports.Glob = void 0;
 const minimatch_1 = require("minimatch");
 const path_scurry_1 = require("path-scurry");
-const url_1 = require("url");
+const url_1 = require("node:url");
 const pattern_js_1 = require("./pattern.js");
 const walker_js_1 = require("./walker.js");
 // if no process global, just call it linux.
diff --git a/node_modules/glob/dist/esm/glob.js b/node_modules/glob/dist/esm/glob.js
index 2a2b15d..da56f87 100644
--- a/node_modules/glob/dist/esm/glob.js
+++ b/node_modules/glob/dist/esm/glob.js
@@ -1,6 +1,6 @@
 import { Minimatch } from 'minimatch';
 import { PathScurry, PathScurryDarwin, PathScurryPosix, PathScurryWin32, } from 'path-scurry';
-import { fileURLToPath } from 'url';
+import { fileURLToPath } from 'node:url';
 import { Pattern } from './pattern.js';
 import { GlobStream, GlobWalker } from './walker.js';
 // if no process global, just call it linux.

This issue body was partially generated by patch-package.

sgammon added a commit to sgammon/minipass that referenced this issue Mar 31, 2024
This adjusts Node built-in imports to use the `node:` prefix, so
that such imports work on all runtimes.

Fixes and closes isaacs#54
Relates to isaacs/node-glob#580 and isaacs/path-scurry#16

Signed-off-by: Sam Gammon <[email protected]>
sgammon added a commit to sgammon/path-scurry that referenced this issue Mar 31, 2024
This changeset fixes and closes isaacs#16 so that this
package can be used on all JS runtimes.

Relates to isaacs/node-glob#580

Signed-off-by: Sam Gammon <[email protected]>
sgammon added a commit to sgammon/node-glob that referenced this issue Mar 31, 2024
Fixes and closes isaacs#580 by switching to `node:`-
prefixed requires for Node API builtins.

Will need releases for `minipass` and `path-scurry`, PRs for these
are noted below.

Relates to:
- isaacs/path-scurry#17
- isaacs/minipass#55

Signed-off-by: Sam Gammon <[email protected]>
sgammon added a commit to sgammon/hashlock that referenced this issue Mar 31, 2024
- feat: support all popular js runtimes
  - patches for `glob`, `minipass`, and `path-scurry`
  - upstream prs (listed below)
  - test entrypoint commands
- test: add test entrypoints for each major runtime
- test: add scripts to test entrypoint with each major runtime
- chore: sync lockfiles

Related Issues
- isaacs/node-glob#580
- isaacs/path-scurry#16
- isaacs/minipass#54
- tj/commander.js#2169

Upstream PRs
- isaacs/node-glob#581
- isaacs/minipass#55
- isaacs/path-scurry#17
- tj/commander.js#2170

Signed-off-by: Sam Gammon <[email protected]>
sgammon added a commit to sgammon/hashlock that referenced this issue Mar 31, 2024
- feat: support all popular js runtimes
  - patches for `glob`, `minipass`, and `path-scurry`
  - upstream prs (listed below)
  - test entrypoint commands
- test: add test entrypoints for each major runtime
- test: add scripts to test entrypoint with each major runtime
- chore: sync lockfiles

Related Issues
- isaacs/node-glob#580
- isaacs/path-scurry#16
- isaacs/minipass#54
- tj/commander.js#2169

Upstream PRs
- isaacs/node-glob#581
- isaacs/minipass#55
- isaacs/path-scurry#17
- tj/commander.js#2170

Signed-off-by: Sam Gammon <[email protected]>
sgammon added a commit to sgammon/hashlock that referenced this issue Mar 31, 2024
- feat: support all popular js runtimes
  - patches for `glob`, `minipass`, and `path-scurry`
  - upstream prs (listed below)
  - test entrypoint commands
- test: add test entrypoints for each major runtime
- test: add scripts to test entrypoint with each major runtime
- chore: sync lockfiles

Related Issues
- isaacs/node-glob#580
- isaacs/path-scurry#16
- isaacs/minipass#54
- tj/commander.js#2169

Upstream PRs
- isaacs/node-glob#581
- isaacs/minipass#55
- isaacs/path-scurry#17
- tj/commander.js#2170

Signed-off-by: Sam Gammon <[email protected]>
sgammon added a commit to sgammon/hashlock that referenced this issue Mar 31, 2024
* feat: support all runtimes

- feat: support all popular js runtimes
  - patches for `glob`, `minipass`, and `path-scurry`
  - upstream prs (listed below)
  - test entrypoint commands
- test: add test entrypoints for each major runtime
- test: add scripts to test entrypoint with each major runtime
- chore: sync lockfiles

Related Issues
- isaacs/node-glob#580
- isaacs/path-scurry#16
- isaacs/minipass#54
- tj/commander.js#2169

Upstream PRs
- isaacs/node-glob#581
- isaacs/minipass#55
- isaacs/path-scurry#17
- tj/commander.js#2170

Signed-off-by: Sam Gammon <[email protected]>

* chore: version bump → `1.0.3`

Signed-off-by: Sam Gammon <[email protected]>

---------

Signed-off-by: Sam Gammon <[email protected]>
Signed-off-by: Sam Gammon <[email protected]>
isaacs pushed a commit to isaacs/path-scurry that referenced this issue May 9, 2024
This changeset fixes and closes #16 so that this
package can be used on all JS runtimes.

Relates to isaacs/node-glob#580

Signed-off-by: Sam Gammon <[email protected]>

PR-URL: #17
Credit: @sgammon
Close: #17
Reviewed-by: @isaacs
isaacs pushed a commit to isaacs/minipass that referenced this issue May 9, 2024
This adjusts Node built-in imports to use the `node:` prefix, so
that such imports work on all runtimes.

Fixes and closes #54
Relates to isaacs/node-glob#580 and isaacs/path-scurry#16

Signed-off-by: Sam Gammon <[email protected]>

PR-URL: #55
Credit: @sgammon
Close: #55
Reviewed-by: @isaacs
@isaacs isaacs closed this as completed in 435d1f7 May 9, 2024
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 a pull request may close this issue.

1 participant