Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove experimental transition flags #858

Merged
merged 2 commits into from
Aug 23, 2023
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/giant-boats-mate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/compiler': patch
natemoo-re marked this conversation as resolved.
Show resolved Hide resolved
---

Remove experimental flags from `transition:` directives. They are now enabled by default.
10 changes: 0 additions & 10 deletions cmd/astro-wasm/astro-wasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,6 @@ func makeTransformOptions(options js.Value) transform.TransformOptions {
if jsBool(options.Get("resultScopedSlot")) {
scopedSlot = true
}
experimentalTransitions := false
if jsBool(options.Get("experimentalTransitions")) {
experimentalTransitions = true
}
experimentalPersistence := false
if jsBool(options.Get("experimentalPersistence")) {
experimentalPersistence = true
}
transitionsAnimationURL := jsString(options.Get("transitionsAnimationURL"))
if transitionsAnimationURL == "" {
transitionsAnimationURL = "astro/components/viewtransitions.css"
Expand Down Expand Up @@ -139,8 +131,6 @@ func makeTransformOptions(options js.Value) transform.TransformOptions {
PreprocessStyle: preprocessStyle,
ResultScopedSlot: scopedSlot,
ScopedStyleStrategy: scopedStyleStrategy,
ExperimentalTransitions: experimentalTransitions,
ExperimentalPersistence: experimentalPersistence,
TransitionsAnimationURL: transitionsAnimationURL,
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/printer/print-to-js.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func emptyTextNodeWithoutSiblings(n *Node) bool {
func render1(p *printer, n *Node, opts RenderOptions) {
depth := opts.depth

if opts.opts.ExperimentalTransitions && n.Transition {
if n.Transition {
p.needsTransitionCSS = true
}

Expand Down
12 changes: 4 additions & 8 deletions internal/printer/printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,10 @@ func (p *printer) printInternalImports(importSpecifier string, opts *RenderOptio
p.print("defineStyleVars as " + DEFINE_STYLE_VARS + ",\n ")
p.addNilSourceMapping()
p.print("defineScriptVars as " + DEFINE_SCRIPT_VARS + ",\n ")
if opts.opts.ExperimentalTransitions {
p.addNilSourceMapping()
p.print("renderTransition as " + RENDER_TRANSITION + ",\n ")
}
if opts.opts.ExperimentalPersistence {
p.addNilSourceMapping()
p.print("createTransitionScope as " + CREATE_TRANSITION_SCOPE + ",\n ")
}
p.addNilSourceMapping()
p.print("renderTransition as " + RENDER_TRANSITION + ",\n ")
p.addNilSourceMapping()
p.print("createTransitionScope as " + CREATE_TRANSITION_SCOPE + ",\n ")

// Only needed if using fallback `resolvePath` as it calls `$$metadata.resolvePath`
if opts.opts.ResolvePath == nil {
Expand Down
18 changes: 11 additions & 7 deletions internal/printer/printer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ var INTERNAL_IMPORTS = fmt.Sprintf("import {\n %s\n} from \"%s\";\n", strings.J
"spreadAttributes as " + SPREAD_ATTRIBUTES,
"defineStyleVars as " + DEFINE_STYLE_VARS,
"defineScriptVars as " + DEFINE_SCRIPT_VARS,
"renderTransition as " + RENDER_TRANSITION,
"createTransitionScope as " + CREATE_TRANSITION_SCOPE,
"createMetadata as " + CREATE_METADATA,
}, ",\n "), "http://localhost:3000/")
var PRELUDE = fmt.Sprintf(`const $$Component = %s(async ($$result, $$props, %s) => {
Expand Down Expand Up @@ -2875,20 +2877,22 @@ const items = ["Dog", "Cat", "Platipus"];
hash := astro.HashString(code)
transform.ExtractStyles(doc)
transformOptions := transform.TransformOptions{
Scope: hash,
ExperimentalTransitions: true,
ExperimentalPersistence: true,
Scope: hash,
}
transform.Transform(doc, transformOptions, h) // note: we want to test Transform in context here, but more advanced cases could be tested separately
result := PrintToJS(code, doc, 0, transform.TransformOptions{
Scope: "XXXX",
InternalURL: "http://localhost:3000/",
Filename: tt.filename,
AstroGlobalArgs: "'https://astro.build'",
Scope: "XXXX",
InternalURL: "http://localhost:3000/",
Filename: tt.filename,
AstroGlobalArgs: "'https://astro.build'",
TransitionsAnimationURL: "transitions.css",
}, h)
output := string(result.Output)

toMatch := INTERNAL_IMPORTS
if strings.Count(tt.source, "transition:") > 0 {
toMatch += `import "transitions.css";`
}
if len(tt.want.frontmatter) > 0 {
toMatch += test_utils.Dedent(tt.want.frontmatter[0])
}
Expand Down
4 changes: 1 addition & 3 deletions internal/transform/transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ type TransformOptions struct {
ScopedStyleStrategy string
Compact bool
ResultScopedSlot bool
ExperimentalTransitions bool
ExperimentalPersistence bool
TransitionsAnimationURL string
ResolvePath func(string) string
PreprocessStyle interface{}
Expand All @@ -46,7 +44,7 @@ func Transform(doc *astro.Node, opts TransformOptions, h *handler.Handler) *astr
if shouldScope {
ScopeElement(n, opts)
}
if opts.ExperimentalTransitions && (HasAttr(n, TRANSITION_ANIMATE) || HasAttr(n, TRANSITION_NAME) || HasAttr(n, TRANSITION_PERSIST)) {
if HasAttr(n, TRANSITION_ANIMATE) || HasAttr(n, TRANSITION_NAME) || HasAttr(n, TRANSITION_PERSIST) {
doc.Transition = true
getOrCreateTransitionScope(n, &opts, i)
}
Expand Down
4 changes: 1 addition & 3 deletions internal/transform/transform_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,7 @@ func TestFullTransform(t *testing.T) {
ExtractStyles(doc)
// Clear doc.Styles to avoid scoping behavior, we're not testing that here
doc.Styles = make([]*astro.Node, 0)
Transform(doc, TransformOptions{
ExperimentalTransitions: true,
}, handler.NewHandler(tt.source, "/test.astro"))
Transform(doc, TransformOptions{}, handler.NewHandler(tt.source, "/test.astro"))
astro.PrintToSource(&b, doc)
got := strings.TrimSpace(b.String())
if tt.want != got {
Expand Down
2 changes: 0 additions & 2 deletions packages/compiler/src/shared/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ export interface TransformOptions {
* @deprecated "as" has been removed and no longer has any effect!
*/
as?: 'document' | 'fragment';
experimentalTransitions?: boolean;
experimentalPersistence?: boolean;
transitionsAnimationURL?: string;
resolvePath?: (specifier: string) => Promise<string>;
preprocessStyle?: (content: string, attrs: Record<string, string>) => null | Promise<PreprocessorResult | PreprocessorError>;
Expand Down
Loading