@solidjs/vite-plugin 3.0.0-next.33 → 3.0.0-next.34
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/README.md +9 -9
- package/dist/cjs/index.cjs +255 -40
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.mjs +255 -40
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/src/diagnostics/index.d.ts +5 -0
- package/dist/types/src/index.d.ts +17 -5
- package/dist/types/src/server-functions/compile.d.ts +1 -1
- package/dist/types/src/ssr/index.d.ts +1 -0
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -693,8 +693,8 @@ your entry files instead. See `examples/start-ssr` for a complete page.
|
|
|
693
693
|
- Default: `"native"`
|
|
694
694
|
|
|
695
695
|
Choose the JSX compiler backend. The default `"native"` compiles JSX through
|
|
696
|
-
the native compiler from `@
|
|
697
|
-
|
|
696
|
+
the native compiler from `@solidjs/compiler`. `"babel"` runs
|
|
697
|
+
`@solidjs/babel-plugin` instead and only switches the JSX transform — every
|
|
698
698
|
other pass (the `lazy()` module-URL transform and the solid-refresh HMR
|
|
699
699
|
transform) is native in both modes.
|
|
700
700
|
|
|
@@ -702,7 +702,7 @@ transform) is native in both modes.
|
|
|
702
702
|
you expect, set `compiler: 'babel'` and file an issue — the behavioral diff
|
|
703
703
|
between the two modes is the bug report. Platforms without a prebuilt native
|
|
704
704
|
binary (for example StackBlitz WebContainers) automatically fall back to the
|
|
705
|
-
`@
|
|
705
|
+
`@solidjs/compiler-wasm32-wasi` build, so no configuration is needed
|
|
706
706
|
there.
|
|
707
707
|
|
|
708
708
|
```ts
|
|
@@ -723,13 +723,13 @@ Pass any additional [babel transform options](https://babeljs.io/docs/en/options
|
|
|
723
723
|
|
|
724
724
|
#### options.solid
|
|
725
725
|
|
|
726
|
-
- Type: [@
|
|
726
|
+
- Type: [@solidjs/compiler](https://github.com/solidjs/solid/tree/main/packages/compiler) / [@solidjs/babel-plugin](https://github.com/solidjs/solid/tree/main/packages/babel-plugin)
|
|
727
727
|
- Default: {}
|
|
728
728
|
|
|
729
|
-
Pass additional
|
|
730
|
-
|
|
731
|
-
context, and conditional wrapping)
|
|
732
|
-
selected.
|
|
729
|
+
Pass additional Solid JSX compiler options. Both backends carry the Solid
|
|
730
|
+
defaults (`moduleName: "@solidjs/web"`, the control-flow built-ins,
|
|
731
|
+
custom-element context, and conditional wrapping) internally; anything set
|
|
732
|
+
here is merged over them and applied to whichever backend is selected.
|
|
733
733
|
|
|
734
734
|
#### options.typescript
|
|
735
735
|
|
|
@@ -778,7 +778,7 @@ plugin's errors are prefixed `[@solidjs/vite-plugin]`.
|
|
|
778
778
|
## Note on HMR
|
|
779
779
|
|
|
780
780
|
Starting from version `1.1.0`, this plugin handles automatic HMR. The refresh
|
|
781
|
-
transform is compiled natively by `@
|
|
781
|
+
transform is compiled natively by `@solidjs/compiler` and drives the
|
|
782
782
|
dev-only `solid-js/refresh` runtime entry that ships with Solid (the
|
|
783
783
|
standalone [solid-refresh](https://github.com/solidjs/solid-refresh) package
|
|
784
784
|
is no longer used).
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var babel = require('@babel/core');
|
|
6
6
|
var remapping = require('@ampproject/remapping');
|
|
7
|
-
var solid = require('babel-
|
|
7
|
+
var solid = require('@solidjs/babel-plugin');
|
|
8
8
|
var fs = require('fs');
|
|
9
9
|
var mergeAnything = require('merge-anything');
|
|
10
10
|
var module$1 = require('module');
|
|
@@ -501,6 +501,27 @@ function createDevAssetResolver(server, filter = defaultStyleFilter) {
|
|
|
501
501
|
};
|
|
502
502
|
}
|
|
503
503
|
|
|
504
|
+
/**
|
|
505
|
+
* Cross-instance-safe stand-in for vite's `isRunnableDevEnvironment`.
|
|
506
|
+
*
|
|
507
|
+
* Vite's helper is an `instanceof RunnableDevEnvironment` check against the
|
|
508
|
+
* class of whichever `vite` module the CALLER imported. When this plugin is
|
|
509
|
+
* consumed through a workspace/`link:` install, its own `vite` import can
|
|
510
|
+
* resolve to a different physical copy than the one running the dev server —
|
|
511
|
+
* and then the `instanceof` is false for every environment, silently standing
|
|
512
|
+
* the SSR/dev middlewares down. The `runner` accessor is the type's defining
|
|
513
|
+
* member (`RunnableDevEnvironment` is exactly "a DevEnvironment with a
|
|
514
|
+
* runner"), so presence-check it instead of trusting class identity.
|
|
515
|
+
*/
|
|
516
|
+
function isRunnableEnvironment(environment) {
|
|
517
|
+
return !!environment && typeof environment === 'object' && 'runner' in environment;
|
|
518
|
+
}
|
|
519
|
+
function getEnvironmentConsumer(environment, options) {
|
|
520
|
+
const consumer = environment?.config?.consumer;
|
|
521
|
+
if (consumer === 'client' || consumer === 'server') return consumer;
|
|
522
|
+
return options?.ssr ? 'server' : 'client';
|
|
523
|
+
}
|
|
524
|
+
|
|
504
525
|
const VIRTUAL_ID = '\0@solidjs/vite-plugin:boundary-modules';
|
|
505
526
|
|
|
506
527
|
/**
|
|
@@ -535,7 +556,7 @@ function boundaryModules() {
|
|
|
535
556
|
// scan all the same. Real dev/build module graphs resolve without
|
|
536
557
|
// the flag and stay fully guarded.
|
|
537
558
|
const scan = !!options?.scan;
|
|
538
|
-
const server = this.environment
|
|
559
|
+
const server = getEnvironmentConsumer(this.environment, options) === 'server';
|
|
539
560
|
if (id === 'server-only') {
|
|
540
561
|
if (!server && !scan) this.error(`[@solidjs/vite-plugin] Attempt to import 'server-only' in a client module: ${importer}. ` + `Code that uses this module must run only on the server — make sure it is only ` + `imported by server code (e.g. a server entry, a "use server" module, or code ` + `reached exclusively from them).`);
|
|
541
562
|
} else if (id === 'client-only') {
|
|
@@ -552,31 +573,206 @@ function boundaryModules() {
|
|
|
552
573
|
}
|
|
553
574
|
|
|
554
575
|
/**
|
|
555
|
-
*
|
|
576
|
+
* Agent diagnostics surface (`diagnostics: true`, dev serve only).
|
|
556
577
|
*
|
|
557
|
-
*
|
|
558
|
-
*
|
|
559
|
-
*
|
|
560
|
-
*
|
|
561
|
-
*
|
|
562
|
-
*
|
|
563
|
-
*
|
|
564
|
-
*
|
|
578
|
+
* Three pieces:
|
|
579
|
+
* - an injected client module (virtual, imported by index.html or the
|
|
580
|
+
* start-mode client entry) that installs the in-page bridge from the
|
|
581
|
+
* app's own `@solidjs/diagnostics` and answers requests over Vite's
|
|
582
|
+
* WebSocket custom events;
|
|
583
|
+
* - a collector that forwards requests to the page and correlates
|
|
584
|
+
* responses by id;
|
|
585
|
+
* - an HTTP endpoint (`/__solid/diagnostics`) fronting that round-trip so
|
|
586
|
+
* any out-of-process consumer (agent, MCP tool, curl) can drive capture
|
|
587
|
+
* sessions without holding a WebSocket.
|
|
588
|
+
*
|
|
589
|
+
* `@solidjs/diagnostics` is deliberately a type-only dependency of this
|
|
590
|
+
* plugin: the runtime bridge always comes from the app's own installed
|
|
591
|
+
* copy, so plugin releases and diagnostics releases stay uncoupled. The
|
|
592
|
+
* wire constants are re-declared here with types imported from the
|
|
593
|
+
* package, so drift fails the plugin's own compile.
|
|
565
594
|
*/
|
|
566
|
-
|
|
567
|
-
|
|
595
|
+
const DIAGNOSTICS_ENDPOINT = '/__solid/diagnostics';
|
|
596
|
+
const REQUEST_EVENT = 'solid:diagnostics:request';
|
|
597
|
+
const RESPONSE_EVENT = 'solid:diagnostics:response';
|
|
598
|
+
const DIAGNOSTICS_PACKAGE = '@solidjs/diagnostics';
|
|
599
|
+
const DIAGNOSTICS_CLIENT_ID = 'virtual:solid-diagnostics/client';
|
|
600
|
+
const METHODS = ['begin', 'end', 'active', 'whyDidRun', 'costs'];
|
|
601
|
+
|
|
602
|
+
/** How long the endpoint waits for a page to answer before failing the call. */
|
|
603
|
+
const RESPONSE_TIMEOUT_MS = 10_000;
|
|
604
|
+
function diagnosticsClientModuleCode() {
|
|
605
|
+
// Runtime imports resolve to the APP's diagnostics package (see the
|
|
606
|
+
// resolveId assist below) — the page speaks its own package's protocol.
|
|
607
|
+
return [`import { installDiagnosticsBridge } from '${DIAGNOSTICS_PACKAGE}/browser';`, `import {`, ` DIAGNOSTICS_REQUEST_EVENT,`, ` DIAGNOSTICS_RESPONSE_EVENT,`, `} from '${DIAGNOSTICS_PACKAGE}/protocol';`, ``, `const bridge = installDiagnosticsBridge();`, ``, `async function dispatch(request) {`, ` switch (request.method) {`, ` case 'begin': bridge.begin(request.params); return true;`, ` case 'end': return bridge.end();`, ` case 'active': return bridge.active();`, ` case 'whyDidRun': return bridge.whyDidRun(request.params.name);`, ` case 'costs': return bridge.costs();`, ` default: throw new Error('Unknown diagnostics method: ' + request.method);`, ` }`, `}`, ``, `if (import.meta.hot) {`, ` import.meta.hot.on(DIAGNOSTICS_REQUEST_EVENT, async (request) => {`, ` let response;`, ` try {`, ` response = { id: request.id, result: await dispatch(request) };`, ` } catch (error) {`, ` response = {`, ` id: request.id,`, ` error: error instanceof Error ? error.message : String(error),`, ` };`, ` }`, ` import.meta.hot.send(DIAGNOSTICS_RESPONSE_EVENT, response);`, ` });`, `}`].join('\n');
|
|
568
608
|
}
|
|
569
|
-
function
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
609
|
+
function sendJson(res, status, body) {
|
|
610
|
+
res.statusCode = status;
|
|
611
|
+
res.setHeader('Content-Type', 'application/json');
|
|
612
|
+
res.end(JSON.stringify(body));
|
|
613
|
+
}
|
|
614
|
+
function readJsonBody(req) {
|
|
615
|
+
return new Promise((resolve, reject) => {
|
|
616
|
+
const chunks = [];
|
|
617
|
+
req.on('data', chunk => chunks.push(chunk));
|
|
618
|
+
req.on('end', () => {
|
|
619
|
+
const text = Buffer.concat(chunks).toString('utf8');
|
|
620
|
+
if (!text) return resolve({});
|
|
621
|
+
try {
|
|
622
|
+
resolve(JSON.parse(text));
|
|
623
|
+
} catch {
|
|
624
|
+
reject(new Error('Request body is not valid JSON'));
|
|
625
|
+
}
|
|
626
|
+
});
|
|
627
|
+
req.on('error', reject);
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
function solidDiagnostics() {
|
|
631
|
+
let root = process.cwd();
|
|
632
|
+
let base = '/';
|
|
633
|
+
return {
|
|
634
|
+
name: 'solid:diagnostics',
|
|
635
|
+
// Dev-serve only: the channels this fronts exist in dev builds only.
|
|
636
|
+
apply(_config, env) {
|
|
637
|
+
return env.command === 'serve' && !env.isPreview;
|
|
638
|
+
},
|
|
639
|
+
configResolved(config) {
|
|
640
|
+
root = config.root;
|
|
641
|
+
base = config.base;
|
|
642
|
+
},
|
|
643
|
+
async resolveId(source, importer) {
|
|
644
|
+
if (source === DIAGNOSTICS_CLIENT_ID) {
|
|
645
|
+
return {
|
|
646
|
+
id: DIAGNOSTICS_CLIENT_ID,
|
|
647
|
+
moduleSideEffects: true
|
|
648
|
+
};
|
|
649
|
+
}
|
|
650
|
+
// The virtual module has no directory to resolve bare imports from;
|
|
651
|
+
// resolve the app's diagnostics package from the project root.
|
|
652
|
+
if (importer === DIAGNOSTICS_CLIENT_ID && source.startsWith(DIAGNOSTICS_PACKAGE)) {
|
|
653
|
+
const resolved = await this.resolve(source, path.resolve(root, 'index.html'), {
|
|
654
|
+
skipSelf: true
|
|
655
|
+
});
|
|
656
|
+
if (!resolved || resolved.id.startsWith('__vite-optional-peer-dep:')) {
|
|
657
|
+
this.error(`[@solidjs/vite-plugin] the diagnostics option requires ${DIAGNOSTICS_PACKAGE} ` + 'installed in the app (it provides the in-page bridge). Install it as a ' + 'development dependency or remove `diagnostics: true`.');
|
|
658
|
+
}
|
|
659
|
+
return resolved;
|
|
660
|
+
}
|
|
661
|
+
return null;
|
|
662
|
+
},
|
|
663
|
+
load(id) {
|
|
664
|
+
if (id === DIAGNOSTICS_CLIENT_ID) return diagnosticsClientModuleCode();
|
|
665
|
+
return null;
|
|
666
|
+
},
|
|
667
|
+
// Plain (index.html) apps get the client module injected here;
|
|
668
|
+
// start-mode apps import it from the generated client entry instead.
|
|
669
|
+
transformIndexHtml() {
|
|
670
|
+
return [{
|
|
671
|
+
tag: 'script',
|
|
672
|
+
attrs: {
|
|
673
|
+
type: 'module',
|
|
674
|
+
src: joinBase(base, '/@id/' + DIAGNOSTICS_CLIENT_ID)
|
|
675
|
+
},
|
|
676
|
+
injectTo: 'head'
|
|
677
|
+
}];
|
|
678
|
+
},
|
|
679
|
+
configureServer(server) {
|
|
680
|
+
const pending = new Map();
|
|
681
|
+
let nextId = 1;
|
|
682
|
+
server.ws.on(RESPONSE_EVENT, data => {
|
|
683
|
+
const entry = pending.get(data?.id);
|
|
684
|
+
if (!entry) return;
|
|
685
|
+
pending.delete(data.id);
|
|
686
|
+
clearTimeout(entry.timer);
|
|
687
|
+
entry.resolve(data);
|
|
688
|
+
});
|
|
689
|
+
server.middlewares.use(DIAGNOSTICS_ENDPOINT, async (req, res) => {
|
|
690
|
+
// The middleware mounts on the exact path; anything deeper is 404.
|
|
691
|
+
if (req.url && req.url !== '/' && req.url !== '') {
|
|
692
|
+
sendJson(res, 404, {
|
|
693
|
+
error: `Unknown diagnostics path ${req.url}`
|
|
694
|
+
});
|
|
695
|
+
return;
|
|
696
|
+
}
|
|
697
|
+
if (req.method === 'GET') {
|
|
698
|
+
sendJson(res, 200, {
|
|
699
|
+
ok: true,
|
|
700
|
+
methods: METHODS,
|
|
701
|
+
clients: server.ws.clients.size
|
|
702
|
+
});
|
|
703
|
+
return;
|
|
704
|
+
}
|
|
705
|
+
if (req.method !== 'POST') {
|
|
706
|
+
sendJson(res, 405, {
|
|
707
|
+
error: 'Use GET for status or POST { method, params }'
|
|
708
|
+
});
|
|
709
|
+
return;
|
|
710
|
+
}
|
|
711
|
+
let body;
|
|
712
|
+
try {
|
|
713
|
+
body = await readJsonBody(req);
|
|
714
|
+
} catch (error) {
|
|
715
|
+
sendJson(res, 400, {
|
|
716
|
+
error: error.message
|
|
717
|
+
});
|
|
718
|
+
return;
|
|
719
|
+
}
|
|
720
|
+
if (!body.method || !METHODS.includes(body.method)) {
|
|
721
|
+
sendJson(res, 400, {
|
|
722
|
+
error: `Unknown method ${JSON.stringify(body.method)}; expected one of: ${METHODS.join(', ')}`
|
|
723
|
+
});
|
|
724
|
+
return;
|
|
725
|
+
}
|
|
726
|
+
if (server.ws.clients.size === 0) {
|
|
727
|
+
sendJson(res, 503, {
|
|
728
|
+
error: 'No connected page. Open the app in a browser (dev server) so the ' + 'diagnostics bridge can answer.'
|
|
729
|
+
});
|
|
730
|
+
return;
|
|
731
|
+
}
|
|
732
|
+
const id = nextId++;
|
|
733
|
+
// Broadcast; with several open tabs the first responder wins. Good
|
|
734
|
+
// enough for the agent loop (one page under test); revisit with
|
|
735
|
+
// client targeting if multi-page capture ever matters.
|
|
736
|
+
const response = await new Promise(resolve => {
|
|
737
|
+
const timer = setTimeout(() => {
|
|
738
|
+
pending.delete(id);
|
|
739
|
+
resolve({
|
|
740
|
+
timeout: `No page answered within ${RESPONSE_TIMEOUT_MS}ms. The connected page ` + 'may predate `diagnostics: true` — reload it.'
|
|
741
|
+
});
|
|
742
|
+
}, RESPONSE_TIMEOUT_MS);
|
|
743
|
+
pending.set(id, {
|
|
744
|
+
resolve,
|
|
745
|
+
timer
|
|
746
|
+
});
|
|
747
|
+
server.ws.send(REQUEST_EVENT, {
|
|
748
|
+
id,
|
|
749
|
+
method: body.method,
|
|
750
|
+
params: body.params
|
|
751
|
+
});
|
|
752
|
+
});
|
|
753
|
+
if ('timeout' in response) {
|
|
754
|
+
sendJson(res, 504, {
|
|
755
|
+
error: response.timeout
|
|
756
|
+
});
|
|
757
|
+
} else if (response.error !== undefined) {
|
|
758
|
+
sendJson(res, 400, {
|
|
759
|
+
error: response.error
|
|
760
|
+
});
|
|
761
|
+
} else {
|
|
762
|
+
sendJson(res, 200, {
|
|
763
|
+
result: response.result
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
});
|
|
767
|
+
}
|
|
768
|
+
};
|
|
573
769
|
}
|
|
574
770
|
|
|
575
771
|
// The `"use server"` directive compiler. This wraps the native
|
|
576
|
-
// `transformDirectives` pass from @
|
|
772
|
+
// `transformDirectives` pass from @solidjs/compiler (Rust/Oxc); the
|
|
577
773
|
// original Babel implementation (hoisted from solid-start) lived in this
|
|
578
774
|
// directory through vite-plugin-solid@c052963e and remains the frozen
|
|
579
|
-
// reference for the native pass's fixture suite
|
|
775
|
+
// reference for the native pass's fixture suite.
|
|
580
776
|
|
|
581
777
|
let compilerPromise;
|
|
582
778
|
|
|
@@ -585,11 +781,11 @@ let compilerPromise;
|
|
|
585
781
|
// compiler's opt-in loader in index.ts).
|
|
586
782
|
async function loadCompiler() {
|
|
587
783
|
try {
|
|
588
|
-
return await (compilerPromise ??= import('@
|
|
784
|
+
return await (compilerPromise ??= import('@solidjs/compiler'));
|
|
589
785
|
} catch (error) {
|
|
590
786
|
compilerPromise = undefined;
|
|
591
787
|
const reason = error instanceof Error ? `\n\nCause: ${error.message}` : '';
|
|
592
|
-
throw new Error('@solidjs/vite-plugin: failed to load @
|
|
788
|
+
throw new Error('@solidjs/vite-plugin: failed to load @solidjs/compiler (the "use server" ' + 'transform). Your platform should get a prebuilt native binary or the ' + '@solidjs/compiler-wasm32-wasi fallback — check that optional ' + 'dependencies were installed.' + reason);
|
|
593
789
|
}
|
|
594
790
|
}
|
|
595
791
|
|
|
@@ -1401,6 +1597,7 @@ function startServe(options, internal = {}) {
|
|
|
1401
1597
|
const serverComponents = !!internal.serverComponents;
|
|
1402
1598
|
const errorBoundary = options.errorBoundary !== false;
|
|
1403
1599
|
const styleFilter = internal.styleFilter;
|
|
1600
|
+
const diagnostics = !!internal.diagnostics;
|
|
1404
1601
|
let devtoolsEnabled = false;
|
|
1405
1602
|
let devtoolsResolutions = {};
|
|
1406
1603
|
let devtoolsIds = {};
|
|
@@ -1565,15 +1762,18 @@ function startServe(options, internal = {}) {
|
|
|
1565
1762
|
const {
|
|
1566
1763
|
app
|
|
1567
1764
|
} = requireEntries();
|
|
1765
|
+
// Dev-only: the diagnostics bridge fronts dev-mode channels, so builds
|
|
1766
|
+
// never see this import (mirrors the plugin's own serve-only `apply`).
|
|
1767
|
+
const diagnosticsImport = diagnostics && !isBuild ? [`import ${JSON.stringify(DIAGNOSTICS_CLIENT_ID)};`] : [];
|
|
1568
1768
|
if (clientMode) {
|
|
1569
1769
|
// render(), not hydrate(): the shell's body is empty, the app mounts
|
|
1570
1770
|
// fresh. Client code compiles non-hydratable in client mode, so the
|
|
1571
1771
|
// app cannot claim server DOM anyway. The entry script is injected
|
|
1572
1772
|
// without `async` (plain module = deferred), so document.body is
|
|
1573
1773
|
// complete when this runs.
|
|
1574
|
-
return [`import { render } from '@solidjs/web';`, ...errorBoundaryImport(), ...(toolbar ? [`import { DevToolbar } from ${JSON.stringify(DEVTOOLS_PACKAGE)};`] : []), `import App from ${JSON.stringify(app)};`, ``, `render(() => ${isBuild && errorBoundary ? '<DefaultErrorBoundary><App /></DefaultErrorBoundary>' : toolbar ? '<DevToolbar><App /></DevToolbar>' : '<App />'}, document.body);`].join('\n');
|
|
1774
|
+
return [...diagnosticsImport, `import { render } from '@solidjs/web';`, ...errorBoundaryImport(), ...(toolbar ? [`import { DevToolbar } from ${JSON.stringify(DEVTOOLS_PACKAGE)};`] : []), `import App from ${JSON.stringify(app)};`, ``, `render(() => ${isBuild && errorBoundary ? '<DefaultErrorBoundary><App /></DefaultErrorBoundary>' : toolbar ? '<DevToolbar><App /></DevToolbar>' : '<App />'}, document.body);`].join('\n');
|
|
1575
1775
|
}
|
|
1576
|
-
return [`import { hydrate } from '@solidjs/web';`, ...(toolbar ? [`import { DevToolbar } from ${JSON.stringify(DEVTOOLS_PACKAGE)};`] : []), ...(serverComponents ? [`import { installServerComponents } from '@solidjs/web/frames';`] : []), ...errorBoundaryImport(), `import Document from ${JSON.stringify(documentSpec())};`, `import App from ${JSON.stringify(app)};`, ``, ...(serverComponents ? [
|
|
1776
|
+
return [...diagnosticsImport, `import { hydrate } from '@solidjs/web';`, ...(toolbar ? [`import { DevToolbar } from ${JSON.stringify(DEVTOOLS_PACKAGE)};`] : []), ...(serverComponents ? [`import { installServerComponents } from '@solidjs/web/frames';`] : []), ...errorBoundaryImport(), `import Document from ${JSON.stringify(documentSpec())};`, `import App from ${JSON.stringify(app)};`, ``, ...(serverComponents ? [
|
|
1577
1777
|
// Installs the t=0 document-adoption registry and the transport
|
|
1578
1778
|
// policy (component responses morph their boundary instead of
|
|
1579
1779
|
// decoding as data). Must run before hydrate().
|
|
@@ -1985,7 +2185,7 @@ function startServe(options, internal = {}) {
|
|
|
1985
2185
|
return null;
|
|
1986
2186
|
},
|
|
1987
2187
|
async transform(code, id, opts) {
|
|
1988
|
-
if (isBuild || !devtoolsEnabled) return null;
|
|
2188
|
+
if (isBuild || !devtoolsEnabled && !diagnostics) return null;
|
|
1989
2189
|
const current = requireEntries();
|
|
1990
2190
|
if (current.generated || getEnvironmentConsumer(this.environment, opts) !== 'client') {
|
|
1991
2191
|
return null;
|
|
@@ -1995,12 +2195,17 @@ function startServe(options, internal = {}) {
|
|
|
1995
2195
|
if (vite.normalizePath(id.split('?')[0]) !== vite.normalizePath(path.resolve(root, current.entryClient))) {
|
|
1996
2196
|
return null;
|
|
1997
2197
|
}
|
|
1998
|
-
const
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2198
|
+
const injected = [];
|
|
2199
|
+
if (diagnostics) injected.push(`import ${JSON.stringify(DIAGNOSTICS_CLIENT_ID)};`);
|
|
2200
|
+
if (devtoolsEnabled) {
|
|
2201
|
+
const toolbar = await resolveDevtools((source, importer) => this.resolve(source, importer, {
|
|
2202
|
+
skipSelf: true
|
|
2203
|
+
}), id, 'client');
|
|
2204
|
+
if (toolbar) injected.push(`import ${JSON.stringify(DEVTOOLS_MOUNT_ID)};`);
|
|
2205
|
+
}
|
|
2206
|
+
if (injected.length === 0) return null;
|
|
2002
2207
|
return {
|
|
2003
|
-
code:
|
|
2208
|
+
code: `${injected.join('\n')}\n${code}`,
|
|
2004
2209
|
map: null
|
|
2005
2210
|
};
|
|
2006
2211
|
},
|
|
@@ -2734,7 +2939,7 @@ const require$1 = module$1.createRequire((typeof document === 'undefined' ? requ
|
|
|
2734
2939
|
* second string-literal argument of the form
|
|
2735
2940
|
* `"__SOLID_LAZY_MODULE__:" + spec`, which `resolveLazyModuleUrls` swaps for
|
|
2736
2941
|
* the project-relative resolved module path. The prefix and shape are FROZEN
|
|
2737
|
-
* — the emitting side lives in @
|
|
2942
|
+
* — the emitting side lives in @solidjs/compiler and must match.
|
|
2738
2943
|
*/
|
|
2739
2944
|
const LAZY_PLACEHOLDER_PREFIX = '__SOLID_LAZY_MODULE__:';
|
|
2740
2945
|
|
|
@@ -2852,18 +3057,17 @@ async function fetchAssets(key) {
|
|
|
2852
3057
|
}
|
|
2853
3058
|
export default (registry && registry[${JSON.stringify(root)}]) ||
|
|
2854
3059
|
(bridgeUrl ? createBridgeResolver() : { resolve: jsOnly, resolveSync: jsOnly });`;
|
|
2855
|
-
const SOLID_BUILT_INS = ['For', 'Show', 'Switch', 'Match', 'Loading', 'Reveal', 'Portal', 'Repeat', 'Dynamic', 'Errored'];
|
|
2856
3060
|
|
|
2857
3061
|
/** Possible options for the extensions property */
|
|
2858
3062
|
|
|
2859
3063
|
let nativeCompilerPromise;
|
|
2860
3064
|
async function loadNativeCompiler() {
|
|
2861
3065
|
try {
|
|
2862
|
-
return await (nativeCompilerPromise ??= import('@
|
|
3066
|
+
return await (nativeCompilerPromise ??= import('@solidjs/compiler'));
|
|
2863
3067
|
} catch (error) {
|
|
2864
3068
|
nativeCompilerPromise = undefined;
|
|
2865
3069
|
const reason = error instanceof Error ? `\n\nCause: ${error.message}` : '';
|
|
2866
|
-
throw new Error('@solidjs/vite-plugin: failed to load @
|
|
3070
|
+
throw new Error('@solidjs/vite-plugin: failed to load @solidjs/compiler, which is required ' + 'in every mode (it drives the lazy, refresh, and server-function transforms; ' + 'compiler: "babel" only switches the JSX transform). Your platform should get ' + 'a prebuilt native binary or the @solidjs/compiler-wasm32-wasi fallback ' + '— check that optional dependencies were installed.' + reason);
|
|
2867
3071
|
}
|
|
2868
3072
|
}
|
|
2869
3073
|
|
|
@@ -2940,11 +3144,12 @@ function getSolidOptions(options, isSsr, dev, isTestMode = false) {
|
|
|
2940
3144
|
// by construction (the dom generate ignores the flag), and apps without
|
|
2941
3145
|
// the flag compile byte-for-byte as before.
|
|
2942
3146
|
const serverComponents = typeof options.serverFunctions === 'object' && !!options.serverFunctions.components;
|
|
3147
|
+
|
|
3148
|
+
// Solid-specific defaults (moduleName "@solidjs/web", the control-flow
|
|
3149
|
+
// builtIns, contextToCustomElements, wrapConditionals) are baked into both
|
|
3150
|
+
// backends — @solidjs/compiler and @solidjs/babel-plugin — so only the
|
|
3151
|
+
// posture this plugin actually decides is passed.
|
|
2943
3152
|
return {
|
|
2944
|
-
moduleName: '@solidjs/web',
|
|
2945
|
-
builtIns: SOLID_BUILT_INS,
|
|
2946
|
-
contextToCustomElements: true,
|
|
2947
|
-
wrapConditionals: true,
|
|
2948
3153
|
...solidOptions,
|
|
2949
3154
|
...(serverComponents && solidOptions.generate === 'ssr' ? {
|
|
2950
3155
|
serverComponents: true
|
|
@@ -3538,10 +3743,13 @@ function solidPlugin(options = {}) {
|
|
|
3538
3743
|
}
|
|
3539
3744
|
|
|
3540
3745
|
// Babel JSX backend: one babel.transformAsync hosting the user's
|
|
3541
|
-
// options plus babel-
|
|
3746
|
+
// options plus @solidjs/babel-plugin. Appended to `plugins` (was the
|
|
3747
|
+
// sole preset pre-rename): user plugins still run before it, user
|
|
3748
|
+
// presets still run after — babel runs plugins before presets and
|
|
3749
|
+
// presets in reverse order, so the pass order is unchanged.
|
|
3542
3750
|
const babelOptions = mergeAnything.mergeAndConcat(babelUserOptions, {
|
|
3543
3751
|
...babelBaseOptions,
|
|
3544
|
-
|
|
3752
|
+
plugins: [[solid, solidOptions]]
|
|
3545
3753
|
});
|
|
3546
3754
|
const result = await babel__namespace.transformAsync(code, babelOptions);
|
|
3547
3755
|
if (!result) {
|
|
@@ -3583,10 +3791,17 @@ function solidPlugin(options = {}) {
|
|
|
3583
3791
|
serverFunctions: !!options.serverFunctions,
|
|
3584
3792
|
serverComponents,
|
|
3585
3793
|
ssr: !!options.ssr,
|
|
3586
|
-
styleFilter: filterDevStyles
|
|
3794
|
+
styleFilter: filterDevStyles,
|
|
3795
|
+
diagnostics: !!options.diagnostics
|
|
3587
3796
|
}));
|
|
3588
3797
|
}
|
|
3589
3798
|
|
|
3799
|
+
// Agent diagnostics endpoint + injected bridge (dev serve only — the
|
|
3800
|
+
// plugin no-ops itself for builds and preview via `apply`).
|
|
3801
|
+
if (options.diagnostics) {
|
|
3802
|
+
plugins.push(solidDiagnostics());
|
|
3803
|
+
}
|
|
3804
|
+
|
|
3590
3805
|
// Builder-mode (environments API) client-before-server build ordering.
|
|
3591
3806
|
// Server builds read the client manifest — `virtual:solid-manifest` bakes
|
|
3592
3807
|
// dist/client/.vite/manifest.json in, and the persisted server-function
|