@ripple-ts/rollup-plugin 0.4.5 → 0.4.6

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 CHANGED
@@ -1,5 +1,16 @@
1
1
  # @ripple-ts/rollup-plugin
2
2
 
3
+ ## 0.4.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1499](https://github.com/Ripple-TS/ripple/pull/1499)
8
+ [`cd1995e`](https://github.com/Ripple-TS/ripple/commit/cd1995e8a10c0b422c03a0e344efd648e6175f67)
9
+ Thanks [@Dev-next-gen](https://github.com/Dev-next-gen)! - Pass
10
+ `compilerOptions` to the compiler instead of the raw file id. This fixes a
11
+ `TypeError` when compiling `.tsrx` files and ensures options such as `mode`,
12
+ `dev`, `hmr`, and `hydration` are respected.
13
+
3
14
  ## 0.4.5
4
15
 
5
16
  ### Patch Changes
package/index.js CHANGED
@@ -53,7 +53,7 @@ export default function (options = {}) {
53
53
 
54
54
  const filename = path.relative(process.cwd(), id);
55
55
 
56
- const result = await compile(code, filename, id);
56
+ const result = await compile(code, filename, compilerOptions);
57
57
 
58
58
  if (emitCss && result.css) {
59
59
  const fname = id.replace(new RegExp(`\\${extension}$`), '.css');
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Rollup plugin for Ripple",
4
4
  "license": "MIT",
5
5
  "author": "Dominic Gannaway",
6
- "version": "0.4.5",
6
+ "version": "0.4.6",
7
7
  "type": "module",
8
8
  "main": "index.js",
9
9
  "homepage": "https://ripple-ts.com",
@@ -23,7 +23,7 @@
23
23
  "rollup": "^4.59.0",
24
24
  "source-map": "^0.7.6",
25
25
  "uvu": "^0.5.6",
26
- "ripple": "0.4.5"
26
+ "ripple": "0.4.6"
27
27
  },
28
28
  "publishConfig": {
29
29
  "access": "public"
@@ -0,0 +1,74 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import path from 'node:path';
3
+ import { rollup } from 'rollup';
4
+ import ripple from '../index.js';
5
+
6
+ const id = path.resolve('src/App.tsrx');
7
+ const source = `export function App(props) @{
8
+ <div><span>{props.value}</span></div>
9
+ }`;
10
+
11
+ describe('@ripple-ts/rollup-plugin compiler options', () => {
12
+ it.each(['client', 'server'])('builds %s output with Rollup', async (mode) => {
13
+ const bundle = await rollup({
14
+ input: id,
15
+ external: /^ripple\//,
16
+ plugins: [
17
+ {
18
+ name: 'fixture',
19
+ resolveId: (entry) => (entry === id ? id : null),
20
+ load: (entry) => (entry === id ? source : null),
21
+ },
22
+ ripple({ compilerOptions: { mode } }),
23
+ ],
24
+ });
25
+ try {
26
+ const { output } = await bundle.generate({ format: 'es', sourcemap: true });
27
+ expect(output[0].imports).toEqual([`ripple/internal/${mode}`]);
28
+ expect(output[0].exports).toContain('App');
29
+ expect(output[0].map.sourcesContent).toEqual([source]);
30
+ } finally {
31
+ await bundle.close();
32
+ }
33
+ });
34
+
35
+ it('keeps the compiler defaults when options are omitted', async () => {
36
+ const result = await ripple().transform(source, id);
37
+ expect(result.code).toContain("from 'ripple/internal/client'");
38
+ expect(result.code).toContain('_$_.hydrate_child(');
39
+ expect(result.code).not.toContain('import.meta.hot');
40
+ });
41
+
42
+ it.each([false, true])('respects hmr: %s', async (hmr) => {
43
+ const result = await ripple({ compilerOptions: { hmr } }).transform(source, id);
44
+ expect(result.code.includes('import.meta.hot.accept(')).toBe(hmr);
45
+ });
46
+
47
+ it.each([false, true])('respects server dev: %s', async (dev) => {
48
+ const result = await ripple({ compilerOptions: { mode: 'server', dev } }).transform(source, id);
49
+ expect(result.code).toContain("from 'ripple/internal/server'");
50
+ expect(result.code.includes('_$_.push_element(')).toBe(dev);
51
+ });
52
+
53
+ it.each([false, true])('respects hydration: %s', async (hydration) => {
54
+ const result = await ripple({ compilerOptions: { hydration } }).transform(source, id);
55
+ expect(result.code.includes('_$_.hydrate_child(')).toBe(hydration);
56
+ });
57
+
58
+ it('preserves extracted CSS and source maps when compiling for the server', async () => {
59
+ const styled_source = `export function App() @{
60
+ <>
61
+ <div>Hello</div>
62
+ <style>div { color: red; }</style>
63
+ </>
64
+ }`;
65
+ const plugin = ripple({ compilerOptions: { mode: 'server' } });
66
+ const result = await plugin.transform(styled_source, id);
67
+ const css_id = id.replace(/\.tsrx$/, '.css');
68
+
69
+ expect(result.code).toContain("from 'ripple/internal/server'");
70
+ expect(result.code).toContain(`import ${JSON.stringify(css_id)};`);
71
+ expect(plugin.load(css_id)).toContain('color: red;');
72
+ expect(result.map.sourcesContent).toEqual([styled_source]);
73
+ });
74
+ });