Skip to content

Commit ac52387

Browse files
feat: remove experimentalScriptOrder option (#1115)
1 parent bd5be73 commit ac52387

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
@@ -140,11 +140,6 @@ func makeTransformOptions(options js.Value) transform.TransformOptions {
140140
renderScript = true
141141
}
142142

143-
experimentalScriptOrder := false
144-
if jsBool(options.Get("experimentalScriptOrder")) {
145-
experimentalScriptOrder = true
146-
}
147-
148143
return transform.TransformOptions{
149144
Filename: filename,
150145
NormalizedFilename: normalizedFilename,
@@ -159,7 +154,6 @@ func makeTransformOptions(options js.Value) transform.TransformOptions {
159154
TransitionsAnimationURL: transitionsAnimationURL,
160155
AnnotateSourceFile: annotateSourceFile,
161156
RenderScript: renderScript,
162-
ExperimentalScriptOrder: experimentalScriptOrder,
163157
}
164158
}
165159

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
@@ -2109,7 +2109,6 @@ import Analytics from '../components/Analytics.astro';
21092109
transformOptions := transform.TransformOptions{
21102110
Scope: hash,
21112111
RenderScript: tt.transformOptions.RenderScript,
2112-
ExperimentalScriptOrder: true,
21132112
}
21142113
transform.ExtractStyles(doc, &transformOptions)
21152114
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
@@ -35,7 +35,6 @@ type TransformOptions struct {
3535
PreprocessStyle interface{}
3636
AnnotateSourceFile bool
3737
RenderScript bool
38-
ExperimentalScriptOrder bool
3938
}
4039

4140
func Transform(doc *astro.Node, opts TransformOptions, h *handler.Handler) *astro.Node {
@@ -128,11 +127,7 @@ func ExtractStyles(doc *astro.Node, opts *TransformOptions) {
128127
return
129128
}
130129
// append node to maintain authored order
131-
if opts.ExperimentalScriptOrder {
132-
doc.Styles = append(doc.Styles, n)
133-
} else {
134-
doc.Styles = append([]*astro.Node{n}, doc.Styles...)
135-
}
130+
doc.Styles = append(doc.Styles, n)
136131
}
137132
})
138133
// Important! Remove styles from original location *after* walking the doc
@@ -443,11 +438,7 @@ func ExtractScript(doc *astro.Node, n *astro.Node, opts *TransformOptions, h *ha
443438

444439
// append node to maintain authored order
445440
if shouldAdd {
446-
if opts.ExperimentalScriptOrder {
447-
doc.Scripts = append(doc.Scripts, n)
448-
} else {
449-
doc.Scripts = append([]*astro.Node{n}, doc.Scripts...)
450-
}
441+
doc.Scripts = append(doc.Scripts, n)
451442
n.HandledScript = true
452443
}
453444
} else {

packages/compiler/src/shared/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ export interface TransformOptions {
6565
* @experimental
6666
*/
6767
renderScript?: boolean;
68-
experimentalScriptOrder?: boolean;
6968
}
7069

7170
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)