Skip to content

Commit 7937793

Browse files
authored
Merge remote-tracking branch 'origin/main' into feature.color-4
2 parents d283b3c + 435a181 commit 7937793

24 files changed

+470
-436
lines changed

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "npm"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"

.github/workflows/ci.yml

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -75,20 +75,18 @@ jobs:
7575
uses: sass/clone-linked-repo@v1
7676
with: {repo: sass/embedded-protocol, default-ref: null}
7777

78-
- name: Check out the embedded compiler
78+
- name: Check out Dart Sass
7979
uses: sass/clone-linked-repo@v1
80-
with: {repo: sass/dart-sass-embedded, default-ref: null}
80+
with: {repo: sass/dart-sass}
8181

82-
- name: Check out Dart Sass
82+
- name: Check out the embedded compiler
8383
uses: sass/clone-linked-repo@v1
84-
with: {repo: sass/dart-sass, default-ref: null}
84+
with: {repo: sass/dart-sass-embedded}
8585

8686
- name: Link the embedded compiler to Dart Sass
8787
run: |
88-
if [[ -d dart-sass ]]; then
89-
yq -i '.dependency_overrides.sass = {"path": "../dart-sass"}' \
90-
dart-sass-embedded/pubspec.yaml
91-
fi
88+
yq -i '.dependency_overrides.sass = {"path": "../dart-sass"}' \
89+
dart-sass-embedded/pubspec.yaml
9290
9391
- name: Check out the JS API definition
9492
uses: sass/clone-linked-repo@v1
@@ -98,8 +96,7 @@ jobs:
9896
- name: npm run init
9997
run: |
10098
if [[ -d embedded-protocol ]]; then args=--protocol-path=embedded-protocol; fi
101-
if [[ -d dart-sass-embedded ]]; then args="$args --compiler-path=dart-sass-embedded"; fi
102-
npm run init -- --api-path=language $args
99+
npm run init -- --compiler-path=dart-sass-embedded --api-path=language $args
103100
104101
- run: npm run test
105102

@@ -139,20 +136,18 @@ jobs:
139136
uses: sass/clone-linked-repo@v1
140137
with: {repo: sass/embedded-protocol, default-ref: null}
141138

142-
- name: Check out the embedded compiler
139+
- name: Check out Dart Sass
143140
uses: sass/clone-linked-repo@v1
144-
with: {repo: sass/dart-sass-embedded, default-ref: null}
141+
with: {repo: sass/dart-sass}
145142

146-
- name: Check out Dart Sass
143+
- name: Check out the embedded compiler
147144
uses: sass/clone-linked-repo@v1
148-
with: {repo: sass/dart-sass, default-ref: null}
145+
with: {repo: sass/dart-sass-embedded}
149146

150147
- name: Link the embedded compiler to Dart Sass
151148
run: |
152-
if [[ -d dart-sass ]]; then
153-
yq -i '.dependency_overrides.sass = {"path": "../dart-sass"}' \
154-
dart-sass-embedded/pubspec.yaml
155-
fi
149+
yq -i '.dependency_overrides.sass = {"path": "../dart-sass"}' \
150+
dart-sass-embedded/pubspec.yaml
156151
157152
- name: Check out the JS API definition
158153
uses: sass/clone-linked-repo@v1
@@ -162,8 +157,7 @@ jobs:
162157
- name: npm run init
163158
run: |
164159
if [[ -d embedded-protocol ]]; then args=--protocol-path=embedded-protocol; fi
165-
if [[ -d dart-sass-embedded ]]; then args="$args --compiler-path=dart-sass-embedded"; fi
166-
npm run init -- --api-path=language $args
160+
npm run init -- --compiler-path=dart-sass-embedded --api-path=language $args
167161
168162
- name: Check out sass-spec
169163
uses: sass/clone-linked-repo@v1

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
## 1.57.1
2+
3+
* No user-visible changes.
4+
5+
## 1.57.0
6+
7+
* Add a `split($string, $separator, $limit: null)` function to `sass:string`
8+
that splits a string into separate substrings based on a separator string.
9+
10+
### JavaScript API
11+
12+
* **Potentially breaking bug fix**: Custom functions in both the modern and
13+
legacy API now properly reject signatures with whitespace between the function
14+
name and parentheses.
15+
16+
* Custom functions in the legacy API now allow signatures with whitespace before
17+
the function name, to match a bug in Node Sass.
18+
19+
### Dart API
20+
21+
* **Potentially breaking bug fix**: `Callable.fromSignature()` and
22+
`AsyncCallable.fromSignature()` now reject signatures with whitespace between
23+
the function name and parentheses.
24+
125
## 1.56.2
226

