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

Q: How to use this ESM-only package? #97

Closed
marekdedic opened this issue Sep 4, 2023 · 2 comments
Closed

Q: How to use this ESM-only package? #97

marekdedic opened this issue Sep 4, 2023 · 2 comments

Comments

@marekdedic
Copy link

Hi,
I am trying to upgrade to v8, however, I am at a loss as to how to use this package... I have read the linked gist and I am on node 20, so I think I have all the prerequisites ready... However, given that this is a gulp plugin, I am a bit lost when it comes to the state of ESM in gulpfiles...

  1. If I keep const filter = require("gulp-filter");, I get Error [ERR_REQUIRE_ESM]: require() of ES Module...
  2. If I switch it to const filter = await import("gulp-filter");, I get SyntaxError: await is only valid in async functions and the top level bodies of modules
  3. If I switch to import filter from "gulp-filter";, I get SyntaxError: Cannot use import statement outside a module. This happens even when I convert all import to this style...

So it seems to me like gulpfiles cannot use ESM? If that's the case, does that mean v8 is unusable without a preprocessor like ts-node?

@sindresorhus
Copy link
Owner

This has nothing to do with this package specifically. This package has the correct ESM config.

https://gist.github.com/noraj/007a943dc781dc8dd3198a29205bae04

@sindresorhus sindresorhus closed this as not planned Won't fix, can't repro, duplicate, stale Sep 4, 2023
@marekdedic
Copy link
Author

Great, that doc is exactly what I needed, thanks!

I suggest maybe adding a link to it to the v8 release? I think it applies here maybe more than the one linked currently...

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

No branches or pull requests

2 participants