@lunora/rspack 1.0.0-alpha.88 → 1.0.0-alpha.89
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 +2 -0
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/LunoraRspackPlugin-DI75z-kD.mjs +1 -0
- package/dist/packem_shared/plugin-DTSWDf5-.mjs +4 -0
- package/dist/rsbuild.mjs +1 -1
- package/package.json +3 -3
- package/dist/packem_shared/LunoraRspackPlugin-qS22fvOc.mjs +0 -1
- package/dist/packem_shared/plugin-DjFRHO3T.mjs +0 -4
package/README.md
CHANGED
|
@@ -99,6 +99,8 @@ lunoraRsbuild({
|
|
|
99
99
|
});
|
|
100
100
|
```
|
|
101
101
|
|
|
102
|
+
`target` must match the target the CLI resolved for the run. `lunora build` and `lunora deploy` set `LUNORA_BUILD_TARGET`, and a plugin whose target differs fails the build rather than emit an artifact for another host. Set the same target in the plugin options and `lunora.config.*`, or leave it unset to use the project's.
|
|
103
|
+
|
|
102
104
|
`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
105
|
|
|
104
106
|
## How the Worker runs
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createRequire as r}from"node:module";import{L as e,r as a}from"./packem_shared/plugin-
|
|
1
|
+
import{createRequire as r}from"node:module";import{L as e,r as a}from"./packem_shared/plugin-DTSWDf5-.mjs";const t=o=>new e(a(o)),p=r(import.meta.url)("../package.json").version;export{e as LunoraRspackPlugin,p as VERSION,t as lunoraRspack};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{L as r,P as s}from"./plugin-DTSWDf5-.mjs";export{r as LunoraRspackPlugin,s as PLUGIN_NAME};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{createHash as v}from"node:crypto";import{existsSync as w,readFileSync as S}from"node:fs";import{join as E,resolve as a}from"node:path";import{createCodegenProject as y,refreshCodegenProject as P,runCodegen as D,findTsconfig as d,PROJECT_CONFIG_FILENAMES as u,projectConfigCandidatePaths as p,fingerprintSchemaSources as C}from"@lunora/codegen";import{resolveTargetOrThrow as F,isRunnableTarget as T,runnableTargetIds as k,assertBuildTargetMatches as b,resolveLazyFunctions as I,LUNORA_TAG as g,writeApiSpecMarker as A,reportCodegenFindings as L,blockingFindingsMessage as _,STRICT_ADVISORIES_ENV as N,isCodegenDisabled as $,CODEGEN_ENV as f,lunoraLine as c,runPostCodegenHook as O,ensureDevVariables as M,createConfirm as W,fillDevSecrets as x,ensureDevWorkerEnv as G,detectAgentRules as z,claimAgentRulesHint as H,AGENT_RULES_HINT as U}from"@lunora/config";import{wranglerCodegenInputs as V,reconcileWranglerExtras as B,WRANGLER_FILES as J,warnCloudflareCliConfigOnce as X,findWranglerFile as q,reconcileBindingsSafely as K,assertWranglerSatisfiesSchema as Q}from"@lunora/config/cloudflare";const j=(t,e)=>{const r=F(t,e);if(!T(r))throw new Error(`target "${r}" has no command-line toolchain, so the Lunora Rspack plugin cannot build for it — it can only generate for it (\`lunora codegen --target ${r}\`). Buildable targets: ${k().join(", ")}`);return b(r,t),r},ae=t=>{const e=t??{},r=e.projectRoot??process.cwd();return{apiSpec:e.apiSpec??"openapi",explicitTarget:e.target,lazyFunctions:I(e.lazyFunctions),projectRoot:r,schemaDir:e.schemaDir??"lunora",target:j(r,e.target),validateWrangler:e.validateWrangler??!0}},Y=(t,e,r)=>{const i=E(t.projectRoot,t.schemaDir,"schema.ts");if(!w(i))return e.warn(`${g} no schema found at ${i} — run \`lunora init\` or create it, then rebuild.`),{};const s=D({apiSpec:t.apiSpec,lazyFunctions:t.lazyFunctions,lunoraDirectory:t.schemaDir,project:r,projectRoot:t.projectRoot,target:t.target,...V(t.projectRoot)});B(t.projectRoot,s.cronTriggers,e);let o;try{A(t.projectRoot,t.apiSpec)}catch(h){o=`${g} could not write the API spec marker: ${h instanceof Error?h.message:String(h)}`,e.error(o)}return L(s,e),{blockingMessage:_(s,{strictAdvisories:process.env[N]!=="0"}),markerFailure:o}},Z=t=>{let e;return{drop:()=>{e=void 0},get:()=>(e===void 0?e=y(t):P(e,t),e)}},m="LunoraRspackPlugin",ee=2,l=t=>{try{return S(t,"utf8")}catch{return""}},n={error:t=>{console.error(t)},info:t=>{console.info(t)},warn:t=>{console.warn(t)}},R=async t=>{const e=r=>{n.info(c(r))};await M({confirm:W("[lunora] "),cwd:t.projectRoot,info:e}),x({cwd:t.projectRoot,info:e}),G(t.projectRoot,e),!z(t.projectRoot).installed&&H()&&n.warn(`
|
|
2
|
+
${c(U)}
|
|
3
|
+
`)};class ce{#e;#c;#t;#h;#o;#i=!1;#l=!1;#n;#d;#r=[];#s;#a;constructor(e){this.#e=e,this.#t=a(e.projectRoot,e.schemaDir),this.#h=$(process.env[f]),this.#o=Z(this.#t)}async prepareDevSession(){this.#p(),!this.#i&&(this.#i=!0,await R(this.#e))}async generateForDev(){return await this.#u(!0),this.#c??this.#e.target}apply(e){e.hooks.beforeCompile.tapPromise(m,async()=>{await this.#u(e.watchMode===!0)}),e.hooks.afterCompile.tapPromise(m,r=>{r.contextDependencies.add(this.#t);const i=d(this.#t);i!==void 0&&r.fileDependencies.add(i);const s=[...J.map(o=>a(this.#e.projectRoot,o)),...u.map(o=>a(this.#e.projectRoot,o)),...p(this.#t)];for(const o of new Set(s))w(o)?r.fileDependencies.add(o):r.missingDependencies.add(o);for(const o of this.#r)r.errors.push(o);return Promise.resolve()})}async#u(e){this.#a??=this.#f(e).finally(()=>{this.#a=void 0}),await this.#a}#p(){this.#l||(this.#l=X(this.#e.projectRoot,e=>{n.warn(c(e))}))}async#f(e){if(this.#p(),e&&this.#h){this.#i||(this.#i=!0,n.info(c(`codegen disabled via ${f} — skipping generation and the wrangler checks.`)));return}const r=this.#j();r!==this.#d&&(this.#o.drop(),this.#d=r,this.#n=void 0);const i=this.#R(r);if(!this.#m(i)){this.#r=[];try{!this.#i&&e&&await R(this.#e),this.#i=!0,await this.#w(e),this.#r.length===0?(this.#n=i,this.#s=void 0):this.#g(i)}catch(s){this.#o.drop(),this.#n=void 0,this.#r.push(s instanceof Error?s:new Error(String(s))),this.#g(i),n.error(s instanceof Error?s.message:String(s))}}}#m(e){return e===this.#n?!0:this.#s!==void 0&&this.#s.fingerprint===e&&this.#s.attempts>=ee}#g(e){this.#s=this.#s?.fingerprint===e?{attempts:this.#s.attempts+1,fingerprint:e}:{attempts:1,fingerprint:e}}#R(e){const r=q(this.#e.projectRoot);return[C(this.#t),e,r===void 0?"":l(r)].map(s=>v("sha256").update(s).digest("hex")).join("")}async#w(e){this.#e={...this.#e,target:j(this.#e.projectRoot,this.#e.explicitTarget)},await K(this.#e,n),this.#e.validateWrangler&&Q(this.#e,n.warn,"Update your wrangler.jsonc and rebuild.");const{blockingMessage:r,markerFailure:i}=Y(this.#e,n,this.#o.get());this.#c=this.#e.target;const s=await O({cwd:this.#e.projectRoot,logger:n});s.error!==void 0&&this.#r.push(new Error(s.error)),!e&&r!==void 0&&this.#r.push(new Error(r)),!e&&i!==void 0&&this.#r.push(new Error(i))}#j(){const e=d(this.#t),i=[...new Set([...p(this.#t),...u.map(s=>a(this.#e.projectRoot,s))])].map(s=>`${s}
|
|
4
|
+
${l(s)}`);return[e===void 0?"":l(e),...i].join("\0")}}export{ce as L,m as P,ae as r};
|
package/dist/rsbuild.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{formatLunoraEvent as h,lunoraLine as c,acceptsConnection as y,startDevProcess as S,targetRunsOwnDevServer as R,startCelldDevSession as k}from"@lunora/config";import{createStudioMiddleware as A,isNonLoopbackHost as D,studioMountPath as b}from"@lunora/config/studio-host";import{r as L,L as P}from"./packem_shared/plugin-
|
|
1
|
+
import{formatLunoraEvent as h,lunoraLine as c,acceptsConnection as y,startDevProcess as S,targetRunsOwnDevServer as R,startCelldDevSession as k}from"@lunora/config";import{createStudioMiddleware as A,isNonLoopbackHost as D,studioMountPath as b}from"@lunora/config/studio-host";import{r as L,L as P}from"./packem_shared/plugin-DTSWDf5-.mjs";import{existsSync as E,mkdirSync as W}from"node:fs";import{resolve as f,dirname as j}from"node:path";import{findWranglerFile as x,readWranglerJsonc as O}from"@lunora/config/cloudflare";const _=8787,$=3e4,v=(r,e,t)=>{let o;for(const[n,a]of r.entries())a.startsWith(`${e}=`)?o=a.slice(e.length+1):(a===e||a===t)&&n+1<r.length&&(o=r[n+1]);return o},p=(r,e=[])=>{const t=v(e,"--config","-c"),o=t===void 0?x(r):f(r,t);if(o===void 0||!E(o))return;const{parsed:n}=O(o);return n===void 0?void 0:{config:n,env:v(e,"--env","-e"),path:o}},T=(r,e,t)=>{if(e!==void 0)return e;const o=p(r,t)?.config.dev?.port;return typeof o=="number"?o:_},C=(r,e)=>{const t=p(r,e);if(t===void 0)return;const n=((t.env===void 0?void 0:t.config.env?.[t.env]?.assets)??t.config.assets)?.directory;typeof n=="string"&&W(f(j(t.path),n),{recursive:!0})},w=r=>{const e=h(r);if(e===void 0){r.trim()!==""&&console.log(r);return}const t=c(e.text);e.level==="error"?console.error(t):e.level==="warn"?console.warn(t):console.info(t)},F=async r=>{if(await y(r.port))throw new Error(`could not start the worker: port ${String(r.port)} is already in use. Stop whatever is serving there (another \`rsbuild dev\` or \`lunora dev\`?), or set \`workerPort\`.`);C(r.projectRoot,r.wranglerArgs);const e=process.platform==="win32",t=await S({args:["dev","--port",String(r.port),"--var","WORKER_ENV:development",...r.wranglerArgs??[]],command:e?"wrangler.cmd":"wrangler",cwd:r.projectRoot,label:"wrangler dev",notFound:"could not start the worker: `wrangler` was not found on PATH. Add it to the project (`npm install -D wrangler`), or pass `worker: false` to run the worker yourself.",onLine:w,port:r.port,readyTimeoutMs:$,shell:e});return{port:r.port,stop:t.stop}},g="/_lunora",M="lunora:rsbuild",N=(r,e)=>{const t=`http://127.0.0.1:${String(e)}`;return Array.isArray(r)?[...r,{changeOrigin:!0,pathFilter:g,target:t,ws:!0}]:{[g]:{changeOrigin:!0,target:t,ws:!0},...r}},U=(r,e)=>{r.onBeforeStartDevServer(({server:t})=>{const{base:o,host:n}=r.getRsbuildConfig().server??{};t.middlewares.use(A({apiSpec:e.apiSpec,lazyFunctions:e.lazyFunctions,base:o,isNonLoopbackBind:D(n),projectRoot:e.projectRoot,schemaDirectory:e.schemaDir}))}),r.onAfterStartDevServer(({port:t})=>{console.info(c(`studio on http://localhost:${String(t)}${b(r.getRsbuildConfig().server?.base)}`))})},G=r=>{const e=L(r),t=T(e.projectRoot,r?.workerPort,r?.wranglerArgs),o=new P(e);return{name:M,setup:n=>{if(n.modifyRspackConfig(s=>({...s,plugins:[...Array.isArray(s.plugins)?s.plugins:[],o]})),n.modifyRsbuildConfig(s=>({...s,server:{...s.server,proxy:N(s.server?.proxy,t)}})),r?.studio!==!1&&U(n,e),r?.worker===!1)return;let a,l;n.onBeforeStartDevServer(async()=>{await o.prepareDevSession();const s=await o.generateForDev();if(console.info(c(`starting the worker on http://127.0.0.1:${String(t)} …`)),R(s)){const d=await k({log:(i,{tag:u})=>{w(u==="celld"?i:`[${u}] ${i}`)},port:t,projectRoot:e.projectRoot});l=d;const m=i=>{console.error(c(`the worker on celld exited (code ${String(i)}) — restart \`rsbuild dev\` to bring it back`))};d.exited.then(m).catch(()=>{});return}a=await F({port:t,projectRoot:e.projectRoot,wranglerArgs:r?.wranglerArgs})}),n.onCloseDevServer(async()=>{await a?.stop(),await l?.stop(),a=void 0,l=void 0})}}};export{g as LUNORA_PATH,M as RSBUILD_PLUGIN_NAME,G as lunoraRsbuild,N as withLunoraProxy};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/rspack",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.89",
|
|
4
4
|
"description": "The Lunora Rspack plugin: codegen, binding provisioning, and wrangler validation for Rspack projects",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
"access": "public"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@lunora/codegen": "1.0.0-alpha.
|
|
55
|
-
"@lunora/config": "1.0.0-alpha.
|
|
54
|
+
"@lunora/codegen": "1.0.0-alpha.342",
|
|
55
|
+
"@lunora/config": "1.0.0-alpha.393"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"@lunora/studio": ">=1.0.0-alpha.50 <2.0.0-0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{L as r,P as s}from"./plugin-DjFRHO3T.mjs";export{r as LunoraRspackPlugin,s as PLUGIN_NAME};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{createHash as v}from"node:crypto";import{existsSync as w,readFileSync as S}from"node:fs";import{join as E,resolve as a}from"node:path";import{createCodegenProject as y,refreshCodegenProject as P,runCodegen as D,findTsconfig as d,PROJECT_CONFIG_FILENAMES as p,projectConfigCandidatePaths as u,fingerprintSchemaSources as C}from"@lunora/codegen";import{resolveTargetOrThrow as F,isRunnableTarget as k,runnableTargetIds as T,resolveLazyFunctions as b,LUNORA_TAG as g,writeApiSpecMarker as I,reportCodegenFindings as A,blockingFindingsMessage as L,STRICT_ADVISORIES_ENV as _,isCodegenDisabled as N,CODEGEN_ENV as f,lunoraLine as c,runPostCodegenHook as $,ensureDevVariables as O,createConfirm as M,fillDevSecrets as W,ensureDevWorkerEnv as x,detectAgentRules as G,claimAgentRulesHint as z,AGENT_RULES_HINT as H}from"@lunora/config";import{wranglerCodegenInputs as U,reconcileWranglerExtras as V,WRANGLER_FILES as B,warnCloudflareCliConfigOnce as J,findWranglerFile as X,reconcileBindingsSafely as q,assertWranglerSatisfiesSchema as K}from"@lunora/config/cloudflare";const j=(t,e)=>{const r=F(t,e);if(!k(r))throw new Error(`target "${r}" has no command-line toolchain, so the Lunora Rspack plugin cannot build for it — it can only generate for it (\`lunora codegen --target ${r}\`). Buildable targets: ${T().join(", ")}`);return r},ne=t=>{const e=t??{},r=e.projectRoot??process.cwd();return{apiSpec:e.apiSpec??"openapi",explicitTarget:e.target,lazyFunctions:b(e.lazyFunctions),projectRoot:r,schemaDir:e.schemaDir??"lunora",target:j(r,e.target),validateWrangler:e.validateWrangler??!0}},Q=(t,e,r)=>{const i=E(t.projectRoot,t.schemaDir,"schema.ts");if(!w(i))return e.warn(`${g} no schema found at ${i} — run \`lunora init\` or create it, then rebuild.`),{};const s=D({apiSpec:t.apiSpec,lazyFunctions:t.lazyFunctions,lunoraDirectory:t.schemaDir,project:r,projectRoot:t.projectRoot,target:t.target,...U(t.projectRoot)});V(t.projectRoot,s.cronTriggers,e);let o;try{I(t.projectRoot,t.apiSpec)}catch(h){o=`${g} could not write the API spec marker: ${h instanceof Error?h.message:String(h)}`,e.error(o)}return A(s,e),{blockingMessage:L(s,{strictAdvisories:process.env[_]!=="0"}),markerFailure:o}},Y=t=>{let e;return{drop:()=>{e=void 0},get:()=>(e===void 0?e=y(t):P(e,t),e)}},m="LunoraRspackPlugin",Z=2,l=t=>{try{return S(t,"utf8")}catch{return""}},n={error:t=>{console.error(t)},info:t=>{console.info(t)},warn:t=>{console.warn(t)}},R=async t=>{const e=r=>{n.info(c(r))};await O({confirm:M("[lunora] "),cwd:t.projectRoot,info:e}),W({cwd:t.projectRoot,info:e}),x(t.projectRoot,e),!G(t.projectRoot).installed&&z()&&n.warn(`
|
|
2
|
-
${c(H)}
|
|
3
|
-
`)};class ae{#e;#c;#t;#h;#o;#i=!1;#l=!1;#n;#d;#r=[];#s;#a;constructor(e){this.#e=e,this.#t=a(e.projectRoot,e.schemaDir),this.#h=N(process.env[f]),this.#o=Y(this.#t)}async prepareDevSession(){this.#u(),!this.#i&&(this.#i=!0,await R(this.#e))}async generateForDev(){return await this.#p(!0),this.#c??this.#e.target}apply(e){e.hooks.beforeCompile.tapPromise(m,async()=>{await this.#p(e.watchMode===!0)}),e.hooks.afterCompile.tapPromise(m,r=>{r.contextDependencies.add(this.#t);const i=d(this.#t);i!==void 0&&r.fileDependencies.add(i);const s=[...B.map(o=>a(this.#e.projectRoot,o)),...p.map(o=>a(this.#e.projectRoot,o)),...u(this.#t)];for(const o of new Set(s))w(o)?r.fileDependencies.add(o):r.missingDependencies.add(o);for(const o of this.#r)r.errors.push(o);return Promise.resolve()})}async#p(e){this.#a??=this.#f(e).finally(()=>{this.#a=void 0}),await this.#a}#u(){this.#l||(this.#l=J(this.#e.projectRoot,e=>{n.warn(c(e))}))}async#f(e){if(this.#u(),e&&this.#h){this.#i||(this.#i=!0,n.info(c(`codegen disabled via ${f} — skipping generation and the wrangler checks.`)));return}const r=this.#j();r!==this.#d&&(this.#o.drop(),this.#d=r,this.#n=void 0);const i=this.#R(r);if(!this.#m(i)){this.#r=[];try{!this.#i&&e&&await R(this.#e),this.#i=!0,await this.#w(e),this.#r.length===0?(this.#n=i,this.#s=void 0):this.#g(i)}catch(s){this.#o.drop(),this.#n=void 0,this.#r.push(s instanceof Error?s:new Error(String(s))),this.#g(i),n.error(s instanceof Error?s.message:String(s))}}}#m(e){return e===this.#n?!0:this.#s!==void 0&&this.#s.fingerprint===e&&this.#s.attempts>=Z}#g(e){this.#s=this.#s?.fingerprint===e?{attempts:this.#s.attempts+1,fingerprint:e}:{attempts:1,fingerprint:e}}#R(e){const r=X(this.#e.projectRoot);return[C(this.#t),e,r===void 0?"":l(r)].map(s=>v("sha256").update(s).digest("hex")).join("")}async#w(e){this.#e={...this.#e,target:j(this.#e.projectRoot,this.#e.explicitTarget)},await q(this.#e,n),this.#e.validateWrangler&&K(this.#e,n.warn,"Update your wrangler.jsonc and rebuild.");const{blockingMessage:r,markerFailure:i}=Q(this.#e,n,this.#o.get());this.#c=this.#e.target;const s=await $({cwd:this.#e.projectRoot,logger:n});s.error!==void 0&&this.#r.push(new Error(s.error)),!e&&r!==void 0&&this.#r.push(new Error(r)),!e&&i!==void 0&&this.#r.push(new Error(i))}#j(){const e=d(this.#t),i=[...new Set([...u(this.#t),...p.map(s=>a(this.#e.projectRoot,s))])].map(s=>`${s}
|
|
4
|
-
${l(s)}`);return[e===void 0?"":l(e),...i].join("\0")}}export{ae as L,m as P,ne as r};
|