Skip to content

Support pure JS sass executable #344

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

ntkme
Copy link
Contributor

@ntkme ntkme commented Oct 26, 2024

sass/dart-sass#2413

This PR changes how compiler is setup for local development. Instead of symlink the compiler into a special vendor directory:

  • Dart: link build/dart-sass/build -> node_modules/sass-embedded-${platform}-${arch}/dart-sass.
  • Pure JS: link build/dart-sass/build/npm -> node_modules/sass.

Only one kind of compiler will be installed by init.ts, that the other kind will be removed if exists.

In the compiler-path.ts, loading the compiler is attempted in the order of:

  • dart runtime + snapshot for release (bypassing the script for slightly better performance)
  • dart sass wrapper script for local development
  • node + sass.js for platforms without dart support

@ntkme ntkme force-pushed the embedded-compiler branch from 9683817 to 2b23fac Compare October 26, 2024 02:34
@ntkme ntkme marked this pull request as ready for review October 26, 2024 02:50
@ntkme ntkme marked this pull request as draft October 26, 2024 03:40
@ntkme ntkme force-pushed the embedded-compiler branch 2 times, most recently from a57567f to ec05f2d Compare October 26, 2024 17:16
@ntkme ntkme closed this Oct 28, 2024
@ntkme ntkme deleted the embedded-compiler branch October 28, 2024 00:27
@ntkme ntkme restored the embedded-compiler branch October 28, 2024 03:43
@ntkme ntkme reopened this Oct 28, 2024
@ntkme ntkme force-pushed the embedded-compiler branch from ec05f2d to 75f77ee Compare October 28, 2024 03:45
@ntkme ntkme marked this pull request as ready for review October 28, 2024 03:46
@ntkme ntkme force-pushed the embedded-compiler branch 4 times, most recently from 5d51360 to b2dfcb2 Compare October 28, 2024 21:40
@ntkme ntkme force-pushed the embedded-compiler branch 12 times, most recently from d233142 to dd17ebb Compare November 2, 2024 03:54
@ntkme ntkme force-pushed the embedded-compiler branch from 7334197 to c1ad745 Compare December 12, 2024 23:00
@ntkme ntkme force-pushed the embedded-compiler branch from c1ad745 to c5827d5 Compare January 6, 2025 17:53
@ntkme ntkme force-pushed the embedded-compiler branch from c5827d5 to 3f07e60 Compare January 14, 2025 16:35
@ntkme ntkme changed the title Implement sass --embedded in pure JS mode Support pure JS sass executable Jan 14, 2025
@ntkme ntkme force-pushed the embedded-compiler branch from 3f07e60 to fa0b0af Compare January 24, 2025 20:30
@ntkme ntkme force-pushed the embedded-compiler branch from 3744f85 to 76097f0 Compare February 3, 2025 19:29
@ntkme ntkme force-pushed the embedded-compiler branch 2 times, most recently from bdcf7c9 to ffb708b Compare February 14, 2025 18:03
@ntkme ntkme force-pushed the embedded-compiler branch 2 times, most recently from e7fa973 to d38f850 Compare February 27, 2025 23:36
@ntkme ntkme force-pushed the embedded-compiler branch from d38f850 to 8bcb141 Compare March 18, 2025 16:03
@ntkme ntkme force-pushed the embedded-compiler branch 3 times, most recently from 6e8a3c8 to 4848227 Compare April 7, 2025 22:34
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason to split this into a different module is that compiler-path contains IIFE that may throw on load, but in tool scripts, we need to know the compiler-module name to setup dev environment without throwing. Therefore it's moved to a separate file.

@ntkme ntkme force-pushed the embedded-compiler branch 2 times, most recently from c9c3970 to 8176dad Compare May 13, 2025 22:03
@ntkme ntkme force-pushed the embedded-compiler branch 2 times, most recently from e2bae73 to 68738e7 Compare May 21, 2025 20:42
@ntkme ntkme force-pushed the embedded-compiler branch from 68738e7 to 7bb703b Compare June 9, 2025 20:57
@ntkme ntkme force-pushed the embedded-compiler branch from 7bb703b to 1c2638b Compare July 16, 2025 20:09
@ntkme
Copy link
Contributor Author

ntkme commented Jul 16, 2025

Because this PR assumes that the dartvm and dart2js sass-compiler will behave exactly same from an external viewpoint, this PR only run test the against dartvm in the CI. The dart2js based CI test is configured in the dart-sass repo itself.

Therefore, this PR has no dependency on dart-sass side of PR, and can be merged independently. - I would like to have this PR merged first, so that I don't have to keep resolving merge conflict every time the version number is bumped.

Of course, if we merge this PR first before merging the dart-sass PR, the API mode won't work. However, at least it allows users to run npm exe sass-embedded consistently on all platforms without native dart support.

@nex3 With the above said, it would be nice if you can take a look and merge this, even if we don't merge dart-sass PR right away.

Copy link
Contributor

@nex3 nex3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm on board to land this first.

However, at least it allows users to run npm exe sass-embedded consistently on all platforms without native dart support.

I don't completely understand this. It looks like this PR only affects local development. How will it affect what users can do at all?

@ntkme
Copy link
Contributor Author

ntkme commented Jul 16, 2025

However, at least it allows users to run npm exe sass-embedded consistently on all platforms without native dart support.

I don't completely understand this. It looks like this PR only affects local development. How will it affect what users can do at all?

Today if you run npm exe sass-embedded it starts the wrapper script which effectively runs the native dart-sass command line, providing the same end-user experience as npm exe sass. However, before this PR on unsupported native platform (e.g. FreeBSD), this will simply fail due to the wrapper won't be able to find a native sass binary. After this PR, the wrapper will fallback to the dart2js version of sass binary as last resort, so that the command will work consistently.

@ntkme ntkme force-pushed the embedded-compiler branch from 9657871 to b82d3bb Compare July 16, 2025 22:39
@ntkme ntkme force-pushed the embedded-compiler branch from b82d3bb to 6dd7037 Compare July 16, 2025 22:47
@ntkme
Copy link
Contributor Author

ntkme commented Jul 16, 2025

Code review feedbacks have been applied.

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
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy