diff --git a/src/babel/index.ts b/src/babel/index.ts index 9fcbd57..c627ee9 100644 --- a/src/babel/index.ts +++ b/src/babel/index.ts @@ -309,10 +309,6 @@ function bubbleFunctionDeclaration( // have zero or one parameter decl.params.length < 2 ) { - const first = program.get('body')[0]; - const [tmp] = first.insertBefore(decl); - program.scope.registerDeclaration(tmp); - tmp.skip(); if (path.parentPath.isExportNamedDeclaration()) { path.parentPath.replaceWith( t.exportNamedDeclaration(undefined, [ @@ -324,6 +320,9 @@ function bubbleFunctionDeclaration( } else { path.remove(); } + const [tmp] = program.unshiftContainer('body', [decl]); + program.scope.registerDeclaration(tmp); + tmp.skip(); } } } @@ -361,6 +360,7 @@ export default function solidRefreshPlugin(): babel.PluginObj { bubbleFunctionDeclaration(programPath, path); }, }); + programPath.scope.crawl(); if (state.jsx) { programPath.traverse({ JSXElement(path) { @@ -370,6 +370,7 @@ export default function solidRefreshPlugin(): babel.PluginObj { transformJSX(path); }, }); + programPath.scope.crawl(); } programPath.traverse({ VariableDeclarator(path) { diff --git a/tests/client-hydratable/__snapshots__/esm.test.ts.snap b/tests/client-hydratable/__snapshots__/esm.test.ts.snap index 29d9702..6ca7987 100644 --- a/tests/client-hydratable/__snapshots__/esm.test.ts.snap +++ b/tests/client-hydratable/__snapshots__/esm.test.ts.snap @@ -451,48 +451,39 @@ exports[`esm (client, hydratable) > ExportNamedDeclaration w/ FunctionExpression "import { template as _$template } from "solid-js/web"; import { createComponent as _$createComponent } from "solid-js/web"; import { getNextElement as _$getNextElement } from "solid-js/web"; -var _tmpl$ = /*#__PURE__*/_$template(\`
foo\`), - _tmpl$2 = /*#__PURE__*/_$template(\`
bar\`); +var _tmpl$ = /*#__PURE__*/_$template(\`
bar\`), + _tmpl$2 = /*#__PURE__*/_$template(\`
foo\`); import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; const _REGISTRY = _$$registry(); -const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$getNextElement(_tmpl$), { +const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props => /*@refresh jsx-skip*/_$getNextElement(_tmpl$), { + location: "example.jsx:3:15", + signature: "61dd3182" +}); +const Bar = _$$component(_REGISTRY, "Bar", function Bar() { + return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); +}, { + location: "example.jsx:2:13", + signature: "e93ca257" +}); +const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$getNextElement(_tmpl$2), { location: "example.jsx:8:12", signature: "241c14a4" }); -const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-skip*/_$createComponent(_props4.v0, {}), { +const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-skip*/_$createComponent(Bar, {}), { location: "example.jsx:9:12", - signature: "9a24e06b" + signature: "61d9a109" }); -const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, { - get v0() { - return _props.v0; - } -})], { +const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props2 => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { location: "example.jsx:7:10", - signature: "77f4a4b9" + signature: "5302828d" }); const Foo = _$$component(_REGISTRY, "Foo", function Foo() { - return /*@refresh jsx-skip*/_$createComponent(Foo_1, { - v0: Bar - }); + return /*@refresh jsx-skip*/_$createComponent(Foo_1, {}); }, { location: "example.jsx:5:13", - signature: "2f861eed", - dependencies: () => ({ - Bar - }) -}); -const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props2 => /*@refresh jsx-skip*/_$getNextElement(_tmpl$2), { - location: "example.jsx:3:15", - signature: "fad4daa8" -}); -const Bar = _$$component(_REGISTRY, "Bar", function Bar() { - return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); -}, { - location: "example.jsx:2:13", - signature: "e93ca257" + signature: "c963b907" }); export { Bar }; export { Foo }; @@ -624,7 +615,6 @@ var _tmpl$ = /*#__PURE__*/_$template(\`

\`); import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; -const example = 'Foo'; const _REGISTRY = _$$registry(); const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/(() => { var _el$ = _$getNextElement(_tmpl$); @@ -645,6 +635,7 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { example }) }); +const example = 'Foo'; if (import.meta.hot) { _$$refresh("esm", import.meta.hot, _REGISTRY); }" @@ -655,7 +646,6 @@ exports[`esm (client, hydratable) > FunctionDeclaration > should transform Funct import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; -const Example = createContext(); const _REGISTRY = _$$registry(); const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/_$createComponent(_props.v0, { children: "Foo" @@ -676,6 +666,7 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { Example }) }); +const Example = createContext(); if (import.meta.hot) { _$$refresh("esm", import.meta.hot, _REGISTRY); }" @@ -685,23 +676,13 @@ exports[`esm (client, hydratable) > FunctionDeclaration > should transform Funct "import { template as _$template } from "solid-js/web"; import { createComponent as _$createComponent } from "solid-js/web"; import { getNextElement as _$getNextElement } from "solid-js/web"; -var _tmpl$ = /*#__PURE__*/_$template(\`
bar\`), - _tmpl$2 = /*#__PURE__*/_$template(\`
foo\`); +var _tmpl$ = /*#__PURE__*/_$template(\`
foo\`), + _tmpl$2 = /*#__PURE__*/_$template(\`
bar\`); import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; const _REGISTRY = _$$registry(); -const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props => /*@refresh jsx-skip*/_$getNextElement(_tmpl$), { - location: "example.jsx:3:15", - signature: "61dd3182" -}); -const Bar = _$$component(_REGISTRY, "Bar", function Bar() { - return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); -}, { - location: "example.jsx:2:6", - signature: "e93ca257" -}); -const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$getNextElement(_tmpl$2), { +const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$getNextElement(_tmpl$), { location: "example.jsx:8:12", signature: "241c14a4" }); @@ -709,9 +690,9 @@ const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-ski location: "example.jsx:9:12", signature: "61d9a109" }); -const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props2 => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { +const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { location: "example.jsx:7:10", - signature: "5302828d" + signature: "825a754d" }); const Foo = _$$component(_REGISTRY, "Foo", function Foo() { return /*@refresh jsx-skip*/_$createComponent(Foo_1, {}); @@ -719,6 +700,16 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { location: "example.jsx:5:6", signature: "c963b907" }); +const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props2 => /*@refresh jsx-skip*/_$getNextElement(_tmpl$2), { + location: "example.jsx:3:15", + signature: "fad4daa8" +}); +const Bar = _$$component(_REGISTRY, "Bar", function Bar() { + return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); +}, { + location: "example.jsx:2:6", + signature: "e93ca257" +}); if (import.meta.hot) { _$$refresh("esm", import.meta.hot, _REGISTRY); }" diff --git a/tests/client-hydratable/__snapshots__/rspack-esm.test.ts.snap b/tests/client-hydratable/__snapshots__/rspack-esm.test.ts.snap index 8d635b8..b57cc4e 100644 --- a/tests/client-hydratable/__snapshots__/rspack-esm.test.ts.snap +++ b/tests/client-hydratable/__snapshots__/rspack-esm.test.ts.snap @@ -451,48 +451,39 @@ exports[`rspack-esm (client, hydratable) > ExportNamedDeclaration w/ FunctionExp "import { template as _$template } from "solid-js/web"; import { createComponent as _$createComponent } from "solid-js/web"; import { getNextElement as _$getNextElement } from "solid-js/web"; -var _tmpl$ = /*#__PURE__*/_$template(\`
foo\`), - _tmpl$2 = /*#__PURE__*/_$template(\`
bar\`); +var _tmpl$ = /*#__PURE__*/_$template(\`
bar\`), + _tmpl$2 = /*#__PURE__*/_$template(\`
foo\`); import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; const _REGISTRY = _$$registry(); -const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$getNextElement(_tmpl$), { +const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props => /*@refresh jsx-skip*/_$getNextElement(_tmpl$), { + location: "example.jsx:3:15", + signature: "61dd3182" +}); +const Bar = _$$component(_REGISTRY, "Bar", function Bar() { + return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); +}, { + location: "example.jsx:2:13", + signature: "e93ca257" +}); +const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$getNextElement(_tmpl$2), { location: "example.jsx:8:12", signature: "241c14a4" }); -const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-skip*/_$createComponent(_props4.v0, {}), { +const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-skip*/_$createComponent(Bar, {}), { location: "example.jsx:9:12", - signature: "9a24e06b" + signature: "61d9a109" }); -const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, { - get v0() { - return _props.v0; - } -})], { +const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props2 => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { location: "example.jsx:7:10", - signature: "77f4a4b9" + signature: "5302828d" }); const Foo = _$$component(_REGISTRY, "Foo", function Foo() { - return /*@refresh jsx-skip*/_$createComponent(Foo_1, { - v0: Bar - }); + return /*@refresh jsx-skip*/_$createComponent(Foo_1, {}); }, { location: "example.jsx:5:13", - signature: "2f861eed", - dependencies: () => ({ - Bar - }) -}); -const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props2 => /*@refresh jsx-skip*/_$getNextElement(_tmpl$2), { - location: "example.jsx:3:15", - signature: "fad4daa8" -}); -const Bar = _$$component(_REGISTRY, "Bar", function Bar() { - return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); -}, { - location: "example.jsx:2:13", - signature: "e93ca257" + signature: "c963b907" }); export { Bar }; export { Foo }; @@ -624,7 +615,6 @@ var _tmpl$ = /*#__PURE__*/_$template(\`

\`); import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; -const example = 'Foo'; const _REGISTRY = _$$registry(); const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/(() => { var _el$ = _$getNextElement(_tmpl$); @@ -645,6 +635,7 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { example }) }); +const example = 'Foo'; if (import.meta.webpackHot) { _$$refresh("rspack-esm", import.meta.webpackHot, _REGISTRY); }" @@ -655,7 +646,6 @@ exports[`rspack-esm (client, hydratable) > FunctionDeclaration > should transfor import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; -const Example = createContext(); const _REGISTRY = _$$registry(); const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/_$createComponent(_props.v0, { children: "Foo" @@ -676,6 +666,7 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { Example }) }); +const Example = createContext(); if (import.meta.webpackHot) { _$$refresh("rspack-esm", import.meta.webpackHot, _REGISTRY); }" @@ -685,23 +676,13 @@ exports[`rspack-esm (client, hydratable) > FunctionDeclaration > should transfor "import { template as _$template } from "solid-js/web"; import { createComponent as _$createComponent } from "solid-js/web"; import { getNextElement as _$getNextElement } from "solid-js/web"; -var _tmpl$ = /*#__PURE__*/_$template(\`
bar\`), - _tmpl$2 = /*#__PURE__*/_$template(\`
foo\`); +var _tmpl$ = /*#__PURE__*/_$template(\`
foo\`), + _tmpl$2 = /*#__PURE__*/_$template(\`
bar\`); import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; const _REGISTRY = _$$registry(); -const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props => /*@refresh jsx-skip*/_$getNextElement(_tmpl$), { - location: "example.jsx:3:15", - signature: "61dd3182" -}); -const Bar = _$$component(_REGISTRY, "Bar", function Bar() { - return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); -}, { - location: "example.jsx:2:6", - signature: "e93ca257" -}); -const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$getNextElement(_tmpl$2), { +const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$getNextElement(_tmpl$), { location: "example.jsx:8:12", signature: "241c14a4" }); @@ -709,9 +690,9 @@ const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-ski location: "example.jsx:9:12", signature: "61d9a109" }); -const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props2 => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { +const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { location: "example.jsx:7:10", - signature: "5302828d" + signature: "825a754d" }); const Foo = _$$component(_REGISTRY, "Foo", function Foo() { return /*@refresh jsx-skip*/_$createComponent(Foo_1, {}); @@ -719,6 +700,16 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { location: "example.jsx:5:6", signature: "c963b907" }); +const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props2 => /*@refresh jsx-skip*/_$getNextElement(_tmpl$2), { + location: "example.jsx:3:15", + signature: "fad4daa8" +}); +const Bar = _$$component(_REGISTRY, "Bar", function Bar() { + return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); +}, { + location: "example.jsx:2:6", + signature: "e93ca257" +}); if (import.meta.webpackHot) { _$$refresh("rspack-esm", import.meta.webpackHot, _REGISTRY); }" diff --git a/tests/client-hydratable/__snapshots__/standard.test.ts.snap b/tests/client-hydratable/__snapshots__/standard.test.ts.snap index dd3ccd8..1ee8753 100644 --- a/tests/client-hydratable/__snapshots__/standard.test.ts.snap +++ b/tests/client-hydratable/__snapshots__/standard.test.ts.snap @@ -451,48 +451,39 @@ exports[`standard (client, hydratable) > ExportNamedDeclaration w/ FunctionExpre "import { template as _$template } from "solid-js/web"; import { createComponent as _$createComponent } from "solid-js/web"; import { getNextElement as _$getNextElement } from "solid-js/web"; -var _tmpl$ = /*#__PURE__*/_$template(\`
foo\`), - _tmpl$2 = /*#__PURE__*/_$template(\`
bar\`); +var _tmpl$ = /*#__PURE__*/_$template(\`
bar\`), + _tmpl$2 = /*#__PURE__*/_$template(\`
foo\`); import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; const _REGISTRY = _$$registry(); -const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$getNextElement(_tmpl$), { +const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props => /*@refresh jsx-skip*/_$getNextElement(_tmpl$), { + location: "example.jsx:3:15", + signature: "61dd3182" +}); +const Bar = _$$component(_REGISTRY, "Bar", function Bar() { + return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); +}, { + location: "example.jsx:2:13", + signature: "e93ca257" +}); +const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$getNextElement(_tmpl$2), { location: "example.jsx:8:12", signature: "241c14a4" }); -const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-skip*/_$createComponent(_props4.v0, {}), { +const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-skip*/_$createComponent(Bar, {}), { location: "example.jsx:9:12", - signature: "9a24e06b" + signature: "61d9a109" }); -const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, { - get v0() { - return _props.v0; - } -})], { +const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props2 => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { location: "example.jsx:7:10", - signature: "77f4a4b9" + signature: "5302828d" }); const Foo = _$$component(_REGISTRY, "Foo", function Foo() { - return /*@refresh jsx-skip*/_$createComponent(Foo_1, { - v0: Bar - }); + return /*@refresh jsx-skip*/_$createComponent(Foo_1, {}); }, { location: "example.jsx:5:13", - signature: "2f861eed", - dependencies: () => ({ - Bar - }) -}); -const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props2 => /*@refresh jsx-skip*/_$getNextElement(_tmpl$2), { - location: "example.jsx:3:15", - signature: "fad4daa8" -}); -const Bar = _$$component(_REGISTRY, "Bar", function Bar() { - return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); -}, { - location: "example.jsx:2:13", - signature: "e93ca257" + signature: "c963b907" }); export { Bar }; export { Foo }; @@ -624,7 +615,6 @@ var _tmpl$ = /*#__PURE__*/_$template(\`

\`); import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; -const example = 'Foo'; const _REGISTRY = _$$registry(); const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/(() => { var _el$ = _$getNextElement(_tmpl$); @@ -645,6 +635,7 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { example }) }); +const example = 'Foo'; if (module.hot) { _$$refresh("standard", module.hot, _REGISTRY); }" @@ -655,7 +646,6 @@ exports[`standard (client, hydratable) > FunctionDeclaration > should transform import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; -const Example = createContext(); const _REGISTRY = _$$registry(); const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/_$createComponent(_props.v0, { children: "Foo" @@ -676,6 +666,7 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { Example }) }); +const Example = createContext(); if (module.hot) { _$$refresh("standard", module.hot, _REGISTRY); }" @@ -685,23 +676,13 @@ exports[`standard (client, hydratable) > FunctionDeclaration > should transform "import { template as _$template } from "solid-js/web"; import { createComponent as _$createComponent } from "solid-js/web"; import { getNextElement as _$getNextElement } from "solid-js/web"; -var _tmpl$ = /*#__PURE__*/_$template(\`
bar\`), - _tmpl$2 = /*#__PURE__*/_$template(\`
foo\`); +var _tmpl$ = /*#__PURE__*/_$template(\`
foo\`), + _tmpl$2 = /*#__PURE__*/_$template(\`
bar\`); import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; const _REGISTRY = _$$registry(); -const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props => /*@refresh jsx-skip*/_$getNextElement(_tmpl$), { - location: "example.jsx:3:15", - signature: "61dd3182" -}); -const Bar = _$$component(_REGISTRY, "Bar", function Bar() { - return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); -}, { - location: "example.jsx:2:6", - signature: "e93ca257" -}); -const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$getNextElement(_tmpl$2), { +const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$getNextElement(_tmpl$), { location: "example.jsx:8:12", signature: "241c14a4" }); @@ -709,9 +690,9 @@ const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-ski location: "example.jsx:9:12", signature: "61d9a109" }); -const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props2 => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { +const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { location: "example.jsx:7:10", - signature: "5302828d" + signature: "825a754d" }); const Foo = _$$component(_REGISTRY, "Foo", function Foo() { return /*@refresh jsx-skip*/_$createComponent(Foo_1, {}); @@ -719,6 +700,16 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { location: "example.jsx:5:6", signature: "c963b907" }); +const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props2 => /*@refresh jsx-skip*/_$getNextElement(_tmpl$2), { + location: "example.jsx:3:15", + signature: "fad4daa8" +}); +const Bar = _$$component(_REGISTRY, "Bar", function Bar() { + return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); +}, { + location: "example.jsx:2:6", + signature: "e93ca257" +}); if (module.hot) { _$$refresh("standard", module.hot, _REGISTRY); }" diff --git a/tests/client-hydratable/__snapshots__/vite.test.ts.snap b/tests/client-hydratable/__snapshots__/vite.test.ts.snap index c21db9d..8f57e26 100644 --- a/tests/client-hydratable/__snapshots__/vite.test.ts.snap +++ b/tests/client-hydratable/__snapshots__/vite.test.ts.snap @@ -464,48 +464,39 @@ exports[`vite (client, hydratable) > ExportNamedDeclaration w/ FunctionExpressio "import { template as _$template } from "solid-js/web"; import { createComponent as _$createComponent } from "solid-js/web"; import { getNextElement as _$getNextElement } from "solid-js/web"; -var _tmpl$ = /*#__PURE__*/_$template(\`
foo\`), - _tmpl$2 = /*#__PURE__*/_$template(\`
bar\`); +var _tmpl$ = /*#__PURE__*/_$template(\`
bar\`), + _tmpl$2 = /*#__PURE__*/_$template(\`
foo\`); import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; const _REGISTRY = _$$registry(); -const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$getNextElement(_tmpl$), { +const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props => /*@refresh jsx-skip*/_$getNextElement(_tmpl$), { + location: "example.jsx:3:15", + signature: "61dd3182" +}); +const Bar = _$$component(_REGISTRY, "Bar", function Bar() { + return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); +}, { + location: "example.jsx:2:13", + signature: "e93ca257" +}); +const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$getNextElement(_tmpl$2), { location: "example.jsx:8:12", signature: "241c14a4" }); -const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-skip*/_$createComponent(_props4.v0, {}), { +const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-skip*/_$createComponent(Bar, {}), { location: "example.jsx:9:12", - signature: "9a24e06b" + signature: "61d9a109" }); -const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, { - get v0() { - return _props.v0; - } -})], { +const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props2 => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { location: "example.jsx:7:10", - signature: "77f4a4b9" + signature: "5302828d" }); const Foo = _$$component(_REGISTRY, "Foo", function Foo() { - return /*@refresh jsx-skip*/_$createComponent(Foo_1, { - v0: Bar - }); + return /*@refresh jsx-skip*/_$createComponent(Foo_1, {}); }, { location: "example.jsx:5:13", - signature: "2f861eed", - dependencies: () => ({ - Bar - }) -}); -const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props2 => /*@refresh jsx-skip*/_$getNextElement(_tmpl$2), { - location: "example.jsx:3:15", - signature: "fad4daa8" -}); -const Bar = _$$component(_REGISTRY, "Bar", function Bar() { - return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); -}, { - location: "example.jsx:2:13", - signature: "e93ca257" + signature: "c963b907" }); export { Bar }; export { Foo }; @@ -641,7 +632,6 @@ var _tmpl$ = /*#__PURE__*/_$template(\`

\`); import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; -const example = 'Foo'; const _REGISTRY = _$$registry(); const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/(() => { var _el$ = _$getNextElement(_tmpl$); @@ -662,6 +652,7 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { example }) }); +const example = 'Foo'; if (import.meta.hot) { import.meta.hot.accept(); _$$refresh("vite", import.meta.hot, _REGISTRY); @@ -673,7 +664,6 @@ exports[`vite (client, hydratable) > FunctionDeclaration > should transform Func import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; -const Example = createContext(); const _REGISTRY = _$$registry(); const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/_$createComponent(_props.v0, { children: "Foo" @@ -694,6 +684,7 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { Example }) }); +const Example = createContext(); if (import.meta.hot) { import.meta.hot.accept(); _$$refresh("vite", import.meta.hot, _REGISTRY); @@ -704,23 +695,13 @@ exports[`vite (client, hydratable) > FunctionDeclaration > should transform Func "import { template as _$template } from "solid-js/web"; import { createComponent as _$createComponent } from "solid-js/web"; import { getNextElement as _$getNextElement } from "solid-js/web"; -var _tmpl$ = /*#__PURE__*/_$template(\`
bar\`), - _tmpl$2 = /*#__PURE__*/_$template(\`
foo\`); +var _tmpl$ = /*#__PURE__*/_$template(\`
foo\`), + _tmpl$2 = /*#__PURE__*/_$template(\`
bar\`); import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; const _REGISTRY = _$$registry(); -const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props => /*@refresh jsx-skip*/_$getNextElement(_tmpl$), { - location: "example.jsx:3:15", - signature: "61dd3182" -}); -const Bar = _$$component(_REGISTRY, "Bar", function Bar() { - return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); -}, { - location: "example.jsx:2:6", - signature: "e93ca257" -}); -const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$getNextElement(_tmpl$2), { +const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$getNextElement(_tmpl$), { location: "example.jsx:8:12", signature: "241c14a4" }); @@ -728,9 +709,9 @@ const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-ski location: "example.jsx:9:12", signature: "61d9a109" }); -const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props2 => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { +const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { location: "example.jsx:7:10", - signature: "5302828d" + signature: "825a754d" }); const Foo = _$$component(_REGISTRY, "Foo", function Foo() { return /*@refresh jsx-skip*/_$createComponent(Foo_1, {}); @@ -738,6 +719,16 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { location: "example.jsx:5:6", signature: "c963b907" }); +const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props2 => /*@refresh jsx-skip*/_$getNextElement(_tmpl$2), { + location: "example.jsx:3:15", + signature: "fad4daa8" +}); +const Bar = _$$component(_REGISTRY, "Bar", function Bar() { + return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); +}, { + location: "example.jsx:2:6", + signature: "e93ca257" +}); if (import.meta.hot) { import.meta.hot.accept(); _$$refresh("vite", import.meta.hot, _REGISTRY); diff --git a/tests/client-hydratable/__snapshots__/webpack5.test.ts.snap b/tests/client-hydratable/__snapshots__/webpack5.test.ts.snap index d1da3d0..17687d3 100644 --- a/tests/client-hydratable/__snapshots__/webpack5.test.ts.snap +++ b/tests/client-hydratable/__snapshots__/webpack5.test.ts.snap @@ -451,48 +451,39 @@ exports[`webpack5 (client, hydratable) > ExportNamedDeclaration w/ FunctionExpre "import { template as _$template } from "solid-js/web"; import { createComponent as _$createComponent } from "solid-js/web"; import { getNextElement as _$getNextElement } from "solid-js/web"; -var _tmpl$ = /*#__PURE__*/_$template(\`
foo\`), - _tmpl$2 = /*#__PURE__*/_$template(\`
bar\`); +var _tmpl$ = /*#__PURE__*/_$template(\`
bar\`), + _tmpl$2 = /*#__PURE__*/_$template(\`
foo\`); import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; const _REGISTRY = _$$registry(); -const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$getNextElement(_tmpl$), { +const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props => /*@refresh jsx-skip*/_$getNextElement(_tmpl$), { + location: "example.jsx:3:15", + signature: "61dd3182" +}); +const Bar = _$$component(_REGISTRY, "Bar", function Bar() { + return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); +}, { + location: "example.jsx:2:13", + signature: "e93ca257" +}); +const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$getNextElement(_tmpl$2), { location: "example.jsx:8:12", signature: "241c14a4" }); -const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-skip*/_$createComponent(_props4.v0, {}), { +const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-skip*/_$createComponent(Bar, {}), { location: "example.jsx:9:12", - signature: "9a24e06b" + signature: "61d9a109" }); -const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, { - get v0() { - return _props.v0; - } -})], { +const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props2 => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { location: "example.jsx:7:10", - signature: "77f4a4b9" + signature: "5302828d" }); const Foo = _$$component(_REGISTRY, "Foo", function Foo() { - return /*@refresh jsx-skip*/_$createComponent(Foo_1, { - v0: Bar - }); + return /*@refresh jsx-skip*/_$createComponent(Foo_1, {}); }, { location: "example.jsx:5:13", - signature: "2f861eed", - dependencies: () => ({ - Bar - }) -}); -const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props2 => /*@refresh jsx-skip*/_$getNextElement(_tmpl$2), { - location: "example.jsx:3:15", - signature: "fad4daa8" -}); -const Bar = _$$component(_REGISTRY, "Bar", function Bar() { - return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); -}, { - location: "example.jsx:2:13", - signature: "e93ca257" + signature: "c963b907" }); export { Bar }; export { Foo }; @@ -624,7 +615,6 @@ var _tmpl$ = /*#__PURE__*/_$template(\`

\`); import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; -const example = 'Foo'; const _REGISTRY = _$$registry(); const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/(() => { var _el$ = _$getNextElement(_tmpl$); @@ -645,6 +635,7 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { example }) }); +const example = 'Foo'; if (import.meta.webpackHot) { _$$refresh("webpack5", import.meta.webpackHot, _REGISTRY); }" @@ -655,7 +646,6 @@ exports[`webpack5 (client, hydratable) > FunctionDeclaration > should transform import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; -const Example = createContext(); const _REGISTRY = _$$registry(); const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/_$createComponent(_props.v0, { children: "Foo" @@ -676,6 +666,7 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { Example }) }); +const Example = createContext(); if (import.meta.webpackHot) { _$$refresh("webpack5", import.meta.webpackHot, _REGISTRY); }" @@ -685,23 +676,13 @@ exports[`webpack5 (client, hydratable) > FunctionDeclaration > should transform "import { template as _$template } from "solid-js/web"; import { createComponent as _$createComponent } from "solid-js/web"; import { getNextElement as _$getNextElement } from "solid-js/web"; -var _tmpl$ = /*#__PURE__*/_$template(\`
bar\`), - _tmpl$2 = /*#__PURE__*/_$template(\`
foo\`); +var _tmpl$ = /*#__PURE__*/_$template(\`
foo\`), + _tmpl$2 = /*#__PURE__*/_$template(\`
bar\`); import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; const _REGISTRY = _$$registry(); -const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props => /*@refresh jsx-skip*/_$getNextElement(_tmpl$), { - location: "example.jsx:3:15", - signature: "61dd3182" -}); -const Bar = _$$component(_REGISTRY, "Bar", function Bar() { - return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); -}, { - location: "example.jsx:2:6", - signature: "e93ca257" -}); -const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$getNextElement(_tmpl$2), { +const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$getNextElement(_tmpl$), { location: "example.jsx:8:12", signature: "241c14a4" }); @@ -709,9 +690,9 @@ const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-ski location: "example.jsx:9:12", signature: "61d9a109" }); -const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props2 => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { +const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { location: "example.jsx:7:10", - signature: "5302828d" + signature: "825a754d" }); const Foo = _$$component(_REGISTRY, "Foo", function Foo() { return /*@refresh jsx-skip*/_$createComponent(Foo_1, {}); @@ -719,6 +700,16 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { location: "example.jsx:5:6", signature: "c963b907" }); +const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props2 => /*@refresh jsx-skip*/_$getNextElement(_tmpl$2), { + location: "example.jsx:3:15", + signature: "fad4daa8" +}); +const Bar = _$$component(_REGISTRY, "Bar", function Bar() { + return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); +}, { + location: "example.jsx:2:6", + signature: "e93ca257" +}); if (import.meta.webpackHot) { _$$refresh("webpack5", import.meta.webpackHot, _REGISTRY); }" diff --git a/tests/client/__snapshots__/esm.test.ts.snap b/tests/client/__snapshots__/esm.test.ts.snap index 1310076..826ba4b 100644 --- a/tests/client/__snapshots__/esm.test.ts.snap +++ b/tests/client/__snapshots__/esm.test.ts.snap @@ -435,48 +435,39 @@ if (import.meta.hot) { exports[`esm (client, non-hydratable) > ExportNamedDeclaration w/ FunctionExpression > should transform ExportNamedDeclaration w/ FunctionExpression with valid Component name and params 5`] = ` "import { template as _$template } from "solid-js/web"; import { createComponent as _$createComponent } from "solid-js/web"; -var _tmpl$ = /*#__PURE__*/_$template(\`
foo\`), - _tmpl$2 = /*#__PURE__*/_$template(\`
bar\`); +var _tmpl$ = /*#__PURE__*/_$template(\`
bar\`), + _tmpl$2 = /*#__PURE__*/_$template(\`
foo\`); import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; const _REGISTRY = _$$registry(); -const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_tmpl$(), { +const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props => /*@refresh jsx-skip*/_tmpl$(), { + location: "example.jsx:3:15", + signature: "61dd3182" +}); +const Bar = _$$component(_REGISTRY, "Bar", function Bar() { + return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); +}, { + location: "example.jsx:2:13", + signature: "e93ca257" +}); +const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_tmpl$2(), { location: "example.jsx:8:12", signature: "241c14a4" }); -const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-skip*/_$createComponent(_props4.v0, {}), { +const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-skip*/_$createComponent(Bar, {}), { location: "example.jsx:9:12", - signature: "9a24e06b" + signature: "61d9a109" }); -const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, { - get v0() { - return _props.v0; - } -})], { +const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props2 => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { location: "example.jsx:7:10", - signature: "77f4a4b9" + signature: "5302828d" }); const Foo = _$$component(_REGISTRY, "Foo", function Foo() { - return /*@refresh jsx-skip*/_$createComponent(Foo_1, { - v0: Bar - }); + return /*@refresh jsx-skip*/_$createComponent(Foo_1, {}); }, { location: "example.jsx:5:13", - signature: "2f861eed", - dependencies: () => ({ - Bar - }) -}); -const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props2 => /*@refresh jsx-skip*/_tmpl$2(), { - location: "example.jsx:3:15", - signature: "fad4daa8" -}); -const Bar = _$$component(_REGISTRY, "Bar", function Bar() { - return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); -}, { - location: "example.jsx:2:13", - signature: "e93ca257" + signature: "c963b907" }); export { Bar }; export { Foo }; @@ -601,7 +592,6 @@ var _tmpl$ = /*#__PURE__*/_$template(\`

\`); import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; -const example = 'Foo'; const _REGISTRY = _$$registry(); const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/(() => { var _el$ = _tmpl$(); @@ -622,6 +612,7 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { example }) }); +const example = 'Foo'; if (import.meta.hot) { _$$refresh("esm", import.meta.hot, _REGISTRY); }" @@ -632,7 +623,6 @@ exports[`esm (client, non-hydratable) > FunctionDeclaration > should transform F import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; -const Example = createContext(); const _REGISTRY = _$$registry(); const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/_$createComponent(_props.v0, { children: "Foo" @@ -653,6 +643,7 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { Example }) }); +const Example = createContext(); if (import.meta.hot) { _$$refresh("esm", import.meta.hot, _REGISTRY); }" @@ -661,23 +652,13 @@ if (import.meta.hot) { exports[`esm (client, non-hydratable) > FunctionDeclaration > should transform FunctionDeclaration with valid Component name and params 5`] = ` "import { template as _$template } from "solid-js/web"; import { createComponent as _$createComponent } from "solid-js/web"; -var _tmpl$ = /*#__PURE__*/_$template(\`
bar\`), - _tmpl$2 = /*#__PURE__*/_$template(\`
foo\`); +var _tmpl$ = /*#__PURE__*/_$template(\`
foo\`), + _tmpl$2 = /*#__PURE__*/_$template(\`
bar\`); import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; const _REGISTRY = _$$registry(); -const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props => /*@refresh jsx-skip*/_tmpl$(), { - location: "example.jsx:3:15", - signature: "61dd3182" -}); -const Bar = _$$component(_REGISTRY, "Bar", function Bar() { - return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); -}, { - location: "example.jsx:2:6", - signature: "e93ca257" -}); -const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_tmpl$2(), { +const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_tmpl$(), { location: "example.jsx:8:12", signature: "241c14a4" }); @@ -685,9 +666,9 @@ const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-ski location: "example.jsx:9:12", signature: "61d9a109" }); -const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props2 => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { +const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { location: "example.jsx:7:10", - signature: "5302828d" + signature: "825a754d" }); const Foo = _$$component(_REGISTRY, "Foo", function Foo() { return /*@refresh jsx-skip*/_$createComponent(Foo_1, {}); @@ -695,6 +676,16 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { location: "example.jsx:5:6", signature: "c963b907" }); +const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props2 => /*@refresh jsx-skip*/_tmpl$2(), { + location: "example.jsx:3:15", + signature: "fad4daa8" +}); +const Bar = _$$component(_REGISTRY, "Bar", function Bar() { + return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); +}, { + location: "example.jsx:2:6", + signature: "e93ca257" +}); if (import.meta.hot) { _$$refresh("esm", import.meta.hot, _REGISTRY); }" diff --git a/tests/client/__snapshots__/rspack-esm.test.ts.snap b/tests/client/__snapshots__/rspack-esm.test.ts.snap index 0312760..e44e7f2 100644 --- a/tests/client/__snapshots__/rspack-esm.test.ts.snap +++ b/tests/client/__snapshots__/rspack-esm.test.ts.snap @@ -435,48 +435,39 @@ if (import.meta.webpackHot) { exports[`rspack-esm (client, non-hydratable) > ExportNamedDeclaration w/ FunctionExpression > should transform ExportNamedDeclaration w/ FunctionExpression with valid Component name and params 5`] = ` "import { template as _$template } from "solid-js/web"; import { createComponent as _$createComponent } from "solid-js/web"; -var _tmpl$ = /*#__PURE__*/_$template(\`
foo\`), - _tmpl$2 = /*#__PURE__*/_$template(\`
bar\`); +var _tmpl$ = /*#__PURE__*/_$template(\`
bar\`), + _tmpl$2 = /*#__PURE__*/_$template(\`
foo\`); import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; const _REGISTRY = _$$registry(); -const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_tmpl$(), { +const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props => /*@refresh jsx-skip*/_tmpl$(), { + location: "example.jsx:3:15", + signature: "61dd3182" +}); +const Bar = _$$component(_REGISTRY, "Bar", function Bar() { + return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); +}, { + location: "example.jsx:2:13", + signature: "e93ca257" +}); +const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_tmpl$2(), { location: "example.jsx:8:12", signature: "241c14a4" }); -const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-skip*/_$createComponent(_props4.v0, {}), { +const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-skip*/_$createComponent(Bar, {}), { location: "example.jsx:9:12", - signature: "9a24e06b" + signature: "61d9a109" }); -const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, { - get v0() { - return _props.v0; - } -})], { +const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props2 => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { location: "example.jsx:7:10", - signature: "77f4a4b9" + signature: "5302828d" }); const Foo = _$$component(_REGISTRY, "Foo", function Foo() { - return /*@refresh jsx-skip*/_$createComponent(Foo_1, { - v0: Bar - }); + return /*@refresh jsx-skip*/_$createComponent(Foo_1, {}); }, { location: "example.jsx:5:13", - signature: "2f861eed", - dependencies: () => ({ - Bar - }) -}); -const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props2 => /*@refresh jsx-skip*/_tmpl$2(), { - location: "example.jsx:3:15", - signature: "fad4daa8" -}); -const Bar = _$$component(_REGISTRY, "Bar", function Bar() { - return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); -}, { - location: "example.jsx:2:13", - signature: "e93ca257" + signature: "c963b907" }); export { Bar }; export { Foo }; @@ -601,7 +592,6 @@ var _tmpl$ = /*#__PURE__*/_$template(\`

\`); import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; -const example = 'Foo'; const _REGISTRY = _$$registry(); const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/(() => { var _el$ = _tmpl$(); @@ -622,6 +612,7 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { example }) }); +const example = 'Foo'; if (import.meta.webpackHot) { _$$refresh("rspack-esm", import.meta.webpackHot, _REGISTRY); }" @@ -632,7 +623,6 @@ exports[`rspack-esm (client, non-hydratable) > FunctionDeclaration > should tran import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; -const Example = createContext(); const _REGISTRY = _$$registry(); const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/_$createComponent(_props.v0, { children: "Foo" @@ -653,6 +643,7 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { Example }) }); +const Example = createContext(); if (import.meta.webpackHot) { _$$refresh("rspack-esm", import.meta.webpackHot, _REGISTRY); }" @@ -661,23 +652,13 @@ if (import.meta.webpackHot) { exports[`rspack-esm (client, non-hydratable) > FunctionDeclaration > should transform FunctionDeclaration with valid Component name and params 5`] = ` "import { template as _$template } from "solid-js/web"; import { createComponent as _$createComponent } from "solid-js/web"; -var _tmpl$ = /*#__PURE__*/_$template(\`
bar\`), - _tmpl$2 = /*#__PURE__*/_$template(\`
foo\`); +var _tmpl$ = /*#__PURE__*/_$template(\`
foo\`), + _tmpl$2 = /*#__PURE__*/_$template(\`
bar\`); import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; const _REGISTRY = _$$registry(); -const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props => /*@refresh jsx-skip*/_tmpl$(), { - location: "example.jsx:3:15", - signature: "61dd3182" -}); -const Bar = _$$component(_REGISTRY, "Bar", function Bar() { - return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); -}, { - location: "example.jsx:2:6", - signature: "e93ca257" -}); -const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_tmpl$2(), { +const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_tmpl$(), { location: "example.jsx:8:12", signature: "241c14a4" }); @@ -685,9 +666,9 @@ const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-ski location: "example.jsx:9:12", signature: "61d9a109" }); -const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props2 => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { +const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { location: "example.jsx:7:10", - signature: "5302828d" + signature: "825a754d" }); const Foo = _$$component(_REGISTRY, "Foo", function Foo() { return /*@refresh jsx-skip*/_$createComponent(Foo_1, {}); @@ -695,6 +676,16 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { location: "example.jsx:5:6", signature: "c963b907" }); +const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props2 => /*@refresh jsx-skip*/_tmpl$2(), { + location: "example.jsx:3:15", + signature: "fad4daa8" +}); +const Bar = _$$component(_REGISTRY, "Bar", function Bar() { + return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); +}, { + location: "example.jsx:2:6", + signature: "e93ca257" +}); if (import.meta.webpackHot) { _$$refresh("rspack-esm", import.meta.webpackHot, _REGISTRY); }" diff --git a/tests/client/__snapshots__/standard.test.ts.snap b/tests/client/__snapshots__/standard.test.ts.snap index 9fd2622..480d636 100644 --- a/tests/client/__snapshots__/standard.test.ts.snap +++ b/tests/client/__snapshots__/standard.test.ts.snap @@ -435,48 +435,39 @@ if (module.hot) { exports[`standard (client, non-hydratable) > ExportNamedDeclaration w/ FunctionExpression > should transform ExportNamedDeclaration w/ FunctionExpression with valid Component name and params 5`] = ` "import { template as _$template } from "solid-js/web"; import { createComponent as _$createComponent } from "solid-js/web"; -var _tmpl$ = /*#__PURE__*/_$template(\`
foo\`), - _tmpl$2 = /*#__PURE__*/_$template(\`
bar\`); +var _tmpl$ = /*#__PURE__*/_$template(\`
bar\`), + _tmpl$2 = /*#__PURE__*/_$template(\`
foo\`); import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; const _REGISTRY = _$$registry(); -const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_tmpl$(), { +const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props => /*@refresh jsx-skip*/_tmpl$(), { + location: "example.jsx:3:15", + signature: "61dd3182" +}); +const Bar = _$$component(_REGISTRY, "Bar", function Bar() { + return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); +}, { + location: "example.jsx:2:13", + signature: "e93ca257" +}); +const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_tmpl$2(), { location: "example.jsx:8:12", signature: "241c14a4" }); -const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-skip*/_$createComponent(_props4.v0, {}), { +const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-skip*/_$createComponent(Bar, {}), { location: "example.jsx:9:12", - signature: "9a24e06b" + signature: "61d9a109" }); -const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, { - get v0() { - return _props.v0; - } -})], { +const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props2 => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { location: "example.jsx:7:10", - signature: "77f4a4b9" + signature: "5302828d" }); const Foo = _$$component(_REGISTRY, "Foo", function Foo() { - return /*@refresh jsx-skip*/_$createComponent(Foo_1, { - v0: Bar - }); + return /*@refresh jsx-skip*/_$createComponent(Foo_1, {}); }, { location: "example.jsx:5:13", - signature: "2f861eed", - dependencies: () => ({ - Bar - }) -}); -const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props2 => /*@refresh jsx-skip*/_tmpl$2(), { - location: "example.jsx:3:15", - signature: "fad4daa8" -}); -const Bar = _$$component(_REGISTRY, "Bar", function Bar() { - return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); -}, { - location: "example.jsx:2:13", - signature: "e93ca257" + signature: "c963b907" }); export { Bar }; export { Foo }; @@ -601,7 +592,6 @@ var _tmpl$ = /*#__PURE__*/_$template(\`

\`); import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; -const example = 'Foo'; const _REGISTRY = _$$registry(); const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/(() => { var _el$ = _tmpl$(); @@ -622,6 +612,7 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { example }) }); +const example = 'Foo'; if (module.hot) { _$$refresh("standard", module.hot, _REGISTRY); }" @@ -632,7 +623,6 @@ exports[`standard (client, non-hydratable) > FunctionDeclaration > should transf import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; -const Example = createContext(); const _REGISTRY = _$$registry(); const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/_$createComponent(_props.v0, { children: "Foo" @@ -653,6 +643,7 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { Example }) }); +const Example = createContext(); if (module.hot) { _$$refresh("standard", module.hot, _REGISTRY); }" @@ -661,23 +652,13 @@ if (module.hot) { exports[`standard (client, non-hydratable) > FunctionDeclaration > should transform FunctionDeclaration with valid Component name and params 5`] = ` "import { template as _$template } from "solid-js/web"; import { createComponent as _$createComponent } from "solid-js/web"; -var _tmpl$ = /*#__PURE__*/_$template(\`
bar\`), - _tmpl$2 = /*#__PURE__*/_$template(\`
foo\`); +var _tmpl$ = /*#__PURE__*/_$template(\`
foo\`), + _tmpl$2 = /*#__PURE__*/_$template(\`
bar\`); import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; const _REGISTRY = _$$registry(); -const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props => /*@refresh jsx-skip*/_tmpl$(), { - location: "example.jsx:3:15", - signature: "61dd3182" -}); -const Bar = _$$component(_REGISTRY, "Bar", function Bar() { - return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); -}, { - location: "example.jsx:2:6", - signature: "e93ca257" -}); -const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_tmpl$2(), { +const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_tmpl$(), { location: "example.jsx:8:12", signature: "241c14a4" }); @@ -685,9 +666,9 @@ const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-ski location: "example.jsx:9:12", signature: "61d9a109" }); -const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props2 => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { +const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { location: "example.jsx:7:10", - signature: "5302828d" + signature: "825a754d" }); const Foo = _$$component(_REGISTRY, "Foo", function Foo() { return /*@refresh jsx-skip*/_$createComponent(Foo_1, {}); @@ -695,6 +676,16 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { location: "example.jsx:5:6", signature: "c963b907" }); +const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props2 => /*@refresh jsx-skip*/_tmpl$2(), { + location: "example.jsx:3:15", + signature: "fad4daa8" +}); +const Bar = _$$component(_REGISTRY, "Bar", function Bar() { + return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); +}, { + location: "example.jsx:2:6", + signature: "e93ca257" +}); if (module.hot) { _$$refresh("standard", module.hot, _REGISTRY); }" diff --git a/tests/client/__snapshots__/vite.test.ts.snap b/tests/client/__snapshots__/vite.test.ts.snap index 369004e..74dab89 100644 --- a/tests/client/__snapshots__/vite.test.ts.snap +++ b/tests/client/__snapshots__/vite.test.ts.snap @@ -448,48 +448,39 @@ if (import.meta.hot) { exports[`vite (client, non-hydratable) > ExportNamedDeclaration w/ FunctionExpression > should transform ExportNamedDeclaration w/ FunctionExpression with valid Component name and params 5`] = ` "import { template as _$template } from "solid-js/web"; import { createComponent as _$createComponent } from "solid-js/web"; -var _tmpl$ = /*#__PURE__*/_$template(\`
foo\`), - _tmpl$2 = /*#__PURE__*/_$template(\`
bar\`); +var _tmpl$ = /*#__PURE__*/_$template(\`
bar\`), + _tmpl$2 = /*#__PURE__*/_$template(\`
foo\`); import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; const _REGISTRY = _$$registry(); -const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_tmpl$(), { +const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props => /*@refresh jsx-skip*/_tmpl$(), { + location: "example.jsx:3:15", + signature: "61dd3182" +}); +const Bar = _$$component(_REGISTRY, "Bar", function Bar() { + return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); +}, { + location: "example.jsx:2:13", + signature: "e93ca257" +}); +const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_tmpl$2(), { location: "example.jsx:8:12", signature: "241c14a4" }); -const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-skip*/_$createComponent(_props4.v0, {}), { +const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-skip*/_$createComponent(Bar, {}), { location: "example.jsx:9:12", - signature: "9a24e06b" + signature: "61d9a109" }); -const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, { - get v0() { - return _props.v0; - } -})], { +const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props2 => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { location: "example.jsx:7:10", - signature: "77f4a4b9" + signature: "5302828d" }); const Foo = _$$component(_REGISTRY, "Foo", function Foo() { - return /*@refresh jsx-skip*/_$createComponent(Foo_1, { - v0: Bar - }); + return /*@refresh jsx-skip*/_$createComponent(Foo_1, {}); }, { location: "example.jsx:5:13", - signature: "2f861eed", - dependencies: () => ({ - Bar - }) -}); -const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props2 => /*@refresh jsx-skip*/_tmpl$2(), { - location: "example.jsx:3:15", - signature: "fad4daa8" -}); -const Bar = _$$component(_REGISTRY, "Bar", function Bar() { - return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); -}, { - location: "example.jsx:2:13", - signature: "e93ca257" + signature: "c963b907" }); export { Bar }; export { Foo }; @@ -618,7 +609,6 @@ var _tmpl$ = /*#__PURE__*/_$template(\`

\`); import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; -const example = 'Foo'; const _REGISTRY = _$$registry(); const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/(() => { var _el$ = _tmpl$(); @@ -639,6 +629,7 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { example }) }); +const example = 'Foo'; if (import.meta.hot) { import.meta.hot.accept(); _$$refresh("vite", import.meta.hot, _REGISTRY); @@ -650,7 +641,6 @@ exports[`vite (client, non-hydratable) > FunctionDeclaration > should transform import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; -const Example = createContext(); const _REGISTRY = _$$registry(); const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/_$createComponent(_props.v0, { children: "Foo" @@ -671,6 +661,7 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { Example }) }); +const Example = createContext(); if (import.meta.hot) { import.meta.hot.accept(); _$$refresh("vite", import.meta.hot, _REGISTRY); @@ -680,23 +671,13 @@ if (import.meta.hot) { exports[`vite (client, non-hydratable) > FunctionDeclaration > should transform FunctionDeclaration with valid Component name and params 5`] = ` "import { template as _$template } from "solid-js/web"; import { createComponent as _$createComponent } from "solid-js/web"; -var _tmpl$ = /*#__PURE__*/_$template(\`
bar\`), - _tmpl$2 = /*#__PURE__*/_$template(\`
foo\`); +var _tmpl$ = /*#__PURE__*/_$template(\`
foo\`), + _tmpl$2 = /*#__PURE__*/_$template(\`
bar\`); import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; const _REGISTRY = _$$registry(); -const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props => /*@refresh jsx-skip*/_tmpl$(), { - location: "example.jsx:3:15", - signature: "61dd3182" -}); -const Bar = _$$component(_REGISTRY, "Bar", function Bar() { - return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); -}, { - location: "example.jsx:2:6", - signature: "e93ca257" -}); -const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_tmpl$2(), { +const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_tmpl$(), { location: "example.jsx:8:12", signature: "241c14a4" }); @@ -704,9 +685,9 @@ const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-ski location: "example.jsx:9:12", signature: "61d9a109" }); -const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props2 => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { +const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { location: "example.jsx:7:10", - signature: "5302828d" + signature: "825a754d" }); const Foo = _$$component(_REGISTRY, "Foo", function Foo() { return /*@refresh jsx-skip*/_$createComponent(Foo_1, {}); @@ -714,6 +695,16 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { location: "example.jsx:5:6", signature: "c963b907" }); +const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props2 => /*@refresh jsx-skip*/_tmpl$2(), { + location: "example.jsx:3:15", + signature: "fad4daa8" +}); +const Bar = _$$component(_REGISTRY, "Bar", function Bar() { + return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); +}, { + location: "example.jsx:2:6", + signature: "e93ca257" +}); if (import.meta.hot) { import.meta.hot.accept(); _$$refresh("vite", import.meta.hot, _REGISTRY); diff --git a/tests/client/__snapshots__/webpack5.test.ts.snap b/tests/client/__snapshots__/webpack5.test.ts.snap index 8ee02cf..45420d3 100644 --- a/tests/client/__snapshots__/webpack5.test.ts.snap +++ b/tests/client/__snapshots__/webpack5.test.ts.snap @@ -435,48 +435,39 @@ if (import.meta.webpackHot) { exports[`webpack5 (client, non-hydratable) > ExportNamedDeclaration w/ FunctionExpression > should transform ExportNamedDeclaration w/ FunctionExpression with valid Component name and params 5`] = ` "import { template as _$template } from "solid-js/web"; import { createComponent as _$createComponent } from "solid-js/web"; -var _tmpl$ = /*#__PURE__*/_$template(\`
foo\`), - _tmpl$2 = /*#__PURE__*/_$template(\`
bar\`); +var _tmpl$ = /*#__PURE__*/_$template(\`
bar\`), + _tmpl$2 = /*#__PURE__*/_$template(\`
foo\`); import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; const _REGISTRY = _$$registry(); -const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_tmpl$(), { +const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props => /*@refresh jsx-skip*/_tmpl$(), { + location: "example.jsx:3:15", + signature: "61dd3182" +}); +const Bar = _$$component(_REGISTRY, "Bar", function Bar() { + return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); +}, { + location: "example.jsx:2:13", + signature: "e93ca257" +}); +const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_tmpl$2(), { location: "example.jsx:8:12", signature: "241c14a4" }); -const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-skip*/_$createComponent(_props4.v0, {}), { +const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-skip*/_$createComponent(Bar, {}), { location: "example.jsx:9:12", - signature: "9a24e06b" + signature: "61d9a109" }); -const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, { - get v0() { - return _props.v0; - } -})], { +const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props2 => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { location: "example.jsx:7:10", - signature: "77f4a4b9" + signature: "5302828d" }); const Foo = _$$component(_REGISTRY, "Foo", function Foo() { - return /*@refresh jsx-skip*/_$createComponent(Foo_1, { - v0: Bar - }); + return /*@refresh jsx-skip*/_$createComponent(Foo_1, {}); }, { location: "example.jsx:5:13", - signature: "2f861eed", - dependencies: () => ({ - Bar - }) -}); -const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props2 => /*@refresh jsx-skip*/_tmpl$2(), { - location: "example.jsx:3:15", - signature: "fad4daa8" -}); -const Bar = _$$component(_REGISTRY, "Bar", function Bar() { - return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); -}, { - location: "example.jsx:2:13", - signature: "e93ca257" + signature: "c963b907" }); export { Bar }; export { Foo }; @@ -601,7 +592,6 @@ var _tmpl$ = /*#__PURE__*/_$template(\`

\`); import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; -const example = 'Foo'; const _REGISTRY = _$$registry(); const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/(() => { var _el$ = _tmpl$(); @@ -622,6 +612,7 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { example }) }); +const example = 'Foo'; if (import.meta.webpackHot) { _$$refresh("webpack5", import.meta.webpackHot, _REGISTRY); }" @@ -632,7 +623,6 @@ exports[`webpack5 (client, non-hydratable) > FunctionDeclaration > should transf import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; -const Example = createContext(); const _REGISTRY = _$$registry(); const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/_$createComponent(_props.v0, { children: "Foo" @@ -653,6 +643,7 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { Example }) }); +const Example = createContext(); if (import.meta.webpackHot) { _$$refresh("webpack5", import.meta.webpackHot, _REGISTRY); }" @@ -661,23 +652,13 @@ if (import.meta.webpackHot) { exports[`webpack5 (client, non-hydratable) > FunctionDeclaration > should transform FunctionDeclaration with valid Component name and params 5`] = ` "import { template as _$template } from "solid-js/web"; import { createComponent as _$createComponent } from "solid-js/web"; -var _tmpl$ = /*#__PURE__*/_$template(\`
bar\`), - _tmpl$2 = /*#__PURE__*/_$template(\`
foo\`); +var _tmpl$ = /*#__PURE__*/_$template(\`
foo\`), + _tmpl$2 = /*#__PURE__*/_$template(\`
bar\`); import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; const _REGISTRY = _$$registry(); -const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props => /*@refresh jsx-skip*/_tmpl$(), { - location: "example.jsx:3:15", - signature: "61dd3182" -}); -const Bar = _$$component(_REGISTRY, "Bar", function Bar() { - return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); -}, { - location: "example.jsx:2:6", - signature: "e93ca257" -}); -const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_tmpl$2(), { +const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_tmpl$(), { location: "example.jsx:8:12", signature: "241c14a4" }); @@ -685,9 +666,9 @@ const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-ski location: "example.jsx:9:12", signature: "61d9a109" }); -const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props2 => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { +const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { location: "example.jsx:7:10", - signature: "5302828d" + signature: "825a754d" }); const Foo = _$$component(_REGISTRY, "Foo", function Foo() { return /*@refresh jsx-skip*/_$createComponent(Foo_1, {}); @@ -695,6 +676,16 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { location: "example.jsx:5:6", signature: "c963b907" }); +const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props2 => /*@refresh jsx-skip*/_tmpl$2(), { + location: "example.jsx:3:15", + signature: "fad4daa8" +}); +const Bar = _$$component(_REGISTRY, "Bar", function Bar() { + return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); +}, { + location: "example.jsx:2:6", + signature: "e93ca257" +}); if (import.meta.webpackHot) { _$$refresh("webpack5", import.meta.webpackHot, _REGISTRY); }" diff --git a/tests/server-hydratable/__snapshots__/esm.test.ts.snap b/tests/server-hydratable/__snapshots__/esm.test.ts.snap index 2faec29..82ec9ae 100644 --- a/tests/server-hydratable/__snapshots__/esm.test.ts.snap +++ b/tests/server-hydratable/__snapshots__/esm.test.ts.snap @@ -443,48 +443,39 @@ exports[`esm (server, hydratable) > ExportNamedDeclaration w/ FunctionExpression "import { createComponent as _$createComponent } from "solid-js/web"; import { ssr as _$ssr } from "solid-js/web"; import { ssrHydrationKey as _$ssrHydrationKey } from "solid-js/web"; -var _tmpl$ = ["foo
"], - _tmpl$2 = ["bar
"]; +var _tmpl$ = ["bar
"], + _tmpl$2 = ["foo
"]; import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; const _REGISTRY = _$$registry(); -const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$ssr(_tmpl$, _$ssrHydrationKey()), { +const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props => /*@refresh jsx-skip*/_$ssr(_tmpl$, _$ssrHydrationKey()), { + location: "example.jsx:3:15", + signature: "61dd3182" +}); +const Bar = _$$component(_REGISTRY, "Bar", function Bar() { + return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); +}, { + location: "example.jsx:2:13", + signature: "e93ca257" +}); +const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$ssr(_tmpl$2, _$ssrHydrationKey()), { location: "example.jsx:8:12", signature: "241c14a4" }); -const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-skip*/_$createComponent(_props4.v0, {}), { +const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-skip*/_$createComponent(Bar, {}), { location: "example.jsx:9:12", - signature: "9a24e06b" + signature: "61d9a109" }); -const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, { - get v0() { - return _props.v0; - } -})], { +const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props2 => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { location: "example.jsx:7:10", - signature: "77f4a4b9" + signature: "5302828d" }); const Foo = _$$component(_REGISTRY, "Foo", function Foo() { - return /*@refresh jsx-skip*/_$createComponent(Foo_1, { - v0: Bar - }); + return /*@refresh jsx-skip*/_$createComponent(Foo_1, {}); }, { location: "example.jsx:5:13", - signature: "2f861eed", - dependencies: () => ({ - Bar - }) -}); -const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props2 => /*@refresh jsx-skip*/_$ssr(_tmpl$2, _$ssrHydrationKey()), { - location: "example.jsx:3:15", - signature: "fad4daa8" -}); -const Bar = _$$component(_REGISTRY, "Bar", function Bar() { - return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); -}, { - location: "example.jsx:2:13", - signature: "e93ca257" + signature: "c963b907" }); export { Bar }; export { Foo }; @@ -616,7 +607,6 @@ var _tmpl$ = ["", "

"]; import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; -const example = 'Foo'; const _REGISTRY = _$$registry(); const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/_$ssr(_tmpl$, _$ssrHydrationKey(), _$escape(_props.v0)), { location: "example.jsx:4:15", @@ -633,6 +623,7 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { example }) }); +const example = 'Foo'; if (import.meta.hot) { _$$refresh("esm", import.meta.hot, _REGISTRY); }" @@ -643,7 +634,6 @@ exports[`esm (server, hydratable) > FunctionDeclaration > should transform Funct import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; -const Example = createContext(); const _REGISTRY = _$$registry(); const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/_$createComponent(_props.v0, { children: "Foo" @@ -664,6 +654,7 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { Example }) }); +const Example = createContext(); if (import.meta.hot) { _$$refresh("esm", import.meta.hot, _REGISTRY); }" @@ -673,23 +664,13 @@ exports[`esm (server, hydratable) > FunctionDeclaration > should transform Funct "import { createComponent as _$createComponent } from "solid-js/web"; import { ssr as _$ssr } from "solid-js/web"; import { ssrHydrationKey as _$ssrHydrationKey } from "solid-js/web"; -var _tmpl$ = ["bar
"], - _tmpl$2 = ["foo
"]; +var _tmpl$ = ["foo
"], + _tmpl$2 = ["bar
"]; import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; const _REGISTRY = _$$registry(); -const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props => /*@refresh jsx-skip*/_$ssr(_tmpl$, _$ssrHydrationKey()), { - location: "example.jsx:3:15", - signature: "61dd3182" -}); -const Bar = _$$component(_REGISTRY, "Bar", function Bar() { - return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); -}, { - location: "example.jsx:2:6", - signature: "e93ca257" -}); -const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$ssr(_tmpl$2, _$ssrHydrationKey()), { +const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$ssr(_tmpl$, _$ssrHydrationKey()), { location: "example.jsx:8:12", signature: "241c14a4" }); @@ -697,9 +678,9 @@ const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-ski location: "example.jsx:9:12", signature: "61d9a109" }); -const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props2 => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { +const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { location: "example.jsx:7:10", - signature: "5302828d" + signature: "825a754d" }); const Foo = _$$component(_REGISTRY, "Foo", function Foo() { return /*@refresh jsx-skip*/_$createComponent(Foo_1, {}); @@ -707,6 +688,16 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { location: "example.jsx:5:6", signature: "c963b907" }); +const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props2 => /*@refresh jsx-skip*/_$ssr(_tmpl$2, _$ssrHydrationKey()), { + location: "example.jsx:3:15", + signature: "fad4daa8" +}); +const Bar = _$$component(_REGISTRY, "Bar", function Bar() { + return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); +}, { + location: "example.jsx:2:6", + signature: "e93ca257" +}); if (import.meta.hot) { _$$refresh("esm", import.meta.hot, _REGISTRY); }" diff --git a/tests/server-hydratable/__snapshots__/rspack-esm.test.ts.snap b/tests/server-hydratable/__snapshots__/rspack-esm.test.ts.snap index 5dcd159..c340374 100644 --- a/tests/server-hydratable/__snapshots__/rspack-esm.test.ts.snap +++ b/tests/server-hydratable/__snapshots__/rspack-esm.test.ts.snap @@ -443,48 +443,39 @@ exports[`esm (server, hydratable) > ExportNamedDeclaration w/ FunctionExpression "import { createComponent as _$createComponent } from "solid-js/web"; import { ssr as _$ssr } from "solid-js/web"; import { ssrHydrationKey as _$ssrHydrationKey } from "solid-js/web"; -var _tmpl$ = ["foo
"], - _tmpl$2 = ["bar
"]; +var _tmpl$ = ["bar
"], + _tmpl$2 = ["foo
"]; import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; const _REGISTRY = _$$registry(); -const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$ssr(_tmpl$, _$ssrHydrationKey()), { +const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props => /*@refresh jsx-skip*/_$ssr(_tmpl$, _$ssrHydrationKey()), { + location: "example.jsx:3:15", + signature: "61dd3182" +}); +const Bar = _$$component(_REGISTRY, "Bar", function Bar() { + return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); +}, { + location: "example.jsx:2:13", + signature: "e93ca257" +}); +const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$ssr(_tmpl$2, _$ssrHydrationKey()), { location: "example.jsx:8:12", signature: "241c14a4" }); -const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-skip*/_$createComponent(_props4.v0, {}), { +const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-skip*/_$createComponent(Bar, {}), { location: "example.jsx:9:12", - signature: "9a24e06b" + signature: "61d9a109" }); -const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, { - get v0() { - return _props.v0; - } -})], { +const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props2 => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { location: "example.jsx:7:10", - signature: "77f4a4b9" + signature: "5302828d" }); const Foo = _$$component(_REGISTRY, "Foo", function Foo() { - return /*@refresh jsx-skip*/_$createComponent(Foo_1, { - v0: Bar - }); + return /*@refresh jsx-skip*/_$createComponent(Foo_1, {}); }, { location: "example.jsx:5:13", - signature: "2f861eed", - dependencies: () => ({ - Bar - }) -}); -const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props2 => /*@refresh jsx-skip*/_$ssr(_tmpl$2, _$ssrHydrationKey()), { - location: "example.jsx:3:15", - signature: "fad4daa8" -}); -const Bar = _$$component(_REGISTRY, "Bar", function Bar() { - return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); -}, { - location: "example.jsx:2:13", - signature: "e93ca257" + signature: "c963b907" }); export { Bar }; export { Foo }; @@ -616,7 +607,6 @@ var _tmpl$ = ["", "

"]; import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; -const example = 'Foo'; const _REGISTRY = _$$registry(); const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/_$ssr(_tmpl$, _$ssrHydrationKey(), _$escape(_props.v0)), { location: "example.jsx:4:15", @@ -633,6 +623,7 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { example }) }); +const example = 'Foo'; if (import.meta.hot) { _$$refresh("esm", import.meta.hot, _REGISTRY); }" @@ -643,7 +634,6 @@ exports[`esm (server, hydratable) > FunctionDeclaration > should transform Funct import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; -const Example = createContext(); const _REGISTRY = _$$registry(); const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/_$createComponent(_props.v0, { children: "Foo" @@ -664,6 +654,7 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { Example }) }); +const Example = createContext(); if (import.meta.hot) { _$$refresh("esm", import.meta.hot, _REGISTRY); }" @@ -673,23 +664,13 @@ exports[`esm (server, hydratable) > FunctionDeclaration > should transform Funct "import { createComponent as _$createComponent } from "solid-js/web"; import { ssr as _$ssr } from "solid-js/web"; import { ssrHydrationKey as _$ssrHydrationKey } from "solid-js/web"; -var _tmpl$ = ["bar
"], - _tmpl$2 = ["foo
"]; +var _tmpl$ = ["foo
"], + _tmpl$2 = ["bar
"]; import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; const _REGISTRY = _$$registry(); -const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props => /*@refresh jsx-skip*/_$ssr(_tmpl$, _$ssrHydrationKey()), { - location: "example.jsx:3:15", - signature: "61dd3182" -}); -const Bar = _$$component(_REGISTRY, "Bar", function Bar() { - return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); -}, { - location: "example.jsx:2:6", - signature: "e93ca257" -}); -const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$ssr(_tmpl$2, _$ssrHydrationKey()), { +const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$ssr(_tmpl$, _$ssrHydrationKey()), { location: "example.jsx:8:12", signature: "241c14a4" }); @@ -697,9 +678,9 @@ const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-ski location: "example.jsx:9:12", signature: "61d9a109" }); -const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props2 => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { +const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { location: "example.jsx:7:10", - signature: "5302828d" + signature: "825a754d" }); const Foo = _$$component(_REGISTRY, "Foo", function Foo() { return /*@refresh jsx-skip*/_$createComponent(Foo_1, {}); @@ -707,6 +688,16 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { location: "example.jsx:5:6", signature: "c963b907" }); +const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props2 => /*@refresh jsx-skip*/_$ssr(_tmpl$2, _$ssrHydrationKey()), { + location: "example.jsx:3:15", + signature: "fad4daa8" +}); +const Bar = _$$component(_REGISTRY, "Bar", function Bar() { + return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); +}, { + location: "example.jsx:2:6", + signature: "e93ca257" +}); if (import.meta.hot) { _$$refresh("esm", import.meta.hot, _REGISTRY); }" diff --git a/tests/server-hydratable/__snapshots__/standard.test.ts.snap b/tests/server-hydratable/__snapshots__/standard.test.ts.snap index 3636a11..d537390 100644 --- a/tests/server-hydratable/__snapshots__/standard.test.ts.snap +++ b/tests/server-hydratable/__snapshots__/standard.test.ts.snap @@ -443,48 +443,39 @@ exports[`standard (server, hydratable) > ExportNamedDeclaration w/ FunctionExpre "import { createComponent as _$createComponent } from "solid-js/web"; import { ssr as _$ssr } from "solid-js/web"; import { ssrHydrationKey as _$ssrHydrationKey } from "solid-js/web"; -var _tmpl$ = ["foo
"], - _tmpl$2 = ["bar
"]; +var _tmpl$ = ["bar
"], + _tmpl$2 = ["foo
"]; import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; const _REGISTRY = _$$registry(); -const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$ssr(_tmpl$, _$ssrHydrationKey()), { +const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props => /*@refresh jsx-skip*/_$ssr(_tmpl$, _$ssrHydrationKey()), { + location: "example.jsx:3:15", + signature: "61dd3182" +}); +const Bar = _$$component(_REGISTRY, "Bar", function Bar() { + return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); +}, { + location: "example.jsx:2:13", + signature: "e93ca257" +}); +const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$ssr(_tmpl$2, _$ssrHydrationKey()), { location: "example.jsx:8:12", signature: "241c14a4" }); -const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-skip*/_$createComponent(_props4.v0, {}), { +const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-skip*/_$createComponent(Bar, {}), { location: "example.jsx:9:12", - signature: "9a24e06b" + signature: "61d9a109" }); -const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, { - get v0() { - return _props.v0; - } -})], { +const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props2 => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { location: "example.jsx:7:10", - signature: "77f4a4b9" + signature: "5302828d" }); const Foo = _$$component(_REGISTRY, "Foo", function Foo() { - return /*@refresh jsx-skip*/_$createComponent(Foo_1, { - v0: Bar - }); + return /*@refresh jsx-skip*/_$createComponent(Foo_1, {}); }, { location: "example.jsx:5:13", - signature: "2f861eed", - dependencies: () => ({ - Bar - }) -}); -const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props2 => /*@refresh jsx-skip*/_$ssr(_tmpl$2, _$ssrHydrationKey()), { - location: "example.jsx:3:15", - signature: "fad4daa8" -}); -const Bar = _$$component(_REGISTRY, "Bar", function Bar() { - return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); -}, { - location: "example.jsx:2:13", - signature: "e93ca257" + signature: "c963b907" }); export { Bar }; export { Foo }; @@ -616,7 +607,6 @@ var _tmpl$ = ["", "

"]; import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; -const example = 'Foo'; const _REGISTRY = _$$registry(); const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/_$ssr(_tmpl$, _$ssrHydrationKey(), _$escape(_props.v0)), { location: "example.jsx:4:15", @@ -633,6 +623,7 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { example }) }); +const example = 'Foo'; if (module.hot) { _$$refresh("standard", module.hot, _REGISTRY); }" @@ -643,7 +634,6 @@ exports[`standard (server, hydratable) > FunctionDeclaration > should transform import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; -const Example = createContext(); const _REGISTRY = _$$registry(); const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/_$createComponent(_props.v0, { children: "Foo" @@ -664,6 +654,7 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { Example }) }); +const Example = createContext(); if (module.hot) { _$$refresh("standard", module.hot, _REGISTRY); }" @@ -673,23 +664,13 @@ exports[`standard (server, hydratable) > FunctionDeclaration > should transform "import { createComponent as _$createComponent } from "solid-js/web"; import { ssr as _$ssr } from "solid-js/web"; import { ssrHydrationKey as _$ssrHydrationKey } from "solid-js/web"; -var _tmpl$ = ["bar
"], - _tmpl$2 = ["foo
"]; +var _tmpl$ = ["foo
"], + _tmpl$2 = ["bar
"]; import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; const _REGISTRY = _$$registry(); -const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props => /*@refresh jsx-skip*/_$ssr(_tmpl$, _$ssrHydrationKey()), { - location: "example.jsx:3:15", - signature: "61dd3182" -}); -const Bar = _$$component(_REGISTRY, "Bar", function Bar() { - return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); -}, { - location: "example.jsx:2:6", - signature: "e93ca257" -}); -const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$ssr(_tmpl$2, _$ssrHydrationKey()), { +const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$ssr(_tmpl$, _$ssrHydrationKey()), { location: "example.jsx:8:12", signature: "241c14a4" }); @@ -697,9 +678,9 @@ const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-ski location: "example.jsx:9:12", signature: "61d9a109" }); -const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props2 => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { +const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { location: "example.jsx:7:10", - signature: "5302828d" + signature: "825a754d" }); const Foo = _$$component(_REGISTRY, "Foo", function Foo() { return /*@refresh jsx-skip*/_$createComponent(Foo_1, {}); @@ -707,6 +688,16 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { location: "example.jsx:5:6", signature: "c963b907" }); +const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props2 => /*@refresh jsx-skip*/_$ssr(_tmpl$2, _$ssrHydrationKey()), { + location: "example.jsx:3:15", + signature: "fad4daa8" +}); +const Bar = _$$component(_REGISTRY, "Bar", function Bar() { + return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); +}, { + location: "example.jsx:2:6", + signature: "e93ca257" +}); if (module.hot) { _$$refresh("standard", module.hot, _REGISTRY); }" diff --git a/tests/server-hydratable/__snapshots__/vite.test.ts.snap b/tests/server-hydratable/__snapshots__/vite.test.ts.snap index 9db27dc..1620475 100644 --- a/tests/server-hydratable/__snapshots__/vite.test.ts.snap +++ b/tests/server-hydratable/__snapshots__/vite.test.ts.snap @@ -456,48 +456,39 @@ exports[`vite (server, hydratable) > ExportNamedDeclaration w/ FunctionExpressio "import { createComponent as _$createComponent } from "solid-js/web"; import { ssr as _$ssr } from "solid-js/web"; import { ssrHydrationKey as _$ssrHydrationKey } from "solid-js/web"; -var _tmpl$ = ["foo
"], - _tmpl$2 = ["bar
"]; +var _tmpl$ = ["bar
"], + _tmpl$2 = ["foo
"]; import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; const _REGISTRY = _$$registry(); -const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$ssr(_tmpl$, _$ssrHydrationKey()), { +const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props => /*@refresh jsx-skip*/_$ssr(_tmpl$, _$ssrHydrationKey()), { + location: "example.jsx:3:15", + signature: "61dd3182" +}); +const Bar = _$$component(_REGISTRY, "Bar", function Bar() { + return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); +}, { + location: "example.jsx:2:13", + signature: "e93ca257" +}); +const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$ssr(_tmpl$2, _$ssrHydrationKey()), { location: "example.jsx:8:12", signature: "241c14a4" }); -const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-skip*/_$createComponent(_props4.v0, {}), { +const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-skip*/_$createComponent(Bar, {}), { location: "example.jsx:9:12", - signature: "9a24e06b" + signature: "61d9a109" }); -const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, { - get v0() { - return _props.v0; - } -})], { +const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props2 => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { location: "example.jsx:7:10", - signature: "77f4a4b9" + signature: "5302828d" }); const Foo = _$$component(_REGISTRY, "Foo", function Foo() { - return /*@refresh jsx-skip*/_$createComponent(Foo_1, { - v0: Bar - }); + return /*@refresh jsx-skip*/_$createComponent(Foo_1, {}); }, { location: "example.jsx:5:13", - signature: "2f861eed", - dependencies: () => ({ - Bar - }) -}); -const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props2 => /*@refresh jsx-skip*/_$ssr(_tmpl$2, _$ssrHydrationKey()), { - location: "example.jsx:3:15", - signature: "fad4daa8" -}); -const Bar = _$$component(_REGISTRY, "Bar", function Bar() { - return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); -}, { - location: "example.jsx:2:13", - signature: "e93ca257" + signature: "c963b907" }); export { Bar }; export { Foo }; @@ -633,7 +624,6 @@ var _tmpl$ = ["", "

"]; import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; -const example = 'Foo'; const _REGISTRY = _$$registry(); const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/_$ssr(_tmpl$, _$ssrHydrationKey(), _$escape(_props.v0)), { location: "example.jsx:4:15", @@ -650,6 +640,7 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { example }) }); +const example = 'Foo'; if (import.meta.hot) { import.meta.hot.accept(); _$$refresh("vite", import.meta.hot, _REGISTRY); @@ -661,7 +652,6 @@ exports[`vite (server, hydratable) > FunctionDeclaration > should transform Func import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; -const Example = createContext(); const _REGISTRY = _$$registry(); const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/_$createComponent(_props.v0, { children: "Foo" @@ -682,6 +672,7 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { Example }) }); +const Example = createContext(); if (import.meta.hot) { import.meta.hot.accept(); _$$refresh("vite", import.meta.hot, _REGISTRY); @@ -692,23 +683,13 @@ exports[`vite (server, hydratable) > FunctionDeclaration > should transform Func "import { createComponent as _$createComponent } from "solid-js/web"; import { ssr as _$ssr } from "solid-js/web"; import { ssrHydrationKey as _$ssrHydrationKey } from "solid-js/web"; -var _tmpl$ = ["bar
"], - _tmpl$2 = ["foo
"]; +var _tmpl$ = ["foo
"], + _tmpl$2 = ["bar
"]; import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; const _REGISTRY = _$$registry(); -const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props => /*@refresh jsx-skip*/_$ssr(_tmpl$, _$ssrHydrationKey()), { - location: "example.jsx:3:15", - signature: "61dd3182" -}); -const Bar = _$$component(_REGISTRY, "Bar", function Bar() { - return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); -}, { - location: "example.jsx:2:6", - signature: "e93ca257" -}); -const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$ssr(_tmpl$2, _$ssrHydrationKey()), { +const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$ssr(_tmpl$, _$ssrHydrationKey()), { location: "example.jsx:8:12", signature: "241c14a4" }); @@ -716,9 +697,9 @@ const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-ski location: "example.jsx:9:12", signature: "61d9a109" }); -const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props2 => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { +const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { location: "example.jsx:7:10", - signature: "5302828d" + signature: "825a754d" }); const Foo = _$$component(_REGISTRY, "Foo", function Foo() { return /*@refresh jsx-skip*/_$createComponent(Foo_1, {}); @@ -726,6 +707,16 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { location: "example.jsx:5:6", signature: "c963b907" }); +const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props2 => /*@refresh jsx-skip*/_$ssr(_tmpl$2, _$ssrHydrationKey()), { + location: "example.jsx:3:15", + signature: "fad4daa8" +}); +const Bar = _$$component(_REGISTRY, "Bar", function Bar() { + return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); +}, { + location: "example.jsx:2:6", + signature: "e93ca257" +}); if (import.meta.hot) { import.meta.hot.accept(); _$$refresh("vite", import.meta.hot, _REGISTRY); diff --git a/tests/server-hydratable/__snapshots__/webpack5.test.ts.snap b/tests/server-hydratable/__snapshots__/webpack5.test.ts.snap index bc2e131..a826640 100644 --- a/tests/server-hydratable/__snapshots__/webpack5.test.ts.snap +++ b/tests/server-hydratable/__snapshots__/webpack5.test.ts.snap @@ -443,48 +443,39 @@ exports[`webpack5 (server, hydratable) > ExportNamedDeclaration w/ FunctionExpre "import { createComponent as _$createComponent } from "solid-js/web"; import { ssr as _$ssr } from "solid-js/web"; import { ssrHydrationKey as _$ssrHydrationKey } from "solid-js/web"; -var _tmpl$ = ["foo
"], - _tmpl$2 = ["bar
"]; +var _tmpl$ = ["bar
"], + _tmpl$2 = ["foo
"]; import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; const _REGISTRY = _$$registry(); -const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$ssr(_tmpl$, _$ssrHydrationKey()), { +const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props => /*@refresh jsx-skip*/_$ssr(_tmpl$, _$ssrHydrationKey()), { + location: "example.jsx:3:15", + signature: "61dd3182" +}); +const Bar = _$$component(_REGISTRY, "Bar", function Bar() { + return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); +}, { + location: "example.jsx:2:13", + signature: "e93ca257" +}); +const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$ssr(_tmpl$2, _$ssrHydrationKey()), { location: "example.jsx:8:12", signature: "241c14a4" }); -const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-skip*/_$createComponent(_props4.v0, {}), { +const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-skip*/_$createComponent(Bar, {}), { location: "example.jsx:9:12", - signature: "9a24e06b" + signature: "61d9a109" }); -const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, { - get v0() { - return _props.v0; - } -})], { +const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props2 => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { location: "example.jsx:7:10", - signature: "77f4a4b9" + signature: "5302828d" }); const Foo = _$$component(_REGISTRY, "Foo", function Foo() { - return /*@refresh jsx-skip*/_$createComponent(Foo_1, { - v0: Bar - }); + return /*@refresh jsx-skip*/_$createComponent(Foo_1, {}); }, { location: "example.jsx:5:13", - signature: "2f861eed", - dependencies: () => ({ - Bar - }) -}); -const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props2 => /*@refresh jsx-skip*/_$ssr(_tmpl$2, _$ssrHydrationKey()), { - location: "example.jsx:3:15", - signature: "fad4daa8" -}); -const Bar = _$$component(_REGISTRY, "Bar", function Bar() { - return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); -}, { - location: "example.jsx:2:13", - signature: "e93ca257" + signature: "c963b907" }); export { Bar }; export { Foo }; @@ -616,7 +607,6 @@ var _tmpl$ = ["", "

"]; import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; -const example = 'Foo'; const _REGISTRY = _$$registry(); const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/_$ssr(_tmpl$, _$ssrHydrationKey(), _$escape(_props.v0)), { location: "example.jsx:4:15", @@ -633,6 +623,7 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { example }) }); +const example = 'Foo'; if (import.meta.webpackHot) { _$$refresh("webpack5", import.meta.webpackHot, _REGISTRY); }" @@ -643,7 +634,6 @@ exports[`webpack5 (server, hydratable) > FunctionDeclaration > should transform import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; -const Example = createContext(); const _REGISTRY = _$$registry(); const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/_$createComponent(_props.v0, { children: "Foo" @@ -664,6 +654,7 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { Example }) }); +const Example = createContext(); if (import.meta.webpackHot) { _$$refresh("webpack5", import.meta.webpackHot, _REGISTRY); }" @@ -673,23 +664,13 @@ exports[`webpack5 (server, hydratable) > FunctionDeclaration > should transform "import { createComponent as _$createComponent } from "solid-js/web"; import { ssr as _$ssr } from "solid-js/web"; import { ssrHydrationKey as _$ssrHydrationKey } from "solid-js/web"; -var _tmpl$ = ["bar
"], - _tmpl$2 = ["foo
"]; +var _tmpl$ = ["foo
"], + _tmpl$2 = ["bar
"]; import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; const _REGISTRY = _$$registry(); -const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props => /*@refresh jsx-skip*/_$ssr(_tmpl$, _$ssrHydrationKey()), { - location: "example.jsx:3:15", - signature: "61dd3182" -}); -const Bar = _$$component(_REGISTRY, "Bar", function Bar() { - return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); -}, { - location: "example.jsx:2:6", - signature: "e93ca257" -}); -const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$ssr(_tmpl$2, _$ssrHydrationKey()), { +const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$ssr(_tmpl$, _$ssrHydrationKey()), { location: "example.jsx:8:12", signature: "241c14a4" }); @@ -697,9 +678,9 @@ const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-ski location: "example.jsx:9:12", signature: "61d9a109" }); -const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props2 => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { +const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { location: "example.jsx:7:10", - signature: "5302828d" + signature: "825a754d" }); const Foo = _$$component(_REGISTRY, "Foo", function Foo() { return /*@refresh jsx-skip*/_$createComponent(Foo_1, {}); @@ -707,6 +688,16 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { location: "example.jsx:5:6", signature: "c963b907" }); +const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props2 => /*@refresh jsx-skip*/_$ssr(_tmpl$2, _$ssrHydrationKey()), { + location: "example.jsx:3:15", + signature: "fad4daa8" +}); +const Bar = _$$component(_REGISTRY, "Bar", function Bar() { + return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); +}, { + location: "example.jsx:2:6", + signature: "e93ca257" +}); if (import.meta.webpackHot) { _$$refresh("webpack5", import.meta.webpackHot, _REGISTRY); }" diff --git a/tests/server/__snapshots__/esm.test.ts.snap b/tests/server/__snapshots__/esm.test.ts.snap index 4e5158b..0b0eb5f 100644 --- a/tests/server/__snapshots__/esm.test.ts.snap +++ b/tests/server/__snapshots__/esm.test.ts.snap @@ -427,48 +427,39 @@ if (import.meta.hot) { exports[`esm (server, non-hydratable) > ExportNamedDeclaration w/ FunctionExpression > should transform ExportNamedDeclaration w/ FunctionExpression with valid Component name and params 5`] = ` "import { createComponent as _$createComponent } from "solid-js/web"; import { ssr as _$ssr } from "solid-js/web"; -var _tmpl$ = "
foo
", - _tmpl$2 = "
bar
"; +var _tmpl$ = "
bar
", + _tmpl$2 = "
foo
"; import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; const _REGISTRY = _$$registry(); -const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$ssr(_tmpl$), { +const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props => /*@refresh jsx-skip*/_$ssr(_tmpl$), { + location: "example.jsx:3:15", + signature: "61dd3182" +}); +const Bar = _$$component(_REGISTRY, "Bar", function Bar() { + return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); +}, { + location: "example.jsx:2:13", + signature: "e93ca257" +}); +const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$ssr(_tmpl$2), { location: "example.jsx:8:12", signature: "241c14a4" }); -const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-skip*/_$createComponent(_props4.v0, {}), { +const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-skip*/_$createComponent(Bar, {}), { location: "example.jsx:9:12", - signature: "9a24e06b" + signature: "61d9a109" }); -const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, { - get v0() { - return _props.v0; - } -})], { +const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props2 => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { location: "example.jsx:7:10", - signature: "77f4a4b9" + signature: "5302828d" }); const Foo = _$$component(_REGISTRY, "Foo", function Foo() { - return /*@refresh jsx-skip*/_$createComponent(Foo_1, { - v0: Bar - }); + return /*@refresh jsx-skip*/_$createComponent(Foo_1, {}); }, { location: "example.jsx:5:13", - signature: "2f861eed", - dependencies: () => ({ - Bar - }) -}); -const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props2 => /*@refresh jsx-skip*/_$ssr(_tmpl$2), { - location: "example.jsx:3:15", - signature: "fad4daa8" -}); -const Bar = _$$component(_REGISTRY, "Bar", function Bar() { - return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); -}, { - location: "example.jsx:2:13", - signature: "e93ca257" + signature: "c963b907" }); export { Bar }; export { Foo }; @@ -593,7 +584,6 @@ var _tmpl$ = ["

", "

"]; import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; -const example = 'Foo'; const _REGISTRY = _$$registry(); const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/_$ssr(_tmpl$, _$escape(_props.v0)), { location: "example.jsx:4:15", @@ -610,6 +600,7 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { example }) }); +const example = 'Foo'; if (import.meta.hot) { _$$refresh("esm", import.meta.hot, _REGISTRY); }" @@ -620,7 +611,6 @@ exports[`esm (server, non-hydratable) > FunctionDeclaration > should transform F import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; -const Example = createContext(); const _REGISTRY = _$$registry(); const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/_$createComponent(_props.v0, { children: "Foo" @@ -641,6 +631,7 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { Example }) }); +const Example = createContext(); if (import.meta.hot) { _$$refresh("esm", import.meta.hot, _REGISTRY); }" @@ -649,23 +640,13 @@ if (import.meta.hot) { exports[`esm (server, non-hydratable) > FunctionDeclaration > should transform FunctionDeclaration with valid Component name and params 5`] = ` "import { createComponent as _$createComponent } from "solid-js/web"; import { ssr as _$ssr } from "solid-js/web"; -var _tmpl$ = "
bar
", - _tmpl$2 = "
foo
"; +var _tmpl$ = "
foo
", + _tmpl$2 = "
bar
"; import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; const _REGISTRY = _$$registry(); -const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props => /*@refresh jsx-skip*/_$ssr(_tmpl$), { - location: "example.jsx:3:15", - signature: "61dd3182" -}); -const Bar = _$$component(_REGISTRY, "Bar", function Bar() { - return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); -}, { - location: "example.jsx:2:6", - signature: "e93ca257" -}); -const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$ssr(_tmpl$2), { +const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$ssr(_tmpl$), { location: "example.jsx:8:12", signature: "241c14a4" }); @@ -673,9 +654,9 @@ const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-ski location: "example.jsx:9:12", signature: "61d9a109" }); -const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props2 => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { +const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { location: "example.jsx:7:10", - signature: "5302828d" + signature: "825a754d" }); const Foo = _$$component(_REGISTRY, "Foo", function Foo() { return /*@refresh jsx-skip*/_$createComponent(Foo_1, {}); @@ -683,6 +664,16 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { location: "example.jsx:5:6", signature: "c963b907" }); +const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props2 => /*@refresh jsx-skip*/_$ssr(_tmpl$2), { + location: "example.jsx:3:15", + signature: "fad4daa8" +}); +const Bar = _$$component(_REGISTRY, "Bar", function Bar() { + return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); +}, { + location: "example.jsx:2:6", + signature: "e93ca257" +}); if (import.meta.hot) { _$$refresh("esm", import.meta.hot, _REGISTRY); }" diff --git a/tests/server/__snapshots__/rspack-esm.test.ts.snap b/tests/server/__snapshots__/rspack-esm.test.ts.snap index cd6e6ba..065c478 100644 --- a/tests/server/__snapshots__/rspack-esm.test.ts.snap +++ b/tests/server/__snapshots__/rspack-esm.test.ts.snap @@ -427,48 +427,39 @@ if (import.meta.webpackHot) { exports[`rspack-esm (server, non-hydratable) > ExportNamedDeclaration w/ FunctionExpression > should transform ExportNamedDeclaration w/ FunctionExpression with valid Component name and params 5`] = ` "import { createComponent as _$createComponent } from "solid-js/web"; import { ssr as _$ssr } from "solid-js/web"; -var _tmpl$ = "
foo
", - _tmpl$2 = "
bar
"; +var _tmpl$ = "
bar
", + _tmpl$2 = "
foo
"; import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; const _REGISTRY = _$$registry(); -const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$ssr(_tmpl$), { +const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props => /*@refresh jsx-skip*/_$ssr(_tmpl$), { + location: "example.jsx:3:15", + signature: "61dd3182" +}); +const Bar = _$$component(_REGISTRY, "Bar", function Bar() { + return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); +}, { + location: "example.jsx:2:13", + signature: "e93ca257" +}); +const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$ssr(_tmpl$2), { location: "example.jsx:8:12", signature: "241c14a4" }); -const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-skip*/_$createComponent(_props4.v0, {}), { +const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-skip*/_$createComponent(Bar, {}), { location: "example.jsx:9:12", - signature: "9a24e06b" + signature: "61d9a109" }); -const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, { - get v0() { - return _props.v0; - } -})], { +const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props2 => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { location: "example.jsx:7:10", - signature: "77f4a4b9" + signature: "5302828d" }); const Foo = _$$component(_REGISTRY, "Foo", function Foo() { - return /*@refresh jsx-skip*/_$createComponent(Foo_1, { - v0: Bar - }); + return /*@refresh jsx-skip*/_$createComponent(Foo_1, {}); }, { location: "example.jsx:5:13", - signature: "2f861eed", - dependencies: () => ({ - Bar - }) -}); -const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props2 => /*@refresh jsx-skip*/_$ssr(_tmpl$2), { - location: "example.jsx:3:15", - signature: "fad4daa8" -}); -const Bar = _$$component(_REGISTRY, "Bar", function Bar() { - return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); -}, { - location: "example.jsx:2:13", - signature: "e93ca257" + signature: "c963b907" }); export { Bar }; export { Foo }; @@ -593,7 +584,6 @@ var _tmpl$ = ["

", "

"]; import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; -const example = 'Foo'; const _REGISTRY = _$$registry(); const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/_$ssr(_tmpl$, _$escape(_props.v0)), { location: "example.jsx:4:15", @@ -610,6 +600,7 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { example }) }); +const example = 'Foo'; if (import.meta.webpackHot) { _$$refresh("rspack-esm", import.meta.webpackHot, _REGISTRY); }" @@ -620,7 +611,6 @@ exports[`rspack-esm (server, non-hydratable) > FunctionDeclaration > should tran import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; -const Example = createContext(); const _REGISTRY = _$$registry(); const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/_$createComponent(_props.v0, { children: "Foo" @@ -641,6 +631,7 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { Example }) }); +const Example = createContext(); if (import.meta.webpackHot) { _$$refresh("rspack-esm", import.meta.webpackHot, _REGISTRY); }" @@ -649,23 +640,13 @@ if (import.meta.webpackHot) { exports[`rspack-esm (server, non-hydratable) > FunctionDeclaration > should transform FunctionDeclaration with valid Component name and params 5`] = ` "import { createComponent as _$createComponent } from "solid-js/web"; import { ssr as _$ssr } from "solid-js/web"; -var _tmpl$ = "
bar
", - _tmpl$2 = "
foo
"; +var _tmpl$ = "
foo
", + _tmpl$2 = "
bar
"; import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; const _REGISTRY = _$$registry(); -const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props => /*@refresh jsx-skip*/_$ssr(_tmpl$), { - location: "example.jsx:3:15", - signature: "61dd3182" -}); -const Bar = _$$component(_REGISTRY, "Bar", function Bar() { - return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); -}, { - location: "example.jsx:2:6", - signature: "e93ca257" -}); -const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$ssr(_tmpl$2), { +const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$ssr(_tmpl$), { location: "example.jsx:8:12", signature: "241c14a4" }); @@ -673,9 +654,9 @@ const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-ski location: "example.jsx:9:12", signature: "61d9a109" }); -const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props2 => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { +const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { location: "example.jsx:7:10", - signature: "5302828d" + signature: "825a754d" }); const Foo = _$$component(_REGISTRY, "Foo", function Foo() { return /*@refresh jsx-skip*/_$createComponent(Foo_1, {}); @@ -683,6 +664,16 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { location: "example.jsx:5:6", signature: "c963b907" }); +const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props2 => /*@refresh jsx-skip*/_$ssr(_tmpl$2), { + location: "example.jsx:3:15", + signature: "fad4daa8" +}); +const Bar = _$$component(_REGISTRY, "Bar", function Bar() { + return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); +}, { + location: "example.jsx:2:6", + signature: "e93ca257" +}); if (import.meta.webpackHot) { _$$refresh("rspack-esm", import.meta.webpackHot, _REGISTRY); }" diff --git a/tests/server/__snapshots__/standard.test.ts.snap b/tests/server/__snapshots__/standard.test.ts.snap index 7453f95..bc312d8 100644 --- a/tests/server/__snapshots__/standard.test.ts.snap +++ b/tests/server/__snapshots__/standard.test.ts.snap @@ -427,48 +427,39 @@ if (module.hot) { exports[`standard (server, non-hydratable) > ExportNamedDeclaration w/ FunctionExpression > should transform ExportNamedDeclaration w/ FunctionExpression with valid Component name and params 5`] = ` "import { createComponent as _$createComponent } from "solid-js/web"; import { ssr as _$ssr } from "solid-js/web"; -var _tmpl$ = "
foo
", - _tmpl$2 = "
bar
"; +var _tmpl$ = "
bar
", + _tmpl$2 = "
foo
"; import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; const _REGISTRY = _$$registry(); -const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$ssr(_tmpl$), { +const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props => /*@refresh jsx-skip*/_$ssr(_tmpl$), { + location: "example.jsx:3:15", + signature: "61dd3182" +}); +const Bar = _$$component(_REGISTRY, "Bar", function Bar() { + return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); +}, { + location: "example.jsx:2:13", + signature: "e93ca257" +}); +const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$ssr(_tmpl$2), { location: "example.jsx:8:12", signature: "241c14a4" }); -const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-skip*/_$createComponent(_props4.v0, {}), { +const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-skip*/_$createComponent(Bar, {}), { location: "example.jsx:9:12", - signature: "9a24e06b" + signature: "61d9a109" }); -const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, { - get v0() { - return _props.v0; - } -})], { +const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props2 => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { location: "example.jsx:7:10", - signature: "77f4a4b9" + signature: "5302828d" }); const Foo = _$$component(_REGISTRY, "Foo", function Foo() { - return /*@refresh jsx-skip*/_$createComponent(Foo_1, { - v0: Bar - }); + return /*@refresh jsx-skip*/_$createComponent(Foo_1, {}); }, { location: "example.jsx:5:13", - signature: "2f861eed", - dependencies: () => ({ - Bar - }) -}); -const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props2 => /*@refresh jsx-skip*/_$ssr(_tmpl$2), { - location: "example.jsx:3:15", - signature: "fad4daa8" -}); -const Bar = _$$component(_REGISTRY, "Bar", function Bar() { - return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); -}, { - location: "example.jsx:2:13", - signature: "e93ca257" + signature: "c963b907" }); export { Bar }; export { Foo }; @@ -593,7 +584,6 @@ var _tmpl$ = ["

", "

"]; import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; -const example = 'Foo'; const _REGISTRY = _$$registry(); const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/_$ssr(_tmpl$, _$escape(_props.v0)), { location: "example.jsx:4:15", @@ -610,6 +600,7 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { example }) }); +const example = 'Foo'; if (module.hot) { _$$refresh("standard", module.hot, _REGISTRY); }" @@ -620,7 +611,6 @@ exports[`standard (server, non-hydratable) > FunctionDeclaration > should transf import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; -const Example = createContext(); const _REGISTRY = _$$registry(); const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/_$createComponent(_props.v0, { children: "Foo" @@ -641,6 +631,7 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { Example }) }); +const Example = createContext(); if (module.hot) { _$$refresh("standard", module.hot, _REGISTRY); }" @@ -649,23 +640,13 @@ if (module.hot) { exports[`standard (server, non-hydratable) > FunctionDeclaration > should transform FunctionDeclaration with valid Component name and params 5`] = ` "import { createComponent as _$createComponent } from "solid-js/web"; import { ssr as _$ssr } from "solid-js/web"; -var _tmpl$ = "
bar
", - _tmpl$2 = "
foo
"; +var _tmpl$ = "
foo
", + _tmpl$2 = "
bar
"; import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; const _REGISTRY = _$$registry(); -const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props => /*@refresh jsx-skip*/_$ssr(_tmpl$), { - location: "example.jsx:3:15", - signature: "61dd3182" -}); -const Bar = _$$component(_REGISTRY, "Bar", function Bar() { - return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); -}, { - location: "example.jsx:2:6", - signature: "e93ca257" -}); -const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$ssr(_tmpl$2), { +const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$ssr(_tmpl$), { location: "example.jsx:8:12", signature: "241c14a4" }); @@ -673,9 +654,9 @@ const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-ski location: "example.jsx:9:12", signature: "61d9a109" }); -const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props2 => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { +const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { location: "example.jsx:7:10", - signature: "5302828d" + signature: "825a754d" }); const Foo = _$$component(_REGISTRY, "Foo", function Foo() { return /*@refresh jsx-skip*/_$createComponent(Foo_1, {}); @@ -683,6 +664,16 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { location: "example.jsx:5:6", signature: "c963b907" }); +const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props2 => /*@refresh jsx-skip*/_$ssr(_tmpl$2), { + location: "example.jsx:3:15", + signature: "fad4daa8" +}); +const Bar = _$$component(_REGISTRY, "Bar", function Bar() { + return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); +}, { + location: "example.jsx:2:6", + signature: "e93ca257" +}); if (module.hot) { _$$refresh("standard", module.hot, _REGISTRY); }" diff --git a/tests/server/__snapshots__/vite.test.ts.snap b/tests/server/__snapshots__/vite.test.ts.snap index 300f470..0f992b1 100644 --- a/tests/server/__snapshots__/vite.test.ts.snap +++ b/tests/server/__snapshots__/vite.test.ts.snap @@ -440,48 +440,39 @@ if (import.meta.hot) { exports[`vite (server, non-hydratable) > ExportNamedDeclaration w/ FunctionExpression > should transform ExportNamedDeclaration w/ FunctionExpression with valid Component name and params 5`] = ` "import { createComponent as _$createComponent } from "solid-js/web"; import { ssr as _$ssr } from "solid-js/web"; -var _tmpl$ = "
foo
", - _tmpl$2 = "
bar
"; +var _tmpl$ = "
bar
", + _tmpl$2 = "
foo
"; import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; const _REGISTRY = _$$registry(); -const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$ssr(_tmpl$), { +const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props => /*@refresh jsx-skip*/_$ssr(_tmpl$), { + location: "example.jsx:3:15", + signature: "61dd3182" +}); +const Bar = _$$component(_REGISTRY, "Bar", function Bar() { + return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); +}, { + location: "example.jsx:2:13", + signature: "e93ca257" +}); +const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$ssr(_tmpl$2), { location: "example.jsx:8:12", signature: "241c14a4" }); -const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-skip*/_$createComponent(_props4.v0, {}), { +const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-skip*/_$createComponent(Bar, {}), { location: "example.jsx:9:12", - signature: "9a24e06b" + signature: "61d9a109" }); -const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, { - get v0() { - return _props.v0; - } -})], { +const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props2 => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { location: "example.jsx:7:10", - signature: "77f4a4b9" + signature: "5302828d" }); const Foo = _$$component(_REGISTRY, "Foo", function Foo() { - return /*@refresh jsx-skip*/_$createComponent(Foo_1, { - v0: Bar - }); + return /*@refresh jsx-skip*/_$createComponent(Foo_1, {}); }, { location: "example.jsx:5:13", - signature: "2f861eed", - dependencies: () => ({ - Bar - }) -}); -const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props2 => /*@refresh jsx-skip*/_$ssr(_tmpl$2), { - location: "example.jsx:3:15", - signature: "fad4daa8" -}); -const Bar = _$$component(_REGISTRY, "Bar", function Bar() { - return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); -}, { - location: "example.jsx:2:13", - signature: "e93ca257" + signature: "c963b907" }); export { Bar }; export { Foo }; @@ -610,7 +601,6 @@ var _tmpl$ = ["

", "

"]; import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; -const example = 'Foo'; const _REGISTRY = _$$registry(); const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/_$ssr(_tmpl$, _$escape(_props.v0)), { location: "example.jsx:4:15", @@ -627,6 +617,7 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { example }) }); +const example = 'Foo'; if (import.meta.hot) { import.meta.hot.accept(); _$$refresh("vite", import.meta.hot, _REGISTRY); @@ -638,7 +629,6 @@ exports[`vite (server, non-hydratable) > FunctionDeclaration > should transform import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; -const Example = createContext(); const _REGISTRY = _$$registry(); const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/_$createComponent(_props.v0, { children: "Foo" @@ -659,6 +649,7 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { Example }) }); +const Example = createContext(); if (import.meta.hot) { import.meta.hot.accept(); _$$refresh("vite", import.meta.hot, _REGISTRY); @@ -668,23 +659,13 @@ if (import.meta.hot) { exports[`vite (server, non-hydratable) > FunctionDeclaration > should transform FunctionDeclaration with valid Component name and params 5`] = ` "import { createComponent as _$createComponent } from "solid-js/web"; import { ssr as _$ssr } from "solid-js/web"; -var _tmpl$ = "
bar
", - _tmpl$2 = "
foo
"; +var _tmpl$ = "
foo
", + _tmpl$2 = "
bar
"; import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; const _REGISTRY = _$$registry(); -const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props => /*@refresh jsx-skip*/_$ssr(_tmpl$), { - location: "example.jsx:3:15", - signature: "61dd3182" -}); -const Bar = _$$component(_REGISTRY, "Bar", function Bar() { - return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); -}, { - location: "example.jsx:2:6", - signature: "e93ca257" -}); -const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$ssr(_tmpl$2), { +const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$ssr(_tmpl$), { location: "example.jsx:8:12", signature: "241c14a4" }); @@ -692,9 +673,9 @@ const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-ski location: "example.jsx:9:12", signature: "61d9a109" }); -const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props2 => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { +const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { location: "example.jsx:7:10", - signature: "5302828d" + signature: "825a754d" }); const Foo = _$$component(_REGISTRY, "Foo", function Foo() { return /*@refresh jsx-skip*/_$createComponent(Foo_1, {}); @@ -702,6 +683,16 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { location: "example.jsx:5:6", signature: "c963b907" }); +const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props2 => /*@refresh jsx-skip*/_$ssr(_tmpl$2), { + location: "example.jsx:3:15", + signature: "fad4daa8" +}); +const Bar = _$$component(_REGISTRY, "Bar", function Bar() { + return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); +}, { + location: "example.jsx:2:6", + signature: "e93ca257" +}); if (import.meta.hot) { import.meta.hot.accept(); _$$refresh("vite", import.meta.hot, _REGISTRY); diff --git a/tests/server/__snapshots__/webpack5.test.ts.snap b/tests/server/__snapshots__/webpack5.test.ts.snap index 42cef93..1e4d9ab 100644 --- a/tests/server/__snapshots__/webpack5.test.ts.snap +++ b/tests/server/__snapshots__/webpack5.test.ts.snap @@ -427,48 +427,39 @@ if (import.meta.webpackHot) { exports[`webpack5 (server, non-hydratable) > ExportNamedDeclaration w/ FunctionExpression > should transform ExportNamedDeclaration w/ FunctionExpression with valid Component name and params 5`] = ` "import { createComponent as _$createComponent } from "solid-js/web"; import { ssr as _$ssr } from "solid-js/web"; -var _tmpl$ = "
foo
", - _tmpl$2 = "
bar
"; +var _tmpl$ = "
bar
", + _tmpl$2 = "
foo
"; import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; const _REGISTRY = _$$registry(); -const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$ssr(_tmpl$), { +const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props => /*@refresh jsx-skip*/_$ssr(_tmpl$), { + location: "example.jsx:3:15", + signature: "61dd3182" +}); +const Bar = _$$component(_REGISTRY, "Bar", function Bar() { + return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); +}, { + location: "example.jsx:2:13", + signature: "e93ca257" +}); +const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$ssr(_tmpl$2), { location: "example.jsx:8:12", signature: "241c14a4" }); -const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-skip*/_$createComponent(_props4.v0, {}), { +const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-skip*/_$createComponent(Bar, {}), { location: "example.jsx:9:12", - signature: "9a24e06b" + signature: "61d9a109" }); -const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, { - get v0() { - return _props.v0; - } -})], { +const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props2 => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { location: "example.jsx:7:10", - signature: "77f4a4b9" + signature: "5302828d" }); const Foo = _$$component(_REGISTRY, "Foo", function Foo() { - return /*@refresh jsx-skip*/_$createComponent(Foo_1, { - v0: Bar - }); + return /*@refresh jsx-skip*/_$createComponent(Foo_1, {}); }, { location: "example.jsx:5:13", - signature: "2f861eed", - dependencies: () => ({ - Bar - }) -}); -const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props2 => /*@refresh jsx-skip*/_$ssr(_tmpl$2), { - location: "example.jsx:3:15", - signature: "fad4daa8" -}); -const Bar = _$$component(_REGISTRY, "Bar", function Bar() { - return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); -}, { - location: "example.jsx:2:13", - signature: "e93ca257" + signature: "c963b907" }); export { Bar }; export { Foo }; @@ -593,7 +584,6 @@ var _tmpl$ = ["

", "

"]; import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; -const example = 'Foo'; const _REGISTRY = _$$registry(); const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/_$ssr(_tmpl$, _$escape(_props.v0)), { location: "example.jsx:4:15", @@ -610,6 +600,7 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { example }) }); +const example = 'Foo'; if (import.meta.webpackHot) { _$$refresh("webpack5", import.meta.webpackHot, _REGISTRY); }" @@ -620,7 +611,6 @@ exports[`webpack5 (server, non-hydratable) > FunctionDeclaration > should transf import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; -const Example = createContext(); const _REGISTRY = _$$registry(); const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/_$createComponent(_props.v0, { children: "Foo" @@ -641,6 +631,7 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { Example }) }); +const Example = createContext(); if (import.meta.webpackHot) { _$$refresh("webpack5", import.meta.webpackHot, _REGISTRY); }" @@ -649,23 +640,13 @@ if (import.meta.webpackHot) { exports[`webpack5 (server, non-hydratable) > FunctionDeclaration > should transform FunctionDeclaration with valid Component name and params 5`] = ` "import { createComponent as _$createComponent } from "solid-js/web"; import { ssr as _$ssr } from "solid-js/web"; -var _tmpl$ = "
bar
", - _tmpl$2 = "
foo
"; +var _tmpl$ = "
foo
", + _tmpl$2 = "
bar
"; import { $$component as _$$component } from "solid-refresh"; import { $$refresh as _$$refresh } from "solid-refresh"; import { $$registry as _$$registry } from "solid-refresh"; const _REGISTRY = _$$registry(); -const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props => /*@refresh jsx-skip*/_$ssr(_tmpl$), { - location: "example.jsx:3:15", - signature: "61dd3182" -}); -const Bar = _$$component(_REGISTRY, "Bar", function Bar() { - return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); -}, { - location: "example.jsx:2:6", - signature: "e93ca257" -}); -const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$ssr(_tmpl$2), { +const Foo_1_1 = _$$component(_REGISTRY, "Foo_1_1", _props3 => /*@refresh jsx-skip*/_$ssr(_tmpl$), { location: "example.jsx:8:12", signature: "241c14a4" }); @@ -673,9 +654,9 @@ const Foo_1_2 = _$$component(_REGISTRY, "Foo_1_2", _props4 => /*@refresh jsx-ski location: "example.jsx:9:12", signature: "61d9a109" }); -const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props2 => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { +const Foo_1 = _$$component(_REGISTRY, "Foo_1", _props => /*@refresh jsx-skip*/[_$createComponent(Foo_1_1, {}), _$createComponent(Foo_1_2, {})], { location: "example.jsx:7:10", - signature: "5302828d" + signature: "825a754d" }); const Foo = _$$component(_REGISTRY, "Foo", function Foo() { return /*@refresh jsx-skip*/_$createComponent(Foo_1, {}); @@ -683,6 +664,16 @@ const Foo = _$$component(_REGISTRY, "Foo", function Foo() { location: "example.jsx:5:6", signature: "c963b907" }); +const Bar_1 = _$$component(_REGISTRY, "Bar_1", _props2 => /*@refresh jsx-skip*/_$ssr(_tmpl$2), { + location: "example.jsx:3:15", + signature: "fad4daa8" +}); +const Bar = _$$component(_REGISTRY, "Bar", function Bar() { + return /*@refresh jsx-skip*/_$createComponent(Bar_1, {}); +}, { + location: "example.jsx:2:6", + signature: "e93ca257" +}); if (import.meta.webpackHot) { _$$refresh("webpack5", import.meta.webpackHot, _REGISTRY); }"