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/neat-camels-raise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@astrojs/compiler": major
---

Removes `renderScript` 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 @@ -135,11 +135,6 @@ func makeTransformOptions(options js.Value) transform.TransformOptions {
scopedStyleStrategy = "where"
}

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

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

Expand Down
2 changes: 1 addition & 1 deletion internal/printer/__printer_js__/Empty_script.snap
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydra

const $$Component = $$createComponent(($$result, $$props, $$slots) => {

return $$render``;
return $$render`${$$renderScript($$result,"?astro&type=script&index=0&lang.ts")}`;
}, undefined, undefined);
export default $$Component;
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydra

const $$Component = $$createComponent(($$result, $$props, $$slots) => {

return $$render``;
return $$render`${$$renderScript($$result,"?astro&type=script&index=0&lang.ts")}`;
}, undefined, undefined);
export default $$Component;
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydra

const $$Component = $$createComponent(($$result, $$props, $$slots) => {

return $$render`<script>var one = 'one';</script><script>(function(){${$$defineScriptVars({foo:'bar'})}var three = foo;})();</script><script>(function(){${$$defineScriptVars({foo:'bar'})}var four = foo;})();</script>`;
return $$render`<script>var one = 'one';</script>${$$renderScript($$result,"?astro&type=script&index=0&lang.ts")}<script>(function(){${$$defineScriptVars({foo:'bar'})}var three = foo;})();</script><script>(function(){${$$defineScriptVars({foo:'bar'})}var four = foo;})();</script>`;
}, undefined, undefined);
export default $$Component;
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const $$metadata = $$createMetadata("/projects/app/src/pages/page.astro",

const $$Page = $$createComponent(($$result, $$props, $$slots) => {

return $$render`${$$renderComponent($$result,'Layout',Layout,{})}`;
return $$render`${$$renderScript($$result,"/projects/app/src/pages/page.astro?astro&type=script&index=0&lang.ts")}${$$renderComponent($$result,'Layout',Layout,{})}`;
}, '/projects/app/src/pages/page.astro', undefined);
export default $$Page;
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydra

const $$Component = $$createComponent(($$result, $$props, $$slots) => {

return $$render`${$$maybeRenderHead($$result)}<a class="test">ツ</a>`;
return $$render`${$$renderScript($$result,"?astro&type=script&index=0&lang.ts")}${$$maybeRenderHead($$result)}<a class="test">ツ</a>`;
}, undefined, undefined);
export default $$Component;
```
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

[TestPrinter/script_(renderScript:_true) - 1]
[TestPrinter/script - 1]
## Input

```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydra

const $$Component = $$createComponent(($$result, $$props, $$slots) => {

return $$render`${$$maybeRenderHead($$result)}<div></div>`;
return $$render`${$$renderScript($$result,"?astro&type=script&index=0&lang.ts")}${$$maybeRenderHead($$result)}<div></div>`;
}, undefined, undefined);
export default $$Component;
```
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

[TestPrinter/script_external_(renderScript:_true) - 1]
[TestPrinter/script_external - 1]
## Input

```
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

[TestPrinter/script_external_in_expression_(renderScript:_true) - 1]
[TestPrinter/script_external_in_expression - 1]
## Input

```
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydra

const $$Component = $$createComponent(($$result, $$props, $$slots) => {

return $$render``;
return $$render`${$$renderScript($$result,"?astro&type=script&index=0&lang.ts")}`;
}, undefined, undefined);
export default $$Component;
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydra
const $$Component = $$createComponent(($$result, $$props, $$slots) => {

return $$render`${$$maybeRenderHead($$result)}<main>

${$$renderScript($$result,"?astro&type=script&index=0&lang.ts")}
</main>`;
}, undefined, undefined);
export default $$Component;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

[TestPrinter/script_in_expression_(renderScript:_true) - 1]
[TestPrinter/script_in_expression - 1]
## Input

```
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

[TestPrinter/script_mixed_handled_and_inline_(renderScript:_true) - 1]
[TestPrinter/script_mixed_handled_and_inline - 1]
## Input

```
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

[TestPrinter/script_multiple_(renderScript:_true) - 1]
[TestPrinter/script_multiple - 1]
## Input

```
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

[TestPrinter/selectedcontent_element_in_customizable_select - 1]
## Input

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

[TestPrinter/selectedcontent_self-closing_element - 1]
## Input

Expand Down
50 changes: 7 additions & 43 deletions internal/printer/printer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ type testcase struct {
source string
only bool
transitions bool
transformOptions transform.TransformOptions
filename string
}

Expand Down Expand Up @@ -845,70 +844,37 @@ import Widget2 from '../components/Widget2.astro';
source: `<script>Here</script><div></div>`,
},
{
name: "script (renderScript: true)",
name: "script",
source: `<main><script>console.log("Hello");</script>`,
transformOptions: transform.TransformOptions{
RenderScript: true,
},
filename: "/src/pages/index.astro",
},
{
name: "script multiple (renderScript: true)",
name: "script multiple",
source: `<main><script>console.log("Hello");</script><script>console.log("World");</script>`,
transformOptions: transform.TransformOptions{
RenderScript: true,
},
filename: "/src/pages/index.astro",
},
{
name: "script external (renderScript: true)",
name: "script external",
source: `<main><script src="./hello.js"></script>`,
transformOptions: transform.TransformOptions{
RenderScript: true,
},
filename: "/src/pages/index.astro",
},
{
name: "script external in expression (renderScript: true)",
name: "script external in expression",
source: `<main>{<script src="./hello.js"></script>}`,
transformOptions: transform.TransformOptions{
RenderScript: true,
},
filename: "/src/pages/index.astro",
},
{
// maintain the original behavior, though it may be
// unneeded as renderScript is now on by default
name: "script external in expression (renderScript: false)",
source: `<main>{<script src="./hello.js"></script>}`,
filename: "/src/pages/index.astro",
},
{
name: "script in expression (renderScript: true)",
name: "script in expression",
source: `<main>{true && <script>console.log("hello")</script>}`,
transformOptions: transform.TransformOptions{
RenderScript: true,
},
filename: "/src/pages/index.astro",
},
{
name: "script in expression (renderScript: false)",
source: `<main>{false && <script>console.log("hello")</script>}`,
filename: "/src/pages/index.astro",
},
{
name: "script inline (renderScript: true)",
name: "script inline",
source: `<main><script is:inline type="module">console.log("Hello");</script>`,
transformOptions: transform.TransformOptions{
RenderScript: true,
},
},
{
name: "script mixed handled and inline (renderScript: true)",
name: "script mixed handled and inline",
source: `<main><script>console.log("Hello");</script><script is:inline>console.log("World");</script>`,
transformOptions: transform.TransformOptions{
RenderScript: true,
},
filename: "/src/pages/index.astro",
},
{
Expand Down Expand Up @@ -2105,10 +2071,8 @@ import Analytics from '../components/Analytics.astro';
}

hash := astro.HashString(code)
// combine from tt.transformOptions
transformOptions := transform.TransformOptions{
Scope: hash,
RenderScript: tt.transformOptions.RenderScript,
}
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
Loading
Loading