327
### Embedded Sass

CONTRIBUTING.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,74 @@ such, manual commits should never:
3535

3636
* Update the `package.json`'s `"compiler-version"` field to a non-`-dev` number.
3737
Changing it from non-`-dev` to dev when using a new feature is fine.
38+
39+
# Keeping in Sync With Other Packages
40+
41+
The embedded host depends on several different components which come from
42+
different repositories:
43+
44+
* The [Dart Sass embedded compiler].
45+
* [Dart Sass] (transitively through the embedded compiler).
46+
* The [Sass embedded protocol].
47+
* The [Sass JS API definition].
48+
49+
[Dart Sass embedded compiler]: https://github.com/sass/dart-sass-embedded
50+
[Dart Sass]: https://github.com/sass/dart-sass
51+
[Sass embedded protocol]: https://github.com/sass/embedded-protocol
52+
[JS API definition]: https://github.com/sass/sass/tree/main/spec/js-api
53+
54+
These dependencies are made available in different ways depending on context.
55+
56+
## Local Development
57+
58+
When developing locally, you can download all of these dependencies by running
59+
`npm run init`. This provides the following options for `compiler` (for the
60+
embedded compiler), `protocol` (for the embedded protocol), and `api` (for the
61+
JS API):
62+
63+
* `--<type>-path`: The local filesystem path of the package to use. This is
64+
useful when doing local development on both the host and its dependencies at
65+
the same time.
66+
67+
* `--<type>-ref`: A Git reference for the GitHub repository of the package to
68+
clone.
69+
70+
By default:
71+
72+
* This uses the version of the embedded protocol and compiler specified by
73+
`protocol-version` in `package.json`, *unless* that version ends in `-dev` in
74+
which case it checks out the latest revision on GitHub.
75+
76+
* This uses the embedded compiler version and JS API definition from the latest
77+
revision on GitHub.
78+
79+
* This uses the Dart Sass version from the latest revision on GitHub, unless the
80+
embedded `--compiler-path` was passed in which case it uses whatever version
81+
of Dart Sass that package references.
82+
83+
## Continuous Integration
84+
85+
CI tests also use `npm run init`, so they use the same defaults as local
86+
development. However, if the pull request description includes a link to a pull
87+
request for the embedded compiler, Dart Sass, the embedded protocol, or the JS
88+
API, this will check out that version and run tests against it instead.
89+
90+
## Release
91+
92+
When this package is released to npm, it downloads the embedded protocol version
93+
that matches `protocol-version` in `package.json`. It downloads the latest JS
94+
API revision on GitHub.
95+
96+
The release version of the `sass-embedded` package does *not* include the
97+
embedded compiler or Dart Sass. Instead, we release optional packages of the
98+
form `sass-embedded-<os>-<arch>`. Each of these contains the published version
99+
of the embedded compiler that matches `compiler-version` in `package.json` for
100+
the given operating system/architecture combination.
101+
102+
If either `protocol-version` or `compiler-version` ends with `-dev`, the release
103+
will fail.
104+
105+
**Note:** As part of the holistic release process for Dart Sass, the embedded
106+
compiler's CI will automatically update this repository's `package.json` file
107+
with the latest `compiler-version` and optional dependency versions before
108+
tagging it for a release.

