Skip to content

Commit f1f7efa

Browse files
Merge branch 'next' into feat/remove-render-script-option
2 parents aacc989 + ac52387 commit f1f7efa

File tree

8 files changed

+9
-25
lines changed

8 files changed

+9
-25
lines changed

.changeset/silver-deers-buy.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@astrojs/compiler": major
3+
---
4+
5+
Removes `experimentalScriptOrder` from `TransformOptions`. It is now the default and only behavior

cmd/astro-wasm/astro-wasm.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,6 @@ func makeTransformOptions(options js.Value) transform.TransformOptions {
135135
scopedStyleStrategy = "where"
136136
}
137137

138-
experimentalScriptOrder := false
139-
if jsBool(options.Get("experimentalScriptOrder")) {
140-
experimentalScriptOrder = true
141-
}
142-
143138
return transform.TransformOptions{
144139
Filename: filename,
145140
NormalizedFilename: normalizedFilename,
@@ -153,7 +148,6 @@ func makeTransformOptions(options js.Value) transform.TransformOptions {
153148
ScopedStyleStrategy: scopedStyleStrategy,
154149
TransitionsAnimationURL: transitionsAnimationURL,
155150
AnnotateSourceFile: annotateSourceFile,
156-
ExperimentalScriptOrder: experimentalScriptOrder,
157151
}
158152
}
159153

internal/printer/printer_css_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func TestPrinterCSS(t *testing.T) {
8787
}
8888

8989
hash := astro.HashString(code)
90-
opts := transform.TransformOptions{Scope: hash, ScopedStyleStrategy: scopedStyleStrategy, ExperimentalScriptOrder: true}
90+
opts := transform.TransformOptions{Scope: hash, ScopedStyleStrategy: scopedStyleStrategy}
9191
transform.ExtractStyles(doc, &opts)
9292
transform.Transform(doc, opts, handler.NewHandler(code, "/test.astro")) // note: we want to test Transform in context here, but more advanced cases could be tested separately
9393
result := PrintCSS(code, doc, transform.TransformOptions{

internal/printer/printer_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2073,7 +2073,6 @@ import Analytics from '../components/Analytics.astro';
20732073
hash := astro.HashString(code)
20742074
transformOptions := transform.TransformOptions{
20752075
Scope: hash,
2076-
ExperimentalScriptOrder: true,
20772076
}
20782077
transform.ExtractStyles(doc, &transformOptions)
20792078
transform.Transform(doc, transformOptions, h) // note: we want to test Transform in context here, but more advanced cases could be tested separately

internal/transform/transform.go

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ type TransformOptions struct {
3434
ResolvePath func(string) string
3535
PreprocessStyle interface{}
3636
AnnotateSourceFile bool
37-
ExperimentalScriptOrder bool
3837
}
3938

4039
func Transform(doc *astro.Node, opts TransformOptions, h *handler.Handler) *astro.Node {
@@ -120,11 +119,7 @@ func ExtractStyles(doc *astro.Node, opts *TransformOptions) {
120119
return
121120
}
122121
// append node to maintain authored order
123-
if opts.ExperimentalScriptOrder {
124-
doc.Styles = append(doc.Styles, n)
125-
} else {
126-
doc.Styles = append([]*astro.Node{n}, doc.Styles...)
127-
}
122+
doc.Styles = append(doc.Styles, n)
128123
}
129124
})
130125
// Important! Remove styles from original location *after* walking the doc
@@ -434,11 +429,7 @@ func ExtractScript(doc *astro.Node, n *astro.Node, opts *TransformOptions, h *ha
434429

435430
// append node to maintain authored order
436431
if shouldAdd {
437-
if opts.ExperimentalScriptOrder {
438-
doc.Scripts = append(doc.Scripts, n)
439-
} else {
440-
doc.Scripts = append([]*astro.Node{n}, doc.Scripts...)
441-
}
432+
doc.Scripts = append(doc.Scripts, n)
442433
n.HandledScript = true
443434
}
444435
} else {

packages/compiler/src/shared/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ export interface TransformOptions {
5959
attrs: Record<string, string>
6060
) => null | Promise<PreprocessorResult | PreprocessorError>;
6161
annotateSourceFile?: boolean;
62-
experimentalScriptOrder?: boolean;
6362
}
6463

6564
export type ConvertToTSXOptions = Pick<

packages/compiler/test/scripts/order.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ test('outputs scripts in expected order', async () => {
66
const result = await transform(
77
`
88
<script>console.log(1)</script>
9-
<script>console.log(2)</script>`,
10-
{
11-
experimentalScriptOrder: true,
12-
}
9+
<script>console.log(2)</script>`
1310
);
1411

1512
const scripts = result.scripts;

packages/compiler/test/styles/sass.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ test.before(async () => {
3333
result = await transform(FIXTURE, {
3434
sourcemap: true,
3535
preprocessStyle,
36-
experimentalScriptOrder: true,
3736
});
3837
});
3938

0 commit comments

Comments
 (0)