@bleedingdev/modern-js-renderer-solid 0.0.0-stage → 3.9.3-ultramodern.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/actions.js +283 -0
- package/dist/esm/application-router.js +25 -0
- package/dist/esm/client.js +49 -0
- package/dist/esm/entry-application.js +60 -0
- package/dist/esm/entry-client.js +23 -0
- package/dist/esm/federation-context.js +25 -0
- package/dist/esm/federation-ssr.js +84 -0
- package/dist/esm/federation.js +83 -0
- package/dist/esm/i18n/I18nProvider.js +33 -0
- package/dist/esm/i18n/LocalizedLink.js +74 -0
- package/dist/esm/i18n/context.js +3 -0
- package/dist/esm/i18n/index.js +8 -0
- package/dist/esm/i18n/languageSync.js +50 -0
- package/dist/esm/i18n/types.js +0 -0
- package/dist/esm/i18n/useI18n.js +74 -0
- package/dist/esm/index.js +58 -0
- package/dist/esm/manifest.js +150 -0
- package/dist/esm/route-completion.js +150 -0
- package/dist/esm/route-data-error.js +108 -0
- package/dist/esm/router-binding/Asset.js +201 -0
- package/dist/esm/router-binding/CatchBoundary.js +94 -0
- package/dist/esm/router-binding/ClientOnly.js +26 -0
- package/dist/esm/router-binding/HeadContent.js +8 -0
- package/dist/esm/router-binding/LICENSE +21 -0
- package/dist/esm/router-binding/Match.js +319 -0
- package/dist/esm/router-binding/Matches.js +117 -0
- package/dist/esm/router-binding/PROVENANCE.json +94 -0
- package/dist/esm/router-binding/RouterProvider.js +51 -0
- package/dist/esm/router-binding/SafeFragment.js +5 -0
- package/dist/esm/router-binding/ScriptOnce.js +15 -0
- package/dist/esm/router-binding/Scripts.js +30 -0
- package/dist/esm/router-binding/ScrollRestoration.js +16 -0
- package/dist/esm/router-binding/Transitioner.js +103 -0
- package/dist/esm/router-binding/awaited.js +48 -0
- package/dist/esm/router-binding/fileRoute.js +83 -0
- package/dist/esm/router-binding/flightData.js +23 -0
- package/dist/esm/router-binding/headContentUtils.js +162 -0
- package/dist/esm/router-binding/history.js +0 -0
- package/dist/esm/router-binding/index.js +35 -0
- package/dist/esm/router-binding/lazyRouteComponent.js +30 -0
- package/dist/esm/router-binding/link.js +389 -0
- package/dist/esm/router-binding/matchContext.js +7 -0
- package/dist/esm/router-binding/nonRouteComponentContext.js +13 -0
- package/dist/esm/router-binding/not-found.js +35 -0
- package/dist/esm/router-binding/publicMatchData.js +447 -0
- package/dist/esm/router-binding/registryTransfer.js +210 -0
- package/dist/esm/router-binding/renderRouteNotFound.js +23 -0
- package/dist/esm/router-binding/route.js +143 -0
- package/dist/esm/router-binding/router.js +13 -0
- package/dist/esm/router-binding/routerContext.js +3 -0
- package/dist/esm/router-binding/routerStores.js +50 -0
- package/dist/esm/router-binding/scroll-restoration.js +13 -0
- package/dist/esm/router-binding/typePrimitives.js +0 -0
- package/dist/esm/router-binding/useBlocker.js +152 -0
- package/dist/esm/router-binding/useCanGoBack.js +7 -0
- package/dist/esm/router-binding/useLoaderData.js +9 -0
- package/dist/esm/router-binding/useLoaderDeps.js +8 -0
- package/dist/esm/router-binding/useLocation.js +14 -0
- package/dist/esm/router-binding/useMatch.js +28 -0
- package/dist/esm/router-binding/useNavigate.js +19 -0
- package/dist/esm/router-binding/useParams.js +13 -0
- package/dist/esm/router-binding/useRouteContext.js +8 -0
- package/dist/esm/router-binding/useRouter.js +10 -0
- package/dist/esm/router-binding/useRouterState.js +19 -0
- package/dist/esm/router-binding/useSearch.js +13 -0
- package/dist/esm/router-binding/utils.js +23 -0
- package/dist/esm/router.js +187 -0
- package/dist/esm-node/actions.js +263 -0
- package/dist/esm-node/application-router.js +25 -0
- package/dist/esm-node/client.js +49 -0
- package/dist/esm-node/entry-application.js +110 -0
- package/dist/esm-node/entry-client.js +23 -0
- package/dist/esm-node/entry-server.js +47 -0
- package/dist/esm-node/federation-context.js +25 -0
- package/dist/esm-node/federation-ssr.js +84 -0
- package/dist/esm-node/federation.js +83 -0
- package/dist/esm-node/i18n/I18nProvider.js +42 -0
- package/dist/esm-node/i18n/LocalizedLink.js +142 -0
- package/dist/esm-node/i18n/context.js +3 -0
- package/dist/esm-node/i18n/index.js +8 -0
- package/dist/esm-node/i18n/languageSync.js +50 -0
- package/dist/esm-node/i18n/types.js +1 -0
- package/dist/esm-node/i18n/useI18n.js +74 -0
- package/dist/esm-node/index.js +58 -0
- package/dist/esm-node/manifest.js +150 -0
- package/dist/esm-node/native-promise-serialization.js +113 -0
- package/dist/esm-node/plugin/compiler.js +209 -0
- package/dist/esm-node/plugin/create.js +235 -0
- package/dist/esm-node/plugin/index.js +73 -0
- package/dist/esm-node/plugin/profile.js +52 -0
- package/dist/esm-node/route-completion.js +160 -0
- package/dist/esm-node/route-data-error.js +108 -0
- package/dist/esm-node/router-binding/Asset.js +171 -0
- package/dist/esm-node/router-binding/CatchBoundary.js +136 -0
- package/dist/esm-node/router-binding/ClientOnly.js +46 -0
- package/dist/esm-node/router-binding/HeadContent.js +8 -0
- package/dist/esm-node/router-binding/LICENSE +21 -0
- package/dist/esm-node/router-binding/Match.js +660 -0
- package/dist/esm-node/router-binding/Matches.js +161 -0
- package/dist/esm-node/router-binding/PROVENANCE.json +94 -0
- package/dist/esm-node/router-binding/RouterProvider.js +87 -0
- package/dist/esm-node/router-binding/SafeFragment.js +5 -0
- package/dist/esm-node/router-binding/ScriptOnce.js +16 -0
- package/dist/esm-node/router-binding/Scripts.js +49 -0
- package/dist/esm-node/router-binding/ScrollRestoration.js +16 -0
- package/dist/esm-node/router-binding/Transitioner.js +103 -0
- package/dist/esm-node/router-binding/awaited.js +75 -0
- package/dist/esm-node/router-binding/fileRoute.js +83 -0
- package/dist/esm-node/router-binding/flightData.js +23 -0
- package/dist/esm-node/router-binding/headContentUtils.js +162 -0
- package/dist/esm-node/router-binding/history.js +1 -0
- package/dist/esm-node/router-binding/index.js +35 -0
- package/dist/esm-node/router-binding/lazyRouteComponent.js +30 -0
- package/dist/esm-node/router-binding/link.js +399 -0
- package/dist/esm-node/router-binding/matchContext.js +7 -0
- package/dist/esm-node/router-binding/nonRouteComponentContext.js +22 -0
- package/dist/esm-node/router-binding/not-found.js +49 -0
- package/dist/esm-node/router-binding/publicMatchData.js +447 -0
- package/dist/esm-node/router-binding/registryTransfer.js +210 -0
- package/dist/esm-node/router-binding/renderRouteNotFound.js +22 -0
- package/dist/esm-node/router-binding/route.js +162 -0
- package/dist/esm-node/router-binding/router.js +13 -0
- package/dist/esm-node/router-binding/routerContext.js +3 -0
- package/dist/esm-node/router-binding/routerStores.js +50 -0
- package/dist/esm-node/router-binding/scroll-restoration.js +12 -0
- package/dist/esm-node/router-binding/typePrimitives.js +1 -0
- package/dist/esm-node/router-binding/useBlocker.js +152 -0
- package/dist/esm-node/router-binding/useCanGoBack.js +7 -0
- package/dist/esm-node/router-binding/useLoaderData.js +9 -0
- package/dist/esm-node/router-binding/useLoaderDeps.js +8 -0
- package/dist/esm-node/router-binding/useLocation.js +14 -0
- package/dist/esm-node/router-binding/useMatch.js +28 -0
- package/dist/esm-node/router-binding/useNavigate.js +19 -0
- package/dist/esm-node/router-binding/useParams.js +13 -0
- package/dist/esm-node/router-binding/useRouteContext.js +8 -0
- package/dist/esm-node/router-binding/useRouter.js +10 -0
- package/dist/esm-node/router-binding/useRouterState.js +19 -0
- package/dist/esm-node/router-binding/useSearch.js +13 -0
- package/dist/esm-node/router-binding/utils.js +23 -0
- package/dist/esm-node/router.js +187 -0
- package/dist/esm-node/server.js +396 -0
- package/dist/types/actions.d.ts +45 -0
- package/dist/types/application-router.d.ts +5 -0
- package/dist/types/client.d.ts +23 -0
- package/dist/types/entry-application.d.ts +10 -0
- package/dist/types/entry-client.d.ts +5 -0
- package/dist/types/entry-server.d.ts +5 -0
- package/dist/types/federation-context.d.ts +16 -0
- package/dist/types/federation-ssr.d.ts +21 -0
- package/dist/types/federation.d.ts +30 -0
- package/dist/types/i18n/I18nProvider.d.ts +21 -0
- package/dist/types/i18n/LocalizedLink.d.ts +43 -0
- package/dist/types/i18n/context.d.ts +11 -0
- package/dist/types/i18n/index.d.ts +9 -0
- package/dist/types/i18n/languageSync.d.ts +31 -0
- package/dist/types/i18n/types.d.ts +33 -0
- package/dist/types/i18n/useI18n.d.ts +24 -0
- package/dist/types/index.d.ts +41 -0
- package/dist/types/manifest.d.ts +55 -0
- package/dist/types/native-promise-serialization.d.ts +9 -0
- package/dist/types/plugin/compiler.d.ts +6 -0
- package/dist/types/plugin/create.d.ts +21 -0
- package/dist/types/plugin/index.d.ts +3 -0
- package/dist/types/plugin/lazy-modules.d.cts +15 -0
- package/dist/types/plugin/preserve-import-loader.d.cts +3 -0
- package/dist/types/plugin/profile.d.ts +2 -0
- package/dist/types/plugin/solid-loader.d.cts +2 -0
- package/dist/types/plugin/svg-component-template.d.cts +6 -0
- package/dist/types/route-completion.d.ts +21 -0
- package/dist/types/route-data-error.d.ts +17 -0
- package/dist/types/router-binding/Asset.d.ts +3 -0
- package/dist/types/router-binding/CatchBoundary.d.ts +13 -0
- package/dist/types/router-binding/ClientOnly.d.ts +31 -0
- package/dist/types/router-binding/HeadContent.d.ts +13 -0
- package/dist/types/router-binding/Match.d.ts +6 -0
- package/dist/types/router-binding/Matches.d.ts +26 -0
- package/dist/types/router-binding/RouterProvider.d.ts +10 -0
- package/dist/types/router-binding/SafeFragment.d.ts +2 -0
- package/dist/types/router-binding/ScriptOnce.d.ts +6 -0
- package/dist/types/router-binding/Scripts.d.ts +2 -0
- package/dist/types/router-binding/ScrollRestoration.d.ts +14 -0
- package/dist/types/router-binding/Transitioner.d.ts +2 -0
- package/dist/types/router-binding/awaited.d.ts +11 -0
- package/dist/types/router-binding/fileRoute.d.ts +54 -0
- package/dist/types/router-binding/flightData.d.ts +38 -0
- package/dist/types/router-binding/headContentUtils.d.ts +15 -0
- package/dist/types/router-binding/history.d.ts +8 -0
- package/dist/types/router-binding/index.d.ts +45 -0
- package/dist/types/router-binding/lazyRouteComponent.d.ts +2 -0
- package/dist/types/router-binding/link.d.ts +43 -0
- package/dist/types/router-binding/matchContext.d.ts +7 -0
- package/dist/types/router-binding/nonRouteComponentContext.d.ts +5 -0
- package/dist/types/router-binding/not-found.d.ts +11 -0
- package/dist/types/router-binding/publicMatchData.d.ts +19 -0
- package/dist/types/router-binding/registryTransfer.d.ts +47 -0
- package/dist/types/router-binding/renderRouteNotFound.d.ts +11 -0
- package/dist/types/router-binding/route.d.ts +105 -0
- package/dist/types/router-binding/router.d.ts +70 -0
- package/dist/types/router-binding/routerContext.d.ts +3 -0
- package/dist/types/router-binding/routerStores.d.ts +2 -0
- package/dist/types/router-binding/scroll-restoration.d.ts +2 -0
- package/dist/types/router-binding/typePrimitives.d.ts +10 -0
- package/dist/types/router-binding/useBlocker.d.ts +70 -0
- package/dist/types/router-binding/useCanGoBack.d.ts +2 -0
- package/dist/types/router-binding/useLoaderData.d.ts +8 -0
- package/dist/types/router-binding/useLoaderDeps.d.ts +8 -0
- package/dist/types/router-binding/useLocation.d.ts +7 -0
- package/dist/types/router-binding/useMatch.d.ts +10 -0
- package/dist/types/router-binding/useNavigate.d.ts +5 -0
- package/dist/types/router-binding/useParams.d.ts +9 -0
- package/dist/types/router-binding/useRouteContext.d.ts +4 -0
- package/dist/types/router-binding/useRouter.d.ts +4 -0
- package/dist/types/router-binding/useRouterState.d.ts +8 -0
- package/dist/types/router-binding/useSearch.d.ts +9 -0
- package/dist/types/router-binding/utils.d.ts +25 -0
- package/dist/types/router.d.ts +31 -0
- package/dist/types/server.d.ts +47 -0
- package/package.json +123 -4
- package/src/actions.tsx +437 -0
- package/src/application-router.tsx +41 -0
- package/src/client.ts +106 -0
- package/src/entry-application.tsx +73 -0
- package/src/entry-client.tsx +48 -0
- package/src/entry-server.tsx +85 -0
- package/src/federation-context.ts +47 -0
- package/src/federation-ssr.ts +117 -0
- package/src/federation.tsx +193 -0
- package/src/i18n/I18nProvider.tsx +54 -0
- package/src/i18n/LocalizedLink.tsx +122 -0
- package/src/i18n/context.ts +13 -0
- package/src/i18n/index.ts +35 -0
- package/src/i18n/languageSync.ts +113 -0
- package/src/i18n/types.ts +35 -0
- package/src/i18n/useI18n.ts +121 -0
- package/src/index.ts +41 -0
- package/src/manifest.ts +337 -0
- package/src/native-promise-serialization.ts +167 -0
- package/src/plugin/compiler.ts +320 -0
- package/src/plugin/create.ts +270 -0
- package/src/plugin/index.ts +72 -0
- package/src/plugin/lazy-modules.cjs +146 -0
- package/src/plugin/preserve-import-loader.cjs +46 -0
- package/src/plugin/profile.ts +42 -0
- package/src/plugin/solid-loader.cjs +83 -0
- package/src/plugin/svg-component-template.cjs +19 -0
- package/src/route-completion.tsx +222 -0
- package/src/route-data-error.ts +175 -0
- package/src/router-binding/Asset.tsx +283 -0
- package/src/router-binding/CatchBoundary.tsx +130 -0
- package/src/router-binding/ClientOnly.tsx +76 -0
- package/src/router-binding/HeadContent.tsx +23 -0
- package/src/router-binding/LICENSE +21 -0
- package/src/router-binding/Match.tsx +397 -0
- package/src/router-binding/Matches.tsx +242 -0
- package/src/router-binding/PROVENANCE.json +94 -0
- package/src/router-binding/RouterProvider.tsx +129 -0
- package/src/router-binding/SafeFragment.tsx +5 -0
- package/src/router-binding/ScriptOnce.tsx +23 -0
- package/src/router-binding/Scripts.tsx +44 -0
- package/src/router-binding/ScrollRestoration.tsx +49 -0
- package/src/router-binding/Transitioner.tsx +172 -0
- package/src/router-binding/awaited.tsx +71 -0
- package/src/router-binding/fileRoute.ts +268 -0
- package/src/router-binding/flightData.ts +90 -0
- package/src/router-binding/headContentUtils.tsx +290 -0
- package/src/router-binding/history.ts +9 -0
- package/src/router-binding/index.tsx +318 -0
- package/src/router-binding/lazyRouteComponent.tsx +70 -0
- package/src/router-binding/link.tsx +865 -0
- package/src/router-binding/matchContext.tsx +15 -0
- package/src/router-binding/nonRouteComponentContext.tsx +23 -0
- package/src/router-binding/not-found.tsx +65 -0
- package/src/router-binding/publicMatchData.ts +674 -0
- package/src/router-binding/registryTransfer.ts +383 -0
- package/src/router-binding/renderRouteNotFound.tsx +53 -0
- package/src/router-binding/route.tsx +665 -0
- package/src/router-binding/router.ts +121 -0
- package/src/router-binding/routerContext.tsx +6 -0
- package/src/router-binding/routerStores.ts +85 -0
- package/src/router-binding/scroll-restoration.tsx +15 -0
- package/src/router-binding/typePrimitives.ts +74 -0
- package/src/router-binding/useBlocker.tsx +359 -0
- package/src/router-binding/useCanGoBack.ts +9 -0
- package/src/router-binding/useLoaderData.tsx +50 -0
- package/src/router-binding/useLoaderDeps.tsx +46 -0
- package/src/router-binding/useLocation.tsx +43 -0
- package/src/router-binding/useMatch.tsx +111 -0
- package/src/router-binding/useNavigate.tsx +43 -0
- package/src/router-binding/useParams.tsx +72 -0
- package/src/router-binding/useRouteContext.ts +30 -0
- package/src/router-binding/useRouter.tsx +17 -0
- package/src/router-binding/useRouterState.tsx +50 -0
- package/src/router-binding/useSearch.tsx +72 -0
- package/src/router-binding/utils.ts +59 -0
- package/src/router.ts +376 -0
- package/src/server.ts +645 -0
- package/README.md +0 -3
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
export type SolidAppSourceOptions = {
|
|
2
|
+
appId: string;
|
|
3
|
+
title: string;
|
|
4
|
+
entryName?: string;
|
|
5
|
+
appRole?: 'shell' | 'vertical';
|
|
6
|
+
capabilities: {
|
|
7
|
+
ssr: boolean;
|
|
8
|
+
federation: boolean;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type SolidAppSourceArtifact = {
|
|
13
|
+
path: string;
|
|
14
|
+
content: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type SolidAppSources = {
|
|
18
|
+
sourceExtension: '.tsx';
|
|
19
|
+
jsxImportSource: '@solidjs/web';
|
|
20
|
+
artifacts: SolidAppSourceArtifact[];
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/** The adapter owns the entry, route tree, document and hydration bootstrap. */
|
|
24
|
+
export function generateSolidAppSources(
|
|
25
|
+
options: SolidAppSourceOptions,
|
|
26
|
+
): SolidAppSources {
|
|
27
|
+
const entryName = options.entryName ?? 'main';
|
|
28
|
+
if (entryName !== 'main') {
|
|
29
|
+
throw new Error(
|
|
30
|
+
'The Solid app template supports the main entry only. The create-time workspace writer places src/modern-app-env.d.ts, src/routes/index.css and the package manifest at the app root regardless of entryName, so it cannot yet route a second entry into src/<entryName>/. Add that entry by hand after generation (mirror src/routes under src/<entryName>/routes) until an admitted native multi-entry create template exists; the native entry generator itself already supports arbitrary entry names.',
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
if (!options.appId.trim() || !options.title.trim()) {
|
|
34
|
+
throw new Error('The Solid app template requires an appId and title.');
|
|
35
|
+
}
|
|
36
|
+
if (
|
|
37
|
+
typeof options.capabilities.ssr !== 'boolean' ||
|
|
38
|
+
typeof options.capabilities.federation !== 'boolean'
|
|
39
|
+
) {
|
|
40
|
+
throw new Error('The Solid app template requires admitted capabilities.');
|
|
41
|
+
}
|
|
42
|
+
const title = JSON.stringify(options.title);
|
|
43
|
+
const aboutTitle = JSON.stringify(`${options.title} - About`);
|
|
44
|
+
const appId = JSON.stringify(options.appId);
|
|
45
|
+
return {
|
|
46
|
+
sourceExtension: '.tsx',
|
|
47
|
+
jsxImportSource: '@solidjs/web',
|
|
48
|
+
artifacts: [
|
|
49
|
+
{
|
|
50
|
+
path: 'src/routes/layout.tsx',
|
|
51
|
+
content: `import type { JSX } from '@solidjs/web';
|
|
52
|
+
import { Link, Outlet } from '@modern-js/renderer-solid/router';
|
|
53
|
+
import Stable from '../components/Stable';
|
|
54
|
+
import './index.css';
|
|
55
|
+
|
|
56
|
+
const appTitle = ${title};
|
|
57
|
+
|
|
58
|
+
export default function Layout(): JSX.Element {
|
|
59
|
+
return (
|
|
60
|
+
<main data-testid="native-layout">
|
|
61
|
+
<header>
|
|
62
|
+
<p>{appTitle}</p>
|
|
63
|
+
<nav aria-label="Application">
|
|
64
|
+
<Link to="/">Home</Link>
|
|
65
|
+
<Link to="/about">About</Link>
|
|
66
|
+
${options.capabilities.federation ? ' <Link to="/remotes">Federated applications</Link>\n' : ''}
|
|
67
|
+
</nav>
|
|
68
|
+
</header>
|
|
69
|
+
<Stable />
|
|
70
|
+
<Outlet />
|
|
71
|
+
</main>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
`,
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
path: 'src/routes/page.tsx',
|
|
78
|
+
content: `import type { JSX } from '@solidjs/web';
|
|
79
|
+
import {
|
|
80
|
+
ActionForm,
|
|
81
|
+
Link,
|
|
82
|
+
useLoaderData,
|
|
83
|
+
useRouteAction,
|
|
84
|
+
} from '@modern-js/renderer-solid/router';
|
|
85
|
+
import Counter from '../components/Counter';
|
|
86
|
+
|
|
87
|
+
const appId = ${appId};
|
|
88
|
+
const appTitle = ${title};
|
|
89
|
+
|
|
90
|
+
export default function HomePage(): JSX.Element {
|
|
91
|
+
const data = useLoaderData({ strict: false });
|
|
92
|
+
const action = useRouteAction();
|
|
93
|
+
return (
|
|
94
|
+
<section data-app-id={appId} data-testid="native-route" data-renderer="solid">
|
|
95
|
+
<h1>{appTitle}</h1>
|
|
96
|
+
<Counter />
|
|
97
|
+
<pre data-testid="native-loader-value">{JSON.stringify(data())}</pre>
|
|
98
|
+
<ActionForm action={action}>
|
|
99
|
+
<label>
|
|
100
|
+
Name <input name="name" />
|
|
101
|
+
</label>
|
|
102
|
+
<button type="submit" disabled={action.pending()}>
|
|
103
|
+
Save
|
|
104
|
+
</button>
|
|
105
|
+
<button type="submit" name="intent" value="redirect">
|
|
106
|
+
Save and redirect
|
|
107
|
+
</button>
|
|
108
|
+
</ActionForm>
|
|
109
|
+
<pre data-testid="native-action-value">
|
|
110
|
+
{JSON.stringify(action.outcome())}
|
|
111
|
+
</pre>
|
|
112
|
+
<output data-testid="native-action-error">
|
|
113
|
+
{action.error()?.message}
|
|
114
|
+
</output>
|
|
115
|
+
<Link to="/about">Open native about route</Link>
|
|
116
|
+
</section>
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
`,
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
path: 'src/routes/page.head.ts',
|
|
123
|
+
content: `import type { FileSystemRouteModule } from '@modern-js/renderer-solid/router';
|
|
124
|
+
|
|
125
|
+
export const head: NonNullable<FileSystemRouteModule['head']> = () => ({
|
|
126
|
+
meta: [
|
|
127
|
+
{ title: ${title} },
|
|
128
|
+
{ name: 'description', content: 'Built with the native Solid renderer' },
|
|
129
|
+
],
|
|
130
|
+
});
|
|
131
|
+
`,
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
path: 'src/routes/about/page.tsx',
|
|
135
|
+
content: `import type { JSX } from '@solidjs/web';
|
|
136
|
+
import { Link } from '@modern-js/renderer-solid/router';
|
|
137
|
+
|
|
138
|
+
export default function AboutPage(): JSX.Element {
|
|
139
|
+
return (
|
|
140
|
+
<section data-testid="native-about">
|
|
141
|
+
<h1>Native Solid navigation</h1>
|
|
142
|
+
<Link to="/">Home</Link>
|
|
143
|
+
</section>
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
`,
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
path: 'src/routes/about/page.head.ts',
|
|
150
|
+
content: `import type { FileSystemRouteModule } from '@modern-js/renderer-solid/router';
|
|
151
|
+
|
|
152
|
+
export const head: NonNullable<FileSystemRouteModule['head']> = () => ({
|
|
153
|
+
meta: [
|
|
154
|
+
{ title: ${aboutTitle} },
|
|
155
|
+
{ name: 'description', content: 'Built with the native Solid renderer' },
|
|
156
|
+
],
|
|
157
|
+
});
|
|
158
|
+
`,
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
path: 'src/routes/page.data.ts',
|
|
162
|
+
content: `import type { DataHandlerInput } from '@modern-js/renderer-core/data';
|
|
163
|
+
|
|
164
|
+
export function loader({ request }: DataHandlerInput) {
|
|
165
|
+
const url = new URL(request.url);
|
|
166
|
+
if (url.searchParams.get('case') === 'not-found')
|
|
167
|
+
throw new Response('Native route not found', { status: 404 });
|
|
168
|
+
if (url.searchParams.get('case') === 'error')
|
|
169
|
+
throw new Error('Native loader failure');
|
|
170
|
+
if (url.searchParams.get('case') === 'redirect')
|
|
171
|
+
return new Response(null, { status: 302, headers: { location: '/about' } });
|
|
172
|
+
return {
|
|
173
|
+
message: 'Native loader value',
|
|
174
|
+
privateValue: request.headers.get('x-conformance-private'),
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export async function action({ request }: DataHandlerInput) {
|
|
179
|
+
const form = await request.formData();
|
|
180
|
+
const name = form.get('name');
|
|
181
|
+
if (typeof name !== 'string' || !name.trim())
|
|
182
|
+
return Response.json(
|
|
183
|
+
{ fieldErrors: { name: 'Name required' } },
|
|
184
|
+
{ status: 422 },
|
|
185
|
+
);
|
|
186
|
+
if (form.get('intent') === 'redirect')
|
|
187
|
+
return new Response(null, {
|
|
188
|
+
status: 303,
|
|
189
|
+
headers: {
|
|
190
|
+
location: '/about',
|
|
191
|
+
'set-cookie': 'conformance-saved=1; Path=/; SameSite=Lax',
|
|
192
|
+
},
|
|
193
|
+
});
|
|
194
|
+
if (form.get('intent') === 'throw') throw new Error('Native action failure');
|
|
195
|
+
return {
|
|
196
|
+
saved: name,
|
|
197
|
+
privateValue: request.headers.get('x-conformance-private'),
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
`,
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
path: 'src/routes/error.tsx',
|
|
204
|
+
content: `import type { ErrorRouteComponent } from '@modern-js/renderer-solid/router';
|
|
205
|
+
|
|
206
|
+
const ErrorBoundary: ErrorRouteComponent = props => (
|
|
207
|
+
<section data-testid="native-error">
|
|
208
|
+
<h1>Something went wrong</h1>
|
|
209
|
+
<output>
|
|
210
|
+
{props.error instanceof Error ? props.error.message : String(props.error)}
|
|
211
|
+
</output>
|
|
212
|
+
</section>
|
|
213
|
+
);
|
|
214
|
+
|
|
215
|
+
export default ErrorBoundary;
|
|
216
|
+
`,
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
path: 'src/routes/not-found.tsx',
|
|
220
|
+
content: `import type { NotFoundRouteComponent } from '@modern-js/renderer-solid/router';
|
|
221
|
+
|
|
222
|
+
const NotFound: NotFoundRouteComponent = () => (
|
|
223
|
+
<section data-testid="native-not-found">
|
|
224
|
+
<h1>Page not found</h1>
|
|
225
|
+
</section>
|
|
226
|
+
);
|
|
227
|
+
|
|
228
|
+
export default NotFound;
|
|
229
|
+
`,
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
path: 'src/components/Counter.tsx',
|
|
233
|
+
content: `import type { JSX } from '@solidjs/web';
|
|
234
|
+
import { createSignal } from 'solid-js';
|
|
235
|
+
|
|
236
|
+
export default function Counter(): JSX.Element {
|
|
237
|
+
const [count, setCount] = createSignal(0);
|
|
238
|
+
return (
|
|
239
|
+
<section data-testid="native-edited-component">
|
|
240
|
+
<span data-testid="native-hmr-marker">Counter before native edit</span>
|
|
241
|
+
<button type="button" onClick={() => setCount(count() + 1)}>
|
|
242
|
+
Increment
|
|
243
|
+
</button>
|
|
244
|
+
<output data-testid="native-count">{count()}</output>
|
|
245
|
+
</section>
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
`,
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
path: 'src/components/Stable.tsx',
|
|
252
|
+
content: `import type { JSX } from '@solidjs/web';
|
|
253
|
+
import { createSignal } from 'solid-js';
|
|
254
|
+
|
|
255
|
+
export default function Stable(): JSX.Element {
|
|
256
|
+
const [count, setCount] = createSignal(0);
|
|
257
|
+
return (
|
|
258
|
+
<section data-testid="native-unaffected-component">
|
|
259
|
+
<button type="button" onClick={() => setCount(count() + 1)}>
|
|
260
|
+
Increment stable state
|
|
261
|
+
</button>
|
|
262
|
+
<output data-testid="native-unaffected-count">{count()}</output>
|
|
263
|
+
</section>
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
`,
|
|
267
|
+
},
|
|
268
|
+
],
|
|
269
|
+
};
|
|
270
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import {
|
|
3
|
+
defineRendererAdapter,
|
|
4
|
+
type NativeRendererAdapter,
|
|
5
|
+
nativeRendererDependencies,
|
|
6
|
+
} from '@modern-js/renderer-core/adapter';
|
|
7
|
+
import { compilerArtifacts } from '../manifest';
|
|
8
|
+
import { pluginSolidRenderer, pluginSourceDirectory } from './compiler';
|
|
9
|
+
import { generateSolidAppSources } from './create';
|
|
10
|
+
import { solidProfile } from './profile';
|
|
11
|
+
|
|
12
|
+
/** The build-side Solid renderer adapter UltraModern loads for `renderer: 'solid'`. */
|
|
13
|
+
export const rendererAdapter: NativeRendererAdapter<'solid'> =
|
|
14
|
+
defineRendererAdapter({
|
|
15
|
+
name: 'solid',
|
|
16
|
+
kind: 'native',
|
|
17
|
+
profile: solidProfile,
|
|
18
|
+
routerFrameworks: ['solid'],
|
|
19
|
+
runtime: {
|
|
20
|
+
package: 'solid-js',
|
|
21
|
+
bootstrap: '@modern-js/renderer-solid',
|
|
22
|
+
entryClient: '@modern-js/renderer-solid/entry-client',
|
|
23
|
+
entryServer: '@modern-js/renderer-solid/entry-server',
|
|
24
|
+
router: '@modern-js/renderer-solid/router',
|
|
25
|
+
i18n: '@modern-js/renderer-solid/i18n',
|
|
26
|
+
manifest: '@modern-js/renderer-solid/manifest',
|
|
27
|
+
},
|
|
28
|
+
federation: {
|
|
29
|
+
library: 'module',
|
|
30
|
+
ssr: true,
|
|
31
|
+
shared: [
|
|
32
|
+
'solid-js',
|
|
33
|
+
'@solidjs/web',
|
|
34
|
+
'@solidjs/signals',
|
|
35
|
+
'seroval',
|
|
36
|
+
'seroval-plugins',
|
|
37
|
+
'@modern-js/renderer-solid',
|
|
38
|
+
'@modern-js/renderer-solid/client',
|
|
39
|
+
'@modern-js/renderer-solid/router',
|
|
40
|
+
'@modern-js/renderer-solid/federation',
|
|
41
|
+
'@modern-js/renderer-core',
|
|
42
|
+
'@modern-js/renderer-core/',
|
|
43
|
+
'@tanstack/router-core',
|
|
44
|
+
'@tanstack/history',
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
worker: { nativeDocuments: true, rsc: false },
|
|
48
|
+
lazyStyles: 'renderer',
|
|
49
|
+
svgComponentTemplate: () =>
|
|
50
|
+
path.join(pluginSourceDirectory(), 'svg-component-template.cjs'),
|
|
51
|
+
compiler: pluginSolidRenderer,
|
|
52
|
+
artifacts: compilerArtifacts,
|
|
53
|
+
create: {
|
|
54
|
+
templates: { federation: true, workers: false },
|
|
55
|
+
dependencies: profile => ({
|
|
56
|
+
frameworkDependencies: [
|
|
57
|
+
'@modern-js/renderer-core',
|
|
58
|
+
'@modern-js/renderer-solid',
|
|
59
|
+
],
|
|
60
|
+
dependencies: {
|
|
61
|
+
...nativeRendererDependencies(profile),
|
|
62
|
+
'solid-js': profile.hydration.version,
|
|
63
|
+
'@solidjs/signals': profile.hydration.version,
|
|
64
|
+
},
|
|
65
|
+
devDependencies: {
|
|
66
|
+
[profile.compiler.name]: profile.compiler.version,
|
|
67
|
+
'@solidjs/babel-plugin': profile.compiler.version,
|
|
68
|
+
},
|
|
69
|
+
}),
|
|
70
|
+
generateAppSources: generateSolidAppSources,
|
|
71
|
+
},
|
|
72
|
+
});
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
const fs = require('node:fs');
|
|
2
|
+
const path = require('node:path');
|
|
3
|
+
const { createHash } = require('node:crypto');
|
|
4
|
+
const babel = require('@babel/core');
|
|
5
|
+
const compiler = require('@solidjs/compiler');
|
|
6
|
+
|
|
7
|
+
const markerPrefix = '__SOLID_LAZY_MODULE__:';
|
|
8
|
+
const extensions = ['.tsx', '.ts', '.jsx', '.js'];
|
|
9
|
+
|
|
10
|
+
function resolveLazyModule(
|
|
11
|
+
filename,
|
|
12
|
+
specifier,
|
|
13
|
+
projectRoot,
|
|
14
|
+
sourceExtensions = extensions,
|
|
15
|
+
dependencies,
|
|
16
|
+
) {
|
|
17
|
+
const split = specifier.search(/[?#]/);
|
|
18
|
+
const pathname = split < 0 ? specifier : specifier.slice(0, split);
|
|
19
|
+
const suffix = split < 0 ? '' : specifier.slice(split);
|
|
20
|
+
if (!pathname.startsWith('.') && !path.isAbsolute(pathname)) {
|
|
21
|
+
throw new Error(
|
|
22
|
+
`Solid lazy import ${specifier} in ${filename} must name a static relative or absolute application module. Render Module Federation remotes with federatedComponent('${pathname}') from @modern-js/renderer-solid/federation`,
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
const requested = path.resolve(path.dirname(filename), pathname);
|
|
26
|
+
const requestedRelative = path.relative(projectRoot, requested);
|
|
27
|
+
if (
|
|
28
|
+
requestedRelative === '..' ||
|
|
29
|
+
requestedRelative.startsWith(`..${path.sep}`) ||
|
|
30
|
+
path.isAbsolute(requestedRelative)
|
|
31
|
+
) {
|
|
32
|
+
throw new Error(
|
|
33
|
+
`Solid lazy module ${requested} must belong to the application source tree`,
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
const candidates = [
|
|
37
|
+
requested,
|
|
38
|
+
...sourceExtensions.map(extension => requested + extension),
|
|
39
|
+
...sourceExtensions.map(extension =>
|
|
40
|
+
path.join(requested, `index${extension}`),
|
|
41
|
+
),
|
|
42
|
+
];
|
|
43
|
+
const resolved = candidates.find(
|
|
44
|
+
candidate => fs.existsSync(candidate) && fs.statSync(candidate).isFile(),
|
|
45
|
+
);
|
|
46
|
+
if (!resolved) {
|
|
47
|
+
for (const candidate of candidates) dependencies?.missing.add(candidate);
|
|
48
|
+
throw new Error(
|
|
49
|
+
`Cannot resolve Solid lazy module ${specifier} from ${filename}`,
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
dependencies?.files.add(resolved);
|
|
53
|
+
const relative = path.relative(projectRoot, resolved);
|
|
54
|
+
if (relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative)) {
|
|
55
|
+
throw new Error(
|
|
56
|
+
`Solid lazy module ${resolved} must belong to the application source tree`,
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
filename: resolved,
|
|
61
|
+
request: resolved + suffix,
|
|
62
|
+
key: relative.split(path.sep).join('/') + suffix,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function markerVisitor(onMarker) {
|
|
67
|
+
return {
|
|
68
|
+
StringLiteral(marker) {
|
|
69
|
+
if (
|
|
70
|
+
marker.key === 2 &&
|
|
71
|
+
marker.listKey === 'arguments' &&
|
|
72
|
+
marker.parentPath.isCallExpression() &&
|
|
73
|
+
marker.node.value.startsWith(markerPrefix)
|
|
74
|
+
) {
|
|
75
|
+
onMarker(marker, marker.node.value.slice(markerPrefix.length));
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function collectLazyModules(
|
|
82
|
+
projectRoot,
|
|
83
|
+
entryDirectories = [],
|
|
84
|
+
sourceExtensions = extensions,
|
|
85
|
+
dependencies,
|
|
86
|
+
) {
|
|
87
|
+
const root = path.join(projectRoot, 'src');
|
|
88
|
+
const found = new Map();
|
|
89
|
+
const visited = new Set();
|
|
90
|
+
const walk = directory => {
|
|
91
|
+
dependencies?.contexts.add(directory);
|
|
92
|
+
if (!fs.existsSync(directory) || visited.has(directory)) return;
|
|
93
|
+
visited.add(directory);
|
|
94
|
+
for (const item of fs
|
|
95
|
+
.readdirSync(directory, { withFileTypes: true })
|
|
96
|
+
.sort((a, b) => a.name.localeCompare(b.name))) {
|
|
97
|
+
const filename = path.join(directory, item.name);
|
|
98
|
+
if (item.isDirectory()) {
|
|
99
|
+
if (item.name !== 'node_modules') walk(filename);
|
|
100
|
+
} else if (
|
|
101
|
+
/\.[jt]sx?$/.test(item.name) &&
|
|
102
|
+
!/\.d\.[cm]?ts$/.test(item.name)
|
|
103
|
+
) {
|
|
104
|
+
dependencies?.files.add(filename);
|
|
105
|
+
try {
|
|
106
|
+
const source = fs.readFileSync(filename, 'utf8');
|
|
107
|
+
const lazy = compiler.transformLazy(source, {
|
|
108
|
+
filename,
|
|
109
|
+
sourceMap: false,
|
|
110
|
+
});
|
|
111
|
+
const ast = babel.parseSync(lazy.code, {
|
|
112
|
+
filename,
|
|
113
|
+
babelrc: false,
|
|
114
|
+
configFile: false,
|
|
115
|
+
parserOpts: { plugins: ['typescript', 'jsx'] },
|
|
116
|
+
});
|
|
117
|
+
babel.traverse(
|
|
118
|
+
ast,
|
|
119
|
+
markerVisitor((_marker, specifier) => {
|
|
120
|
+
const module = resolveLazyModule(
|
|
121
|
+
filename,
|
|
122
|
+
specifier,
|
|
123
|
+
projectRoot,
|
|
124
|
+
sourceExtensions,
|
|
125
|
+
dependencies,
|
|
126
|
+
);
|
|
127
|
+
found.set(module.key, {
|
|
128
|
+
...module,
|
|
129
|
+
entryName: `solid-lazy-${createHash('sha256').update(module.key).digest('hex').slice(0, 16)}`,
|
|
130
|
+
});
|
|
131
|
+
}),
|
|
132
|
+
);
|
|
133
|
+
} catch (error) {
|
|
134
|
+
throw new Error(
|
|
135
|
+
`Solid lazy discovery failed in ${filename}: ${error instanceof Error ? error.message : String(error)}`,
|
|
136
|
+
{ cause: error },
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
for (const directory of [root, ...entryDirectories]) walk(directory);
|
|
143
|
+
return [...found.values()].sort((a, b) => a.key.localeCompare(b.key));
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
module.exports = { collectLazyModules, markerVisitor, resolveLazyModule };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const babel = require('@babel/core');
|
|
2
|
+
|
|
3
|
+
/** Preserve the native runtime's browser URL import without patching its file. */
|
|
4
|
+
module.exports = function preserveSolidImport(source, inputMap) {
|
|
5
|
+
const callback = this.async();
|
|
6
|
+
let matched = 0;
|
|
7
|
+
try {
|
|
8
|
+
const result = babel.transformSync(source, {
|
|
9
|
+
filename: this.resourcePath,
|
|
10
|
+
babelrc: false,
|
|
11
|
+
configFile: false,
|
|
12
|
+
sourceMaps: true,
|
|
13
|
+
inputSourceMap:
|
|
14
|
+
typeof inputMap === 'string' ? JSON.parse(inputMap) : inputMap,
|
|
15
|
+
plugins: [
|
|
16
|
+
() => ({
|
|
17
|
+
visitor: {
|
|
18
|
+
CallExpression(call) {
|
|
19
|
+
if (
|
|
20
|
+
call.node.callee.type === 'Import' &&
|
|
21
|
+
call.node.arguments.length === 1 &&
|
|
22
|
+
call.node.arguments[0].type === 'Identifier' &&
|
|
23
|
+
call.node.arguments[0].name === 'entryUrl'
|
|
24
|
+
) {
|
|
25
|
+
const argument = call.node.arguments[0];
|
|
26
|
+
argument.leadingComments = [
|
|
27
|
+
...(argument.leadingComments ?? []),
|
|
28
|
+
{ type: 'CommentBlock', value: ' webpackIgnore: true ' },
|
|
29
|
+
];
|
|
30
|
+
matched++;
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
}),
|
|
35
|
+
],
|
|
36
|
+
});
|
|
37
|
+
if (matched !== 1 || !result) {
|
|
38
|
+
throw new Error(
|
|
39
|
+
'Solid native browser URL import contract changed. Expected one import(entryUrl) in @solidjs/web 2.0.0-rc.13; update and revalidate the compiler integration.',
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
callback(null, result.code, result.map);
|
|
43
|
+
} catch (error) {
|
|
44
|
+
callback(error);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { RendererBuildProfile } from '@modern-js/renderer-core/adapter';
|
|
2
|
+
|
|
3
|
+
export const solidProfile: RendererBuildProfile<'solid'> = {
|
|
4
|
+
renderer: 'solid',
|
|
5
|
+
status: 'preview',
|
|
6
|
+
protocolVersion: 1,
|
|
7
|
+
minimumNode: '26.10.0',
|
|
8
|
+
hmr: {
|
|
9
|
+
editedBoundary: 'may-reset',
|
|
10
|
+
unaffectedComponents: 'preserved',
|
|
11
|
+
document: 'preserved',
|
|
12
|
+
roots: 'single',
|
|
13
|
+
cleanup: 'exactly-once',
|
|
14
|
+
},
|
|
15
|
+
compiler: { name: '@solidjs/compiler', version: '2.0.0-rc.13' },
|
|
16
|
+
hydration: { name: '@solidjs/web', version: '2.0.0-rc.13' },
|
|
17
|
+
router: {
|
|
18
|
+
name: '@modern-js/renderer-solid',
|
|
19
|
+
version: '3.8.3',
|
|
20
|
+
coreName: '@tanstack/router-core',
|
|
21
|
+
coreVersion: '1.171.34',
|
|
22
|
+
},
|
|
23
|
+
sourceExtensions: ['.tsx', '.ts', '.jsx', '.js'],
|
|
24
|
+
jsxImportSource: '@solidjs/web',
|
|
25
|
+
dependencies: {
|
|
26
|
+
'solid-js': '2.0.0-rc.13',
|
|
27
|
+
'@solidjs/web': '2.0.0-rc.13',
|
|
28
|
+
'@solidjs/signals': '2.0.0-rc.13',
|
|
29
|
+
'@solidjs/compiler': '2.0.0-rc.13',
|
|
30
|
+
'@modern-js/renderer-solid': '3.8.3',
|
|
31
|
+
seroval: '1.6.8',
|
|
32
|
+
'seroval-plugins': '1.6.8',
|
|
33
|
+
},
|
|
34
|
+
capabilities: {
|
|
35
|
+
worker: true,
|
|
36
|
+
moduleFederation: true,
|
|
37
|
+
rsc: false,
|
|
38
|
+
ssg: true,
|
|
39
|
+
i18n: true,
|
|
40
|
+
svgComponent: true,
|
|
41
|
+
},
|
|
42
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
const babel = require('@babel/core');
|
|
2
|
+
const compiler = require('@solidjs/compiler');
|
|
3
|
+
const { markerVisitor, resolveLazyModule } = require('./lazy-modules.cjs');
|
|
4
|
+
|
|
5
|
+
module.exports = async function solidLoader(source, inputMap) {
|
|
6
|
+
const callback = this.async();
|
|
7
|
+
const { projectRoot, server, isProd, sourceExtensions } = this.getOptions();
|
|
8
|
+
const filename = this.resourcePath;
|
|
9
|
+
const maps = [];
|
|
10
|
+
const step = result => {
|
|
11
|
+
if (!result || typeof result.code !== 'string') {
|
|
12
|
+
throw new Error(
|
|
13
|
+
`The native Solid compiler produced no code for ${filename}`,
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
if (result.map)
|
|
17
|
+
maps.unshift(
|
|
18
|
+
typeof result.map === 'string' ? JSON.parse(result.map) : result.map,
|
|
19
|
+
);
|
|
20
|
+
return result.code;
|
|
21
|
+
};
|
|
22
|
+
try {
|
|
23
|
+
const { default: remapping } = await import('@jridgewell/remapping');
|
|
24
|
+
if (inputMap)
|
|
25
|
+
maps.push(typeof inputMap === 'string' ? JSON.parse(inputMap) : inputMap);
|
|
26
|
+
let code = step(
|
|
27
|
+
compiler.transformLazy(source, { filename, sourceMap: true }),
|
|
28
|
+
);
|
|
29
|
+
code = step(
|
|
30
|
+
babel.transformSync(code, {
|
|
31
|
+
filename,
|
|
32
|
+
babelrc: false,
|
|
33
|
+
configFile: false,
|
|
34
|
+
sourceMaps: true,
|
|
35
|
+
parserOpts: { plugins: ['typescript', 'jsx'] },
|
|
36
|
+
plugins: [
|
|
37
|
+
() => ({
|
|
38
|
+
visitor: markerVisitor((marker, specifier) => {
|
|
39
|
+
const module = resolveLazyModule(
|
|
40
|
+
filename,
|
|
41
|
+
specifier,
|
|
42
|
+
projectRoot,
|
|
43
|
+
sourceExtensions,
|
|
44
|
+
);
|
|
45
|
+
this.addDependency(module.filename);
|
|
46
|
+
marker.node.value = module.key;
|
|
47
|
+
}),
|
|
48
|
+
}),
|
|
49
|
+
],
|
|
50
|
+
}),
|
|
51
|
+
);
|
|
52
|
+
const applicationSource =
|
|
53
|
+
!filename.includes('/node_modules/') ||
|
|
54
|
+
filename.includes('/node_modules/.modern-js/solid/');
|
|
55
|
+
if (!server && !isProd && applicationSource) {
|
|
56
|
+
code = step(
|
|
57
|
+
compiler.transformRefresh(code, {
|
|
58
|
+
filename,
|
|
59
|
+
bundler: 'standard',
|
|
60
|
+
importSource: 'solid-js/refresh',
|
|
61
|
+
jsx: false,
|
|
62
|
+
fixRender: true,
|
|
63
|
+
granular: true,
|
|
64
|
+
sourceMap: true,
|
|
65
|
+
}),
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
code = step(
|
|
69
|
+
compiler.transform(code, {
|
|
70
|
+
filename,
|
|
71
|
+
moduleName: '@solidjs/web',
|
|
72
|
+
generate: server ? 'ssr' : 'dom',
|
|
73
|
+
hydratable: true,
|
|
74
|
+
dev: !isProd,
|
|
75
|
+
sourceMap: true,
|
|
76
|
+
}),
|
|
77
|
+
);
|
|
78
|
+
const map = maps.length ? remapping(maps, () => null) : undefined;
|
|
79
|
+
callback(null, code, map);
|
|
80
|
+
} catch (error) {
|
|
81
|
+
callback(error);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Solid sets unknown SVG props as attributes, accepts `class`, and renders
|
|
2
|
+
// `innerHTML` as children during SSR and hydration.
|
|
3
|
+
module.exports = ({
|
|
4
|
+
attributes,
|
|
5
|
+
markup,
|
|
6
|
+
origin,
|
|
7
|
+
}) => `/** @jsxImportSource @solidjs/web */
|
|
8
|
+
// Generated by UltraModern from ${origin}. Do not edit.
|
|
9
|
+
import type { JSX } from '@solidjs/web';
|
|
10
|
+
|
|
11
|
+
const attributes: { readonly [name: string]: string } = ${attributes};
|
|
12
|
+
const markup = ${markup};
|
|
13
|
+
|
|
14
|
+
export default function SvgComponent(
|
|
15
|
+
props: { readonly [name: string]: unknown },
|
|
16
|
+
): JSX.Element {
|
|
17
|
+
return <svg {...attributes} {...props} innerHTML={markup} />;
|
|
18
|
+
}
|
|
19
|
+
`;
|