lib/src/compile.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ async function compileRequestAsync(
153153
): Promise<CompileResult> {
154154
const functions = new FunctionRegistry(options?.functions);
155155
const embeddedCompiler = new AsyncEmbeddedCompiler();
156+
embeddedCompiler.stderr$.subscribe(data => process.stderr.write(data));
156157

157158
try {
158159
const dispatcher = createDispatcher<'async'>(
@@ -198,6 +199,7 @@ function compileRequestSync(
198199
): CompileResult {
199200
const functions = new FunctionRegistry(options?.functions);
200201
const embeddedCompiler = new SyncEmbeddedCompiler();
202+
embeddedCompiler.stderr$.subscribe(data => process.stderr.write(data));
201203

202204
try {
203205
const dispatcher = createDispatcher<'sync'>(

lib/src/compiler-path.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,6 @@ import {isErrnoException} from './utils';
88

99
/** The path to the embedded compiler executable. */
1010
export const compilerPath = (() => {
11-
try {
12-
return require.resolve(
13-
`sass-embedded-${process.platform}-${process.arch}/` +
14-
'dart-sass-embedded/dart-sass-embedded' +
15-
(process.platform === 'win32' ? '.bat' : '')
16-
);
17-
} catch (e: unknown) {
18-
if (!(isErrnoException(e) && e.code === 'MODULE_NOT_FOUND')) {
19-
throw e;
20-
}
21-
}
22-
2311
// find for development
2412
for (const path of ['vendor', '../../../lib/src/vendor']) {
2513
const executable = p.resolve(
@@ -33,6 +21,18 @@ export const compilerPath = (() => {
3321
if (fs.existsSync(executable)) return executable;
3422
}
3523

24+
try {
25+
return require.resolve(
26+
`sass-embedded-${process.platform}-${process.arch}/` +
27+
'dart-sass-embedded/dart-sass-embedded' +
28+
(process.platform === 'win32' ? '.bat' : '')
29+
);
30+
} catch (e: unknown) {
31+
if (!(isErrnoException(e) && e.code === 'MODULE_NOT_FOUND')) {
32+
throw e;
33+
}
34+
}
35+
3636
throw new Error(
3737
"Embedded Dart Sass couldn't find the embedded compiler executable. " +
3838
'Please make sure the optional dependency ' +

lib/src/legacy/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ function convertOptions<sync extends 'sync' | 'async'>(
131131
// does not.
132132
if (!signature.includes('(')) signature += '()';
133133

134-
functions[signature] = wrapFunction(self, callback, sync);
134+
functions[signature.trimLeft()] = wrapFunction(self, callback, sync);
135135
}
136136

137137
const importers =

lib/src/sync-compiler.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ export class SyncEmbeddedCompiler {
2121
/** The buffers emitted by the child process's stderr. */
2222
readonly stderr$ = new Subject<Buffer>();
2323

24+
/** Whether the underlying compiler has already exited. */
25+
private exited = false;
26+
2427
/** Writes `buffer` to the child process's stdin. */
2528
writeStdin(buffer: Buffer): void {
2629
this.process.stdin.write(buffer);
@@ -38,14 +41,15 @@ export class SyncEmbeddedCompiler {
3841
return true;
3942

4043
case 'exit':
44+
this.exited = true;
4145
return false;
4246
}
4347
}
4448

4549
/** Blocks until the underlying process exits. */
4650
yieldUntilExit(): void {
47-
while (this.yield()) {
48-
// Any events will be handled by `this.yield()`.
51+
while (!this.exited) {
52+
this.yield();
4953
}
5054
}
5155

npm/darwin-arm64/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sass-embedded-darwin-arm64",
3-
"version": "1.56.2",
3+
"version": "1.57.1",
44
"description": "The darwin-arm64 binary for sass-embedded",
55
"repository": "sass/embedded-host-node",
66
"author": "Google Inc.",

npm/darwin-x64/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sass-embedded-darwin-x64",
3-
"version": "1.56.2",
3+
"version": "1.57.1",
44
"description": "The darwin-x64 binary for sass-embedded",
55
"repository": "sass/embedded-host-node",
66
"author": "Google Inc.",

0 commit comments

Comments
 (0)