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

Parcel 2: @parcel/register node require hook #2396

Open
devongovett opened this issue Dec 11, 2018 · 5 comments
Open

Parcel 2: @parcel/register node require hook #2396

devongovett opened this issue Dec 11, 2018 · 5 comments

Comments

@devongovett
Copy link
Member

devongovett commented Dec 11, 2018

The idea here is to enable Parcel transformers and resolvers to be run in other places than just bundling via a package similar to babel-register or other require hooks in node. This way, you could run the same Parcel transformers that you run when bundling your app in your tests, which might run in node.

Currently it is very challenging to set up a real world app, even with Parcel, because you are still stuck configuring other tools like mocha, jest, babel, and others for your tests, not even your real app. If you could get the same zero configuration experience just by loading @parcel/require in node, that would be pretty great.

There are a bunch of Parcel features that would be great to be able to use in tests:

  1. The source and alias fields in package.json. No manually configuring babel-register to include certain node_modules. Using the Parcel resolver, this would be possible.
  2. Real Parcel transformers, no extra configuration. Normal babel-register might not be enough if you are using other compilers. We could even automatically handle things like CSS imports that won't work in node.
  3. Take advantage of Parcel's cache for faster test runs - no need to recompile every time.

@parcel/register would only run the Parcel transformer pipeline, not any packagers or actual bundling. It would operate on a per-file level, and hook into the node module system to compile and resolve modules.

@pspeter3
Copy link

Is this available? For example, if you're using Jest, is it possible to use Parcel to transform the TypeScript?

@pete55104
Copy link

pete55104 commented Feb 5, 2022

This seems important, and I'm interested as well. In the process of converting a CRA react and node backend, and got as far as trying to run my Jest tests through parcel and ended up here.
I'm interested in working on this feature, although I'd need some guidance. Let me see if I can get the existing @swc/Jest + babel tooling to work as a model.

How do I tell which version of swc a given parcel version is using? I'm on 2.2.1.

@devongovett
Copy link
Member Author

I had started on it here. Haven't had time to work on it recently. Feel free to take a look if you want! https://github.com/parcel-bundler/parcel/compare/parcel-node

@jteppinette
Copy link

jteppinette commented Jan 5, 2023

Without this, should there be a disclaimer that parcel doesn't support unit testing? One of the key features of parcel is the transformer pipeline, which is unsupported.

@andymac4182
Copy link

andymac4182 commented Feb 4, 2024

@devongovett Any movement on this from you? Thoughts on starting with getting the new transform and resolve functions you have added to Parcel?

I can see the @parcel/register package that is available now. Curious if I am missing a jest one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants