Skip to content

Commit 0f19817

Browse files
authored
Bundle forked sass npm package with pure js embedded compiler support (#336)
sass/dart-sass#2413
1 parent 81ac007 commit 0f19817

File tree

5 files changed

+68
-9
lines changed

5 files changed

+68
-9
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# TODO: remove after https://github.com/sass/dart-sass/pull/2413
2+
name: Build dart-sass
3+
description: Build dart-sass from source with patch from https://github.com/sass/dart-sass/pull/2413
4+
runs:
5+
using: composite
6+
steps:
7+
- uses: bufbuild/[email protected]
8+
with:
9+
github_token: ${{ github.token }}
10+
11+
- uses: dart-lang/setup-dart@v1
12+
13+
- uses: actions/setup-node@v6
14+
15+
- id: version
16+
run: node -e 'console.log(`version=${JSON.parse(fs.readFileSync("ext/sass/package.json"))["dependencies"]["sass"]}`)' | tee -a "$GITHUB_OUTPUT"
17+
shell: bash
18+
19+
- uses: actions/checkout@v5
20+
with:
21+
repository: sass/dart-sass
22+
ref: ${{ steps.version.outputs.version }}
23+
path: dart-sass
24+
25+
- run: curl -fsSL -- https://github.com/sass/dart-sass/pull/2413.diff | git apply -
26+
working-directory: dart-sass
27+
shell: bash
28+
29+
- run: dart pub get
30+
working-directory: dart-sass
31+
shell: bash
32+
33+
- run: dart run grinder protobuf pkg-npm-release
34+
working-directory: dart-sass
35+
shell: bash
36+
37+
- run: npm pack
38+
working-directory: dart-sass/build/npm
39+
shell: bash
40+
41+
- run: mv dart-sass/build/npm/sass-${{ steps.version.outputs.version }}.tgz ext/sass
42+
shell: bash
43+
44+
- run: npm install sass@file:sass-${{ steps.version.outputs.version }}.tgz
45+
working-directory: ext/sass
46+
shell: bash
47+
48+
- run: git add ext/sass/sass-${{ steps.version.outputs.version }}.tgz ext/sass/package.json
49+
shell: bash
50+
51+
- run: git clean -dffx
52+
shell: bash
53+
54+
- run: git diff HEAD
55+
shell: bash

.github/workflows/build.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,17 +138,16 @@ jobs:
138138
run: |
139139
pkg_add node protobuf ruby%3.4 ruby-shims
140140
echo 3.4 | tee /etc/ruby-version
141-
- os: ubuntu-latest
142-
vm:
143-
os: omnios
144-
run: |
145-
pkg install build-essential node-22 protobuf ruby-34
146-
pkg install "$(pkg search -HI -o pkg.name "$(ruby -e 'puts RbConfig::CONFIG["CC"]')")"
147141
148142
steps:
149143
- name: Checkout
150144
uses: actions/checkout@v5
151145

146+
# TODO: remove after https://github.com/sass/dart-sass/pull/2413
147+
- name: Build dart-sass
148+
if: matrix.vm
149+
uses: ./.github/actions/build-dart-sass
150+
152151
- name: Initialize vm
153152
if: matrix.vm
154153
timeout-minutes: 10
@@ -195,7 +194,6 @@ jobs:
195194
GH_TOKEN: ${{ github.token }}
196195

197196
- name: Spec
198-
if: "!matrix.vm || contains(matrix.vm.run, 'linux_base') || contains(matrix.vm.run, '/proc')" # TODO: remove after https://github.com/sass/dart-sass/pull/2413
199197
run: bundle exec rake spec
200198

201199
- name: Install

.github/workflows/release.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ jobs:
6666
rubygems: latest
6767
bundler-cache: true
6868

69+
# TODO: remove after https://github.com/sass/dart-sass/pull/2413
70+
- name: Build dart-sass
71+
if: matrix.platform == 'ruby'
72+
uses: ./.github/actions/build-dart-sass
73+
6974
- name: Compile
7075
run: bundle exec rake compile ext_platform=${{ matrix.platform }}
7176
env:

ext/sass/Rakefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,8 @@ module SassConfig
488488

489489
def dart_sass_version
490490
package_json['dependencies']['sass']
491+
# TODO: remove after https://github.com/sass/dart-sass/pull/2413
492+
.delete_prefix('file:sass-').delete_suffix('.tgz')
491493
end
492494

493495
def dart_sass
@@ -606,8 +608,6 @@ module SassConfig
606608
tag_name = JSON.parse(version)['protocolVersion']
607609

608610
"https://github.com/sass/sass/raw/embedded-protocol-#{tag_name}/spec/embedded_sass.proto"
609-
rescue StandardError # TODO: remove after https://github.com/sass/dart-sass/pull/2413
610-
'https://github.com/sass/sass/raw/HEAD/spec/embedded_sass.proto'
611611
end
612612

613613
def development?

sass-embedded.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Gem::Specification.new do |spec|
2626

2727
if spec.platform == Gem::Platform::RUBY
2828
spec.extensions = ['ext/sass/Rakefile']
29+
spec.files += Dir['ext/sass/sass-*.tgz'] # TODO: remove after https://github.com/sass/dart-sass/pull/2413
2930
spec.files += [
3031
'ext/sass/Rakefile',
3132
'ext/sass/package.json'

0 commit comments

Comments
 (0)