@lunora/rspack 0.0.0 → 1.0.0-alpha.10

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/LICENSE.md ADDED
@@ -0,0 +1,111 @@
1
+ # Functional Source License, Version 1.1, Apache 2.0 Future License
2
+
3
+ ## Abbreviation
4
+
5
+ FSL-1.1-Apache-2.0
6
+
7
+ ## Notice
8
+
9
+ Copyright 2026 anolilab and contributors
10
+
11
+ ## Terms and Conditions
12
+
13
+ ### Licensor ("We")
14
+
15
+ The party offering the Software under these Terms and Conditions.
16
+
17
+ ### The Software
18
+
19
+ The "Software" is each version of the software that we make available under
20
+ these Terms and Conditions, as indicated by our inclusion of these Terms and
21
+ Conditions with the Software.
22
+
23
+ ### License Grant
24
+
25
+ Subject to your compliance with this License Grant and the Patents,
26
+ Redistribution and Trademark clauses below, we hereby grant you the right to
27
+ use, copy, modify, create derivative works, publicly perform, publicly display
28
+ and redistribute the Software for any Permitted Purpose identified below.
29
+
30
+ ### Permitted Purpose
31
+
32
+ A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
33
+ means making the Software available to others in a commercial product or service
34
+ that:
35
+
36
+ 1. substitutes for the Software;
37
+
38
+ 2. substitutes for any other product or service we offer using the Software that
39
+ exists as of the date we make the Software available; or
40
+
41
+ 3. offers the same or substantially similar functionality as the Software.
42
+
43
+ Permitted Purposes specifically include using the Software:
44
+
45
+ 1. for your internal use and access;
46
+
47
+ 2. for non-commercial education;
48
+
49
+ 3. for non-commercial research; and
50
+
51
+ 4. in connection with professional services that you provide to a licensee using
52
+ the Software in accordance with these Terms and Conditions.
53
+
54
+ ### Patents
55
+
56
+ To the extent your use for a Permitted Purpose would necessarily infringe our
57
+ patents, the license grant above includes a license under our patents. If you
58
+ make a claim against any party that the Software infringes or contributes to the
59
+ infringement of any patent, then your patent license to the Software ends
60
+ immediately.
61
+
62
+ ### Redistribution
63
+
64
+ The Terms and Conditions apply to all copies, modifications and derivatives of
65
+ the Software.
66
+
67
+ If you redistribute any copies, modifications or derivatives of the Software,
68
+ you must include a copy of or a link to these Terms and Conditions and not
69
+ remove any copyright notices provided in or with the Software.
70
+
71
+ ### Disclaimer
72
+
73
+ THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
74
+ IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
75
+ PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
76
+
77
+ IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
78
+ SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, EVEN
79
+ IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
80
+
81
+ ### Trademarks
82
+
83
+ Except for displaying the License Details and identifying us as the origin of
84
+ the Software, you have no right under these Terms and Conditions to use our
85
+ trademarks, trade names, service marks or product names.
86
+
87
+ ## Grant of Future License
88
+
89
+ We hereby irrevocably grant you an additional license to use the Software under
90
+ the Apache License, Version 2.0 that is effective on the second anniversary of
91
+ the date we make the Software available. On or after that date, you may use the
92
+ Software under the Apache License, Version 2.0, in which case the following will
93
+ apply:
94
+
95
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
96
+ this file except in compliance with the License.
97
+
98
+ You may obtain a copy of the License at
99
+
100
+ http://www.apache.org/licenses/LICENSE-2.0
101
+
102
+ Unless required by applicable law or agreed to in writing, software distributed
103
+ under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
104
+ CONDITIONS OF ANY KIND, either express or implied. See the License for the
105
+ specific language governing permissions and limitations under the License.
106
+
107
+ <!-- DEPENDENCIES -->
108
+ <!-- /DEPENDENCIES -->
109
+
110
+ <!-- TYPE_DEPENDENCIES -->
111
+ <!-- /TYPE_DEPENDENCIES -->
package/README.md CHANGED
@@ -1,45 +1,179 @@
1
- # @lunora/rspack
1
+ <!-- START_PACKAGE_OG_IMAGE_PLACEHOLDER -->
2
2
 
