Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/silver-deers-buy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@astrojs/compiler": major
---

Removes `experimentalScriptOrder` from `TransformOptions`. It is now the default and only behavior
6 changes: 0 additions & 6 deletions cmd/astro-wasm/astro-wasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,6 @@ func makeTransformOptions(options js.Value) transform.TransformOptions {
renderScript = true
}

experimentalScriptOrder := false
if jsBool(options.Get("experimentalScriptOrder")) {
experimentalScriptOrder = true
}

return transform.TransformOptions{
Filename: filename,
NormalizedFilename: normalizedFilename,
Expand All @@ -159,7 +154,6 @@ func makeTransformOptions(options js.Value) transform.TransformOptions {
TransitionsAnimationURL: transitionsAnimationURL,
AnnotateSourceFile: annotateSourceFile,
RenderScript: renderScript,
ExperimentalScriptOrder: experimentalScriptOrder,
}
}

Expand Down
2 changes: 1 addition & 1 deletion internal/printer/printer_css_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func TestPrinterCSS(t *testing.T) {
}

hash := astro.HashString(code)
opts := transform.TransformOptions{Scope: hash, ScopedStyleStrategy: scopedStyleStrategy, ExperimentalScriptOrder: true}
opts := transform.TransformOptions{Scope: hash, ScopedStyleStrategy: scopedStyleStrategy}
transform.ExtractStyles(doc, &opts)
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
result := PrintCSS(code, doc, transform.TransformOptions{
Expand Down
1 change: 0 additions & 1 deletion internal/printer/printer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2109,7 +2109,6 @@ import Analytics from '../components/Analytics.astro';
transformOptions := transform.TransformOptions{
Scope: hash,
RenderScript: tt.transformOptions.RenderScript,
ExperimentalScriptOrder: true,
}
transform.ExtractStyles(doc, &transformOptions)
transform.Transform(doc, transformOptions, h) // note: we want to test Transform in context here, but more advanced cases could be tested separately
Expand Down
13 changes: 2 additions & 11 deletions internal/transform/transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ type TransformOptions struct {
PreprocessStyle interface{}
AnnotateSourceFile bool
RenderScript bool
ExperimentalScriptOrder bool
}

func Transform(doc *astro.Node, opts TransformOptions, h *handler.Handler) *astro.Node {
Expand Down Expand Up @@ -128,11 +127,7 @@ func ExtractStyles(doc *astro.Node, opts *TransformOptions) {
return
}
// append node to maintain authored order
if opts.ExperimentalScriptOrder {
doc.Styles = append(doc.Styles, n)
} else {
doc.Styles = append([]*astro.Node{n}, doc.Styles...)
}
doc.Styles = append(doc.Styles, n)
}
})
// Important! Remove styles from original location *after* walking the doc
Expand Down Expand Up @@ -443,11 +438,7 @@ func ExtractScript(doc *astro.Node, n *astro.Node, opts *TransformOptions, h *ha

// append node to maintain authored order
if shouldAdd {
if opts.ExperimentalScriptOrder {
doc.Scripts = append(doc.Scripts, n)
} else {
doc.Scripts = append([]*astro.Node{n}, doc.Scripts...)
}
doc.Scripts = append(doc.Scripts, n)
n.HandledScript = true
}
} else {
Expand Down
1 change: 0 additions & 1 deletion packages/compiler/src/shared/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ export interface TransformOptions {
* @experimental
*/
renderScript?: boolean;
experimentalScriptOrder?: boolean;
}

export type ConvertToTSXOptions = Pick<
Expand Down
5 changes: 1 addition & 4 deletions packages/compiler/test/scripts/order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ test('outputs scripts in expected order', async () => {
const result = await transform(
`
<script>console.log(1)</script>
<script>console.log(2)</script>`,
{
experimentalScriptOrder: true,
}
<script>console.log(2)</script>`
);

const scripts = result.scripts;
Expand Down
1 change: 0 additions & 1 deletion packages/compiler/test/styles/sass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ test.before(async () => {
result = await transform(FIXTURE, {
sourcemap: true,
preprocessStyle,
experimentalScriptOrder: true,
});
});

Expand Down
Loading