@ripple-ts/vite-plugin 0.3.72 → 0.3.76
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/CHANGELOG.md +56 -0
- package/package.json +4 -4
- package/src/index.js +0 -18
- package/src/load-config.js +1 -62
- package/src/project-codegen.js +0 -50
- package/tests/transform-source-maps.test.js +10 -8
- package/types/index.d.ts +0 -32
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,61 @@
|
|
|
1
1
|
# @ripple-ts/vite-plugin
|
|
2
2
|
|
|
3
|
+
## 0.3.76
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
[[`6fd49c9`](https://github.com/Ripple-TS/ripple/commit/6fd49c9dd737e889844e254763f66e13ea4a7241)]:
|
|
9
|
+
- @tsrx/ripple@0.1.24
|
|
10
|
+
- @ripple-ts/adapter@0.3.76
|
|
11
|
+
|
|
12
|
+
## 0.3.75
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
[[`88a254c`](https://github.com/Ripple-TS/ripple/commit/88a254c69953a5ace33bc10047f11052ec598672),
|
|
18
|
+
[`4c5f992`](https://github.com/Ripple-TS/ripple/commit/4c5f992b9a11e1f26abee476a6add89f959169bc),
|
|
19
|
+
[`186b3b2`](https://github.com/Ripple-TS/ripple/commit/186b3b2557761ff06c9056bf2e0b7ab8c7692477)]:
|
|
20
|
+
- @tsrx/ripple@0.1.23
|
|
21
|
+
- @ripple-ts/adapter@0.3.75
|
|
22
|
+
|
|
23
|
+
## 0.3.74
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- Updated dependencies
|
|
28
|
+
[[`5d33325`](https://github.com/Ripple-TS/ripple/commit/5d3332564109d228af5e02c0f68ca4a318766649),
|
|
29
|
+
[`5d33325`](https://github.com/Ripple-TS/ripple/commit/5d3332564109d228af5e02c0f68ca4a318766649),
|
|
30
|
+
[`5d33325`](https://github.com/Ripple-TS/ripple/commit/5d3332564109d228af5e02c0f68ca4a318766649),
|
|
31
|
+
[`5d33325`](https://github.com/Ripple-TS/ripple/commit/5d3332564109d228af5e02c0f68ca4a318766649),
|
|
32
|
+
[`5d33325`](https://github.com/Ripple-TS/ripple/commit/5d3332564109d228af5e02c0f68ca4a318766649),
|
|
33
|
+
[`5d33325`](https://github.com/Ripple-TS/ripple/commit/5d3332564109d228af5e02c0f68ca4a318766649),
|
|
34
|
+
[`5d33325`](https://github.com/Ripple-TS/ripple/commit/5d3332564109d228af5e02c0f68ca4a318766649),
|
|
35
|
+
[`5d33325`](https://github.com/Ripple-TS/ripple/commit/5d3332564109d228af5e02c0f68ca4a318766649),
|
|
36
|
+
[`5d33325`](https://github.com/Ripple-TS/ripple/commit/5d3332564109d228af5e02c0f68ca4a318766649),
|
|
37
|
+
[`5d33325`](https://github.com/Ripple-TS/ripple/commit/5d3332564109d228af5e02c0f68ca4a318766649),
|
|
38
|
+
[`5d33325`](https://github.com/Ripple-TS/ripple/commit/5d3332564109d228af5e02c0f68ca4a318766649),
|
|
39
|
+
[`5d33325`](https://github.com/Ripple-TS/ripple/commit/5d3332564109d228af5e02c0f68ca4a318766649),
|
|
40
|
+
[`5d33325`](https://github.com/Ripple-TS/ripple/commit/5d3332564109d228af5e02c0f68ca4a318766649)]:
|
|
41
|
+
- @tsrx/ripple@0.1.22
|
|
42
|
+
- @ripple-ts/adapter@0.3.74
|
|
43
|
+
|
|
44
|
+
## 0.3.73
|
|
45
|
+
|
|
46
|
+
### Patch Changes
|
|
47
|
+
|
|
48
|
+
- [#1198](https://github.com/Ripple-TS/ripple/pull/1198)
|
|
49
|
+
[`1de66b8`](https://github.com/Ripple-TS/ripple/commit/1de66b8f851849597b6078dab7af2699e49b0e21)
|
|
50
|
+
Thanks [@trueadm](https://github.com/trueadm)! - Remove the unused namespaced
|
|
51
|
+
TSX island feature and React bridge package.
|
|
52
|
+
|
|
53
|
+
- Updated dependencies
|
|
54
|
+
[[`e738e11`](https://github.com/Ripple-TS/ripple/commit/e738e1153694f56f35cfcab8982d897d7199d85a),
|
|
55
|
+
[`1de66b8`](https://github.com/Ripple-TS/ripple/commit/1de66b8f851849597b6078dab7af2699e49b0e21)]:
|
|
56
|
+
- @tsrx/ripple@0.1.21
|
|
57
|
+
- @ripple-ts/adapter@0.3.73
|
|
58
|
+
|
|
3
59
|
## 0.3.72
|
|
4
60
|
|
|
5
61
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Vite plugin for Ripple",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Dominic Gannaway",
|
|
6
|
-
"version": "0.3.
|
|
6
|
+
"version": "0.3.76",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"module": "src/index.js",
|
|
9
9
|
"main": "src/index.js",
|
|
@@ -32,14 +32,14 @@
|
|
|
32
32
|
"url": "https://github.com/Ripple-TS/ripple/issues"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@ripple-ts/adapter": "0.3.
|
|
36
|
-
"@tsrx/ripple": "0.1.
|
|
35
|
+
"@ripple-ts/adapter": "0.3.76",
|
|
36
|
+
"@tsrx/ripple": "0.1.24"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/node": "^24.3.0",
|
|
40
40
|
"type-fest": "^5.6.0",
|
|
41
41
|
"vite": "^8.0.12",
|
|
42
|
-
"ripple": "0.3.
|
|
42
|
+
"ripple": "0.3.76"
|
|
43
43
|
},
|
|
44
44
|
"publishConfig": {
|
|
45
45
|
"access": "public"
|
package/src/index.js
CHANGED
|
@@ -24,12 +24,9 @@ import {
|
|
|
24
24
|
import { ENTRY_FILENAME } from './constants.js';
|
|
25
25
|
import {
|
|
26
26
|
RESOLVED_ADAPTER_BROWSER_STUB_ID,
|
|
27
|
-
RESOLVED_VIRTUAL_COMPAT_ID,
|
|
28
27
|
SERVER_ONLY_ADAPTER_IDS,
|
|
29
|
-
VIRTUAL_COMPAT_ID,
|
|
30
28
|
create_adapter_browser_stub_source,
|
|
31
29
|
create_client_entry_source,
|
|
32
|
-
create_compat_virtual_module,
|
|
33
30
|
to_vite_root_import,
|
|
34
31
|
write_project_generated_file,
|
|
35
32
|
} from './project-codegen.js';
|
|
@@ -1083,10 +1080,6 @@ export function ripple(inlineOptions = {}) {
|
|
|
1083
1080
|
return RESOLVED_VIRTUAL_HYDRATE_ID;
|
|
1084
1081
|
}
|
|
1085
1082
|
|
|
1086
|
-
if (id === VIRTUAL_COMPAT_ID) {
|
|
1087
|
-
return RESOLVED_VIRTUAL_COMPAT_ID;
|
|
1088
|
-
}
|
|
1089
|
-
|
|
1090
1083
|
// Skip non-package imports (relative/absolute paths)
|
|
1091
1084
|
if (id.startsWith('.') || id.startsWith('/') || id.includes(':')) {
|
|
1092
1085
|
return null;
|
|
@@ -1131,11 +1124,6 @@ export function ripple(inlineOptions = {}) {
|
|
|
1131
1124
|
return create_adapter_browser_stub_source();
|
|
1132
1125
|
}
|
|
1133
1126
|
|
|
1134
|
-
if (id === RESOLVED_VIRTUAL_COMPAT_ID) {
|
|
1135
|
-
const compat_config = await get_current_ripple_config();
|
|
1136
|
-
return create_compat_virtual_module(compat_config);
|
|
1137
|
-
}
|
|
1138
|
-
|
|
1139
1127
|
// Handle virtual hydrate module
|
|
1140
1128
|
if (id === RESOLVED_VIRTUAL_HYDRATE_ID) {
|
|
1141
1129
|
const file = write_project_generated_file(
|
|
@@ -1162,16 +1150,10 @@ export function ripple(inlineOptions = {}) {
|
|
|
1162
1150
|
const ssr = opts?.ssr === true || this.environment.config.consumer === 'server';
|
|
1163
1151
|
|
|
1164
1152
|
const is_dev = config?.command === 'serve';
|
|
1165
|
-
const current_ripple_config = await get_current_ripple_config();
|
|
1166
|
-
|
|
1167
1153
|
let { code, css, map } = await compile(source_code, filename, {
|
|
1168
1154
|
mode: ssr ? 'server' : 'client',
|
|
1169
1155
|
dev: is_dev,
|
|
1170
1156
|
hmr: is_dev && !ssr,
|
|
1171
|
-
compat_kinds:
|
|
1172
|
-
current_ripple_config === null
|
|
1173
|
-
? undefined
|
|
1174
|
-
: Object.keys(current_ripple_config.compat),
|
|
1175
1157
|
});
|
|
1176
1158
|
|
|
1177
1159
|
// Track modules with `module server` declarations for RPC (client build only)
|
package/src/load-config.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* and the generated production server entry.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
/** @import {
|
|
18
|
+
/** @import { RippleConfigOptions, ResolvedRippleConfig } from '@ripple-ts/vite-plugin' */
|
|
19
19
|
|
|
20
20
|
import path from 'node:path';
|
|
21
21
|
import fs from 'node:fs';
|
|
@@ -24,61 +24,6 @@ import { DEFAULT_OUTDIR } from './constants.js';
|
|
|
24
24
|
|
|
25
25
|
const RIPPLE_EXTENSION_PATTERN = /\.tsrx$/;
|
|
26
26
|
|
|
27
|
-
/**
|
|
28
|
-
* @param {unknown} entry
|
|
29
|
-
* @returns {entry is CompatFactoryConfig}
|
|
30
|
-
*/
|
|
31
|
-
function is_compat_descriptor(entry) {
|
|
32
|
-
return !!entry && typeof entry === 'object' && 'from' in entry;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* @param {unknown} entry
|
|
37
|
-
* @returns {entry is { __ripple_compat__: CompatFactoryConfig }}
|
|
38
|
-
*/
|
|
39
|
-
function is_compat_branded_entry(entry) {
|
|
40
|
-
return (
|
|
41
|
-
!!entry &&
|
|
42
|
-
(typeof entry === 'function' || typeof entry === 'object') &&
|
|
43
|
-
'__ripple_compat__' in entry &&
|
|
44
|
-
is_compat_descriptor(entry.__ripple_compat__)
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* @param {string} kind
|
|
50
|
-
* @param {unknown} entry
|
|
51
|
-
* @returns {CompatFactoryConfig}
|
|
52
|
-
*/
|
|
53
|
-
function normalize_compat_entry(kind, entry) {
|
|
54
|
-
if (is_compat_branded_entry(entry)) {
|
|
55
|
-
entry = entry.__ripple_compat__;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (!is_compat_descriptor(entry)) {
|
|
59
|
-
throw new Error(
|
|
60
|
-
`[@ripple-ts/vite-plugin] ripple.config.ts compat.${kind} must be either a compat descriptor, a compat factory, or an invoked compat entry.`,
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (typeof entry.from !== 'string' || entry.from.length === 0) {
|
|
65
|
-
throw new Error(
|
|
66
|
-
`[@ripple-ts/vite-plugin] ripple.config.ts compat.${kind}.from must be a non-empty string.`,
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (entry.factory !== undefined && typeof entry.factory !== 'string') {
|
|
71
|
-
throw new Error(
|
|
72
|
-
`[@ripple-ts/vite-plugin] ripple.config.ts compat.${kind}.factory must be a string when provided.`,
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return {
|
|
77
|
-
from: entry.from,
|
|
78
|
-
...(entry.factory ? { factory: entry.factory } : {}),
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
|
|
82
27
|
/**
|
|
83
28
|
* @param {unknown} route
|
|
84
29
|
* @returns {void}
|
|
@@ -196,12 +141,6 @@ export function resolveRippleConfig(raw, options = {}) {
|
|
|
196
141
|
},
|
|
197
142
|
rootBoundary: raw.rootBoundary ?? {},
|
|
198
143
|
middlewares: raw.middlewares ?? [],
|
|
199
|
-
compat: Object.fromEntries(
|
|
200
|
-
Object.entries(raw.compat ?? {}).map(([kind, entry]) => [
|
|
201
|
-
kind,
|
|
202
|
-
normalize_compat_entry(kind, entry),
|
|
203
|
-
]),
|
|
204
|
-
),
|
|
205
144
|
platform: {
|
|
206
145
|
env: raw.platform?.env ?? {},
|
|
207
146
|
},
|
package/src/project-codegen.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
/** @import { ResolvedConfig } from 'vite' */
|
|
2
|
-
/** @import { ResolvedRippleConfig } from '@ripple-ts/vite-plugin' */
|
|
3
2
|
|
|
4
3
|
import fs from 'node:fs';
|
|
5
4
|
import path from 'node:path';
|
|
6
5
|
|
|
7
|
-
export const VIRTUAL_COMPAT_ID = 'virtual:ripple-compat';
|
|
8
|
-
export const RESOLVED_VIRTUAL_COMPAT_ID = '\0virtual:ripple-compat';
|
|
9
6
|
export const RESOLVED_ADAPTER_BROWSER_STUB_ID = '\0ripple:adapter-browser-stub';
|
|
10
7
|
export const SERVER_ONLY_ADAPTER_IDS = new Set([
|
|
11
8
|
'@ripple-ts/adapter-node',
|
|
@@ -16,52 +13,6 @@ export const SERVER_ONLY_ADAPTER_IDS = new Set([
|
|
|
16
13
|
/** @type {Map<string, string>} */
|
|
17
14
|
const generated_file_cache = new Map();
|
|
18
15
|
|
|
19
|
-
/**
|
|
20
|
-
* @param {ResolvedRippleConfig | null} config
|
|
21
|
-
* @returns {string}
|
|
22
|
-
*/
|
|
23
|
-
export function create_compat_virtual_module(config) {
|
|
24
|
-
const compat_entries = Object.entries(config?.compat ?? {});
|
|
25
|
-
|
|
26
|
-
if (compat_entries.length === 0) {
|
|
27
|
-
return `const compat = undefined;
|
|
28
|
-
globalThis.__RIPPLE_COMPAT__ = compat;
|
|
29
|
-
export { compat };
|
|
30
|
-
export default compat;
|
|
31
|
-
`;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const imports = [];
|
|
35
|
-
const properties = [];
|
|
36
|
-
|
|
37
|
-
for (let i = 0; i < compat_entries.length; i++) {
|
|
38
|
-
const [kind, entry] = compat_entries[i];
|
|
39
|
-
const local_name = `__ripple_compat_factory_${i}`;
|
|
40
|
-
|
|
41
|
-
if (entry.factory) {
|
|
42
|
-
imports.push(
|
|
43
|
-
`import { ${entry.factory} as ${local_name} } from ${JSON.stringify(entry.from)};`,
|
|
44
|
-
);
|
|
45
|
-
} else {
|
|
46
|
-
imports.push(`import ${local_name} from ${JSON.stringify(entry.from)};`);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
properties.push(` ${JSON.stringify(kind)}: ${local_name}(),`);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return `${imports.join('\n')}
|
|
53
|
-
|
|
54
|
-
const compat = {
|
|
55
|
-
${properties.join('\n')}
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
globalThis.__RIPPLE_COMPAT__ = compat;
|
|
59
|
-
|
|
60
|
-
export { compat };
|
|
61
|
-
export default compat;
|
|
62
|
-
`;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
16
|
/**
|
|
66
17
|
* @returns {string}
|
|
67
18
|
*/
|
|
@@ -121,7 +72,6 @@ export function create_client_entry_source(options) {
|
|
|
121
72
|
return `// Auto-generated by @ripple-ts/vite-plugin.
|
|
122
73
|
// This file is written to Vite's cacheDir/project folder.
|
|
123
74
|
|
|
124
|
-
import ${JSON.stringify(VIRTUAL_COMPAT_ID)};
|
|
125
75
|
import { hydrate, mount } from 'ripple';
|
|
126
76
|
import rippleConfig from ${JSON.stringify(options.configPath)};
|
|
127
77
|
|
|
@@ -73,15 +73,17 @@ describe('vite-plugin-ripple source maps', () => {
|
|
|
73
73
|
await init_plugin(plugin, root);
|
|
74
74
|
|
|
75
75
|
const id = `${root}/Styled.tsrx`;
|
|
76
|
-
const source = `export function Styled() {
|
|
77
|
-
|
|
76
|
+
const source = `export function Styled() @{
|
|
77
|
+
<>
|
|
78
|
+
<div>{'Hello world'}</div>
|
|
78
79
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
<style>
|
|
81
|
+
.div {
|
|
82
|
+
color: red;
|
|
83
|
+
}
|
|
84
|
+
</style>
|
|
85
|
+
</>
|
|
86
|
+
}`;
|
|
85
87
|
|
|
86
88
|
const result = await call_transform(plugin, source, id);
|
|
87
89
|
|
package/types/index.d.ts
CHANGED
|
@@ -116,26 +116,6 @@ export interface RootBoundaryOptions {
|
|
|
116
116
|
catch?: Component<{ error: unknown; reset: () => void }>;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
export interface CompatFactoryConfig {
|
|
120
|
-
/** Module specifier that exports the compat factory */
|
|
121
|
-
from: string;
|
|
122
|
-
/** Named export to call. Omit to use the module's default export. */
|
|
123
|
-
factory?: string;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export interface CompatFactory<T = unknown> {
|
|
127
|
-
(): T;
|
|
128
|
-
__ripple_compat__: CompatFactoryConfig;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
export interface CompatEntryValue {
|
|
132
|
-
__ripple_compat__: CompatFactoryConfig;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
export type CompatConfigEntry = CompatFactoryConfig | CompatFactory | CompatEntryValue;
|
|
136
|
-
|
|
137
|
-
export type CompatConfig = Record<string, CompatConfigEntry>;
|
|
138
|
-
|
|
139
119
|
export interface RippleConfigOptions {
|
|
140
120
|
build?: {
|
|
141
121
|
/** Output directory for the production build. @default 'dist' */
|
|
@@ -163,16 +143,6 @@ export interface RippleConfigOptions {
|
|
|
163
143
|
rootBoundary?: RootBoundaryOptions;
|
|
164
144
|
/** Global middlewares applied to all routes */
|
|
165
145
|
middlewares?: Middleware[];
|
|
166
|
-
/**
|
|
167
|
-
* Client-side TSX compat integrations keyed by kind, e.g. `react` for `<tsx:react>`.
|
|
168
|
-
*
|
|
169
|
-
* You can either pass a descriptor object or import a compat factory directly,
|
|
170
|
-
* as long as that factory export carries Ripple compat metadata.
|
|
171
|
-
*
|
|
172
|
-
* These are compiled into a browser-side compat registry by the Vite plugin,
|
|
173
|
-
* allowing `mount()` / `hydrate()` to pick them up automatically.
|
|
174
|
-
*/
|
|
175
|
-
compat?: CompatConfig;
|
|
176
146
|
platform?: {
|
|
177
147
|
env: Record<string, string>;
|
|
178
148
|
};
|
|
@@ -213,8 +183,6 @@ export interface ResolvedRippleConfig {
|
|
|
213
183
|
rootBoundary: RootBoundaryOptions;
|
|
214
184
|
/** @default [] */
|
|
215
185
|
middlewares: Middleware[];
|
|
216
|
-
/** @default {} */
|
|
217
|
-
compat: Record<string, CompatFactoryConfig>;
|
|
218
186
|
platform: {
|
|
219
187
|
/** @default {} */
|
|
220
188
|
env: Record<string, string>;
|