3
- ## ⚠️ IMPORTANT NOTICE ⚠️
3
+ <a href="https://www.anolilab.com/open-source" align="center">
4
4
 
5
- **This package is created solely for the purpose of setting up OIDC (OpenID Connect) trusted publishing with npm.**
5
+ <img src="__assets__/package-og.svg" alt="rspack" />
6
6
 
7
- This is **NOT** a functional package and contains **NO** code or functionality beyond the OIDC setup configuration.
7
+ </a>
8
8
 
9
- ## Purpose
9
+ <h3 align="center">The Lunora Rspack plugin: codegen, binding provisioning, and wrangler validation for Rspack projects</h3>
10
10
 
11
- This package exists to:
12
- 1. Configure OIDC trusted publishing for the package name `@lunora/rspack`
13
- 2. Enable secure, token-less publishing from CI/CD workflows
14
- 3. Establish provenance for packages published under this name
11
+ <!-- END_PACKAGE_OG_IMAGE_PLACEHOLDER -->
15
12
 
16
- ## What is OIDC Trusted Publishing?
13
+ <br />
17
14
 
18
- OIDC trusted publishing allows package maintainers to publish packages directly from their CI/CD workflows without needing to manage npm access tokens. Instead, it uses OpenID Connect to establish trust between the CI/CD provider (like GitHub Actions) and npm.
15
+ <div align="center">
19
16
 
20
- ## Setup Instructions
17
+ [![typescript-image][typescript-badge]][typescript-url]
18
+ [![FSL-1.1-Apache-2.0 licence][license-badge]][license]
19
+ [![npm version][npm-version-badge]][npm-version]
20
+ [![npm downloads][npm-downloads-badge]][npm-downloads]
21
+ [![PRs Welcome][prs-welcome-badge]][prs-welcome]
21
22
 
22
- To properly configure OIDC trusted publishing for this package:
23
+ </div>
23
24
 
