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

look for .node files in sibling directory. #428

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nicksrandall
Copy link
Contributor

@nicksrandall nicksrandall commented Feb 15, 2023

I use Lightningcss with esbuild and the "approved" way to import .node files with esbuild is to use the "copy" loader, which copies the .node file into the destination folder. Now the script that requires the .node file is a sibling of the .node file instead of a child.

@devongovett
Copy link
Member

What is the reason for this?

@nicksrandall
Copy link
Contributor Author

@nicksrandall added info into the description.

@devongovett
Copy link
Member

So you are bundling lightningcss itself with esbuild? That's an interesting use case... When you install it from npm, there will be a platform-specific package installed as well, e.g. lightningcss-linux-x64-gnu. So the relative paths here should only really be used for local development of lightningcss itself. When bundling with esbuild, wouldn't the .node file actually be coming from the platform-specific package, and not the main lightningcss package?

@nicksrandall
Copy link
Contributor Author

Yeah, I have an HTTP service (specifically an AWS lamba fn) that generates css files and we use Lightningcss to post-process the files before we deliver.

To work around this, I could also include my "node-modules" folder with the deployed service which would allow the first condition here to work.

However, I was hoping to avoid having to ship my node_modules folder (which is heavy) or coming up with logic to conditionally include certain folders (which is a challenge when tracking nested dependencies). Allowing esbuild to just do its thing and only having to copy over my built files has made our deployment process very easy/simple.

@nicksrandall
Copy link
Contributor Author

So yes, the node file that is actually copied does come from the platform specific package. This fallback logic allows the service to find the copied node file when shipped as a single bundle without node-modules folder. Does that make sense?

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.

None yet

2 participants