24
- 1. Go to [npmjs.com](https://www.npmjs.com/) and navigate to your package settings
25
- 2. Configure the trusted publisher (e.g., GitHub Actions)
26
- 3. Specify the repository and workflow that should be allowed to publish
27
- 4. Use the configured workflow to publish your actual package
25
+ ---
28
26
 
29
- ## DO NOT USE THIS PACKAGE
27
+ <div align="center">
28
+ <p>
29
+ <sup>
30
+ Daniel Bannert's open source work is supported by the community on <a href="https://github.com/sponsors/prisis">GitHub Sponsors</a>
31
+ </sup>
32
+ </p>
33
+ </div>
30
34
 
31
- This package is a placeholder for OIDC configuration only. It:
32
- - Contains no executable code
33
- - Provides no functionality
34
- - Should not be installed as a dependency
35
- - Exists only for administrative purposes
35
+ ---
36
36
 
37
- ## More Information
37
+ The Lunora [Rspack](https://rspack.rs) plugin. It runs `@lunora/codegen` before every compilation, writes the Cloudflare bindings your code implies into `wrangler.jsonc`, and validates that config against your schema — the build-time half of what [`@lunora/vite`](https://www.npmjs.com/package/@lunora/vite) does.
38
38
 
39
- For more details about npm's trusted publishing feature, see:
40
- - [npm Trusted Publishing Documentation](https://docs.npmjs.com/generating-provenance-statements)
41
- - [GitHub Actions OIDC Documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
39
+ Part of the [Lunora](https://github.com/anolilab/lunora) framework — a type-safe, real-time backend on Cloudflare Workers + Durable Objects.
42
40
 
43
- ---
41
+ ## Install
42
+
43
+ ```sh
44
+ npm install @lunora/rspack
45
+ ```
46
+
47
+ ```sh
48
+ yarn add @lunora/rspack
49
+ ```
50
+
51
+ ```sh
52
+ pnpm add @lunora/rspack
53
+ ```
54
+
55
+ ## Usage
56
+
57
+ With [Rsbuild](https://rsbuild.rs) — the recommended setup, and the one that runs your Worker:
58
+
59
+ ```ts
60
+ // rsbuild.config.ts
61
+ import { lunoraRsbuild } from "@lunora/rspack/rsbuild";
62
+ import { defineConfig } from "@rsbuild/core";
63
+
64
+ export default defineConfig({
65
+ plugins: [lunoraRsbuild()],
66
+ });
67
+ ```
68
+
69
+ `rsbuild dev` now starts the client dev server **and** the Lunora Worker, and routes `/_lunora/*` to it. Nothing else to wire — no hand-written proxy, no second terminal, no `wrangler.dev.jsonc`. One entry registers codegen, binding provisioning, wrangler validation, the Worker, and the proxy.
70
+
71
+ To start from a working app, `lunora init -t rspack-react` scaffolds a React SPA and `lunora init -t tanstack-start-react-rspack` a TanStack Start app that deploys as one Worker.
72
+
73
+ On bare Rspack (or webpack 5), the plugin half works on its own — codegen and config only, no Worker:
74
+
75
+ ```js
76
+ // rspack.config.mjs
77
+ import { lunoraRspack } from "@lunora/rspack";
78
+
79
+ export default {
80
+ plugins: [lunoraRspack()],
81
+ };
82
+ ```
83
+
84
+ ## Options
85
+
86
+ ```ts
87
+ lunoraRsbuild({
88
+ projectRoot: process.cwd(), // directory containing `lunora/`
89
+ schemaDir: "lunora", // where `schema.ts` and your function files live
90
+ apiSpec: "openapi", // "openapi" | "openrpc" | "both" | "none"
91
+ target: "cloudflare", // defaults to `target` in lunora.config.*
92
+ validateWrangler: true, // set false to skip the wrangler.jsonc check
93
+
94
+ // Rsbuild only:
95
+ studio: true, // Lunora Studio at /__lunora (needs @lunora/studio)
96
+ worker: true, // false to run the Worker yourself (the proxy is still injected)
97
+ workerPort: 8787, // defaults to the wrangler config's `dev.port`, then 8787
98
+ wranglerArgs: [], // extra arguments appended to `wrangler dev`
99
+ });
100
+ ```
101
+
102
+ `LUNORA_CODEGEN=0` skips generation and the wrangler checks **in watch mode only**. A production build keeps generating: the ERROR-advisory gate is the only thing that fails it, so honouring the variable there would let an app ship against a surface its target cannot serve, green the whole way.
103
+
104
+ ## How the Worker runs
105
+
106
+ Not in-process. `@cloudflare/vite-plugin` runs the Worker _inside_ the dev server using Vite's Environment API — a module runner in workerd pulls each module over RPC from Vite. Rspack has no equivalent runner protocol, and the alternative (bundling the Worker ourselves for Miniflare) would mean reimplementing wrangler's `nodejs_compat`, Durable Object migrations, binding wiring and local persistence.
107
+
108
+ So `lunoraRsbuild` spawns `wrangler dev` and proxies to it. From your seat that is the same DX — one command, Worker included. What differs is that the Worker **restarts** on change rather than hot-swapping modules, and the process boundary means a few Vite-plugin features have no counterpart:
109
+
110
+ | Feature | Here | Where to get it |
111
+ | ---------------------------------------- | --------------- | --------------- |
112
+ | Codegen on save, wrangler validation | ✅ | — |
113
+ | Binding / cron / compatibility-date sync | ✅ | — |
114
+ | `.dev.vars` scaffolding + `WORKER_ENV` | ✅ (watch mode) | — |
115
+ | Worker running on `dev` | ✅ (Rsbuild) | — |
116
+ | Studio at `/__lunora` | ✅ (Rsbuild) | — |
117
+ | Browser error overlay | ❌ | `@lunora/vite` |
118
+ | Per-module HMR inside the Worker | ❌ (restarts) | `@lunora/vite` |
119
+ | Remote-binding dev (`LUNORA_REMOTE`) | ❌ | `lunora dev` |
120
+ | Class-A framework worker composition | ❌ | `@lunora/vite` |
121
+
122
+ ## What each pass does
123
+
124
+ Before every compilation, in this order:
125
+
126
+ 1. **Provision bindings** — infers the Durable Objects, their migration classes, and the `DB` D1 binding a `.global()` table implies, and writes them into `wrangler.jsonc`. Idempotent.
127
+ 2. **Validate** — checks that config against the schema's requirements, and throws when it is short one (`validateWrangler: false` opts out).
128
+ 3. **Generate** — runs `@lunora/codegen` into `<schemaDir>/_generated`, syncing your cron triggers and the compatibility date on the way.
129
+ 4. **`postcodegen`** — runs the project's hook.
130
+
131
+ In watch mode the plugin registers your schema directory as a watch dependency, so editing _or adding_ anything under `lunora/` regenerates. The first pass of a session also scaffolds `.dev.vars` (it is gitignored, so a fresh clone has none and the Worker throws on its first required secret).
132
+
133
+ A production build **fails** on an ERROR-level schema advisory or platform diagnostic, exactly as `vite build` and `lunora deploy` do: the finding lands in `compilation.errors`, so no bundle is emitted and the CLI exits non-zero. A watch rebuild logs it and carries on — a half-typed schema should not take the watcher down. Codegen _crashes_ are reported the same way in both modes, never thrown out of the hook.
134
+
135
+ > This README covers the basics. For the full API, options, and guides, see the **[documentation](https://lunora.sh/docs/packages/rspack)**.
136
+
137
+ ## Related
138
+
139
+ - [`@lunora/vite`](https://www.npmjs.com/package/@lunora/vite) — the Vite plugin, which runs the Worker in-process with per-module HMR.
140
+ - [`@lunora/cli`](https://www.npmjs.com/package/@lunora/cli) — the CLI; `lunora deploy` ships what this plugin generates.
141
+ - [`@lunora/codegen`](https://www.npmjs.com/package/@lunora/codegen) — the code generator run on schema changes.
142
+ - [`@lunora/config`](https://www.npmjs.com/package/@lunora/config) — shared `wrangler.jsonc` validation and binding inference.
143
+
144
+ ## Supported Node.js Versions
145
+
146
+ Libraries in this ecosystem make the best effort to track [Node.js' release schedule](https://github.com/nodejs/release#release-schedule).
147
+ Here's [a post on why we think this is important](https://medium.com/the-node-js-collection/maintainers-should-consider-following-node-js-release-schedule-ab08ed4de71a).
148
+
149
+ ## Contributing
150
+
151
+ If you would like to help take a look at the [list of issues](https://github.com/anolilab/lunora/issues) and check our [Contributing](https://github.com/anolilab/lunora/blob/alpha/.github/CONTRIBUTING.md) guidelines.
152
+
153
+ > **Note:** please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
154
+
155
+ ## Credits
156
+
157
+ - [Daniel Bannert](https://github.com/prisis)
158
+ - [All Contributors](https://github.com/anolilab/lunora/graphs/contributors)
159
+
160
+ ## Made with ❤️ at Anolilab
161
+
162
+ This is an open source project and will always remain free to use. If you think it's cool, please star it 🌟. [Anolilab](https://www.anolilab.com/open-source) is a Development and AI Studio. Contact us at [hello@anolilab.com](mailto:hello@anolilab.com) if you need any help with these technologies or just want to say hi!
163
+
164
+ ## License
165
+
166
+ The Lunora rspack package is open-sourced software licensed under the [FSL-1.1-Apache-2.0][license].
167
+
168
+ <!-- badges -->
44
169
 
45
- **Maintained for OIDC setup purposes only**
170
+ [license-badge]: https://img.shields.io/badge/license-FSL--1.1--Apache--2.0-blue.svg?style=for-the-badge
171
+ [license]: https://github.com/anolilab/lunora/blob/alpha/LICENSE.md
172
+ [npm-version-badge]: https://img.shields.io/npm/v/@lunora/rspack?style=for-the-badge
173
+ [npm-version]: https://www.npmjs.com/package/@lunora/rspack
174
+ [npm-downloads-badge]: https://img.shields.io/npm/dm/@lunora/rspack?style=for-the-badge
175
+ [npm-downloads]: https://www.npmjs.com/package/@lunora/rspack
176
+ [prs-welcome-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=for-the-badge
177
+ [prs-welcome]: https://github.com/anolilab/lunora/blob/alpha/.github/CONTRIBUTING.md
178
+ [typescript-badge]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript
179
+ [typescript-url]: https://www.typescriptlang.org/