@lunora/rspack 1.0.0-alpha.24 → 1.0.0-alpha.26

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/dist/index.d.mts CHANGED
@@ -36,6 +36,8 @@ interface CompilationLike {
36
36
  errors: Error[];
37
37
  /** Individual files that invalidate this compilation when they change. */
38
38
  fileDependencies: DependencySet;
39
+ /** Files that do not exist yet, and invalidate this compilation when they appear. */
40
+ missingDependencies: DependencySet;
39
41
  }
40
42
  /** The slice of `Compiler` this plugin taps. */
41
43
  interface CompilerLike {
package/dist/index.d.ts CHANGED
@@ -36,6 +36,8 @@ interface CompilationLike {
36
36
  errors: Error[];
37
37
  /** Individual files that invalidate this compilation when they change. */
38
38
  fileDependencies: DependencySet;
39
+ /** Files that do not exist yet, and invalidate this compilation when they appear. */
40
+ missingDependencies: DependencySet;
39
41
  }
40
42
  /** The slice of `Compiler` this plugin taps. */
41
43
  interface CompilerLike {
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{createRequire as r}from"node:module";import{r as e}from"./packem_shared/options-rWtSt-oe.mjs";import{LunoraRspackPlugin as t}from"./packem_shared/LunoraRspackPlugin-DPrjGG-k.mjs";const s=o=>new t(e(o)),i=r(import.meta.url)("../package.json").version;export{t as LunoraRspackPlugin,i as VERSION,s as lunoraRspack};
1
+ import{createRequire as r}from"node:module";import{r as e}from"./packem_shared/options-rWtSt-oe.mjs";import{LunoraRspackPlugin as t}from"./packem_shared/LunoraRspackPlugin-CqOpNzzn.mjs";const s=o=>new t(e(o)),i=r(import.meta.url)("../package.json").version;export{t as LunoraRspackPlugin,i as VERSION,s as lunoraRspack};
@@ -0,0 +1,3 @@
1
+ import{createHash as p}from"node:crypto";import{existsSync as g,readFileSync as m}from"node:fs";import{join as v,resolve as c}from"node:path";import{createCodegenProject as w,refreshCodegenProject as R,runCodegen as j,findTsconfig as h,fingerprintSchemaSources as E}from"@lunora/codegen";import{LUNORA_TAG as S,reportCodegenFindings as D,blockingFindingsMessage as y,isCodegenDisabled as P,CODEGEN_ENV as d,lunoraLine as n,runPostCodegenHook as C,ensureDevVariables as b,createConfirm as k,fillDevSecrets as F,ensureDevWorkerEnv as L,detectAgentRules as A,claimAgentRulesHint as N,AGENT_RULES_HINT as T}from"@lunora/config";import{collectWranglerSecretVariables as _,reconcileWranglerExtras as W,WRANGLER_FILES as x,warnCloudflareCliConfigOnce as G,findWranglerFile as I,reconcileBindingsSafely as M,assertWranglerSatisfiesSchema as H}from"@lunora/config/cloudflare";const O=(t,e,r)=>{const i=v(t.projectRoot,t.schemaDir,"schema.ts");if(!g(i)){e.warn(`${S} no schema found at ${i} — run \`lunora init\` or create it, then rebuild.`);return}const s=j({apiSpec:t.apiSpec,lunoraDirectory:t.schemaDir,project:r,projectRoot:t.projectRoot,target:t.target,wranglerVariables:_(t.projectRoot)});return W(t.projectRoot,s.cronTriggers,e),D(s,e),y(s)},U=t=>{let e;return{drop:()=>{e=void 0},get:()=>(e===void 0?e=w(t):R(e,t),e)}},l="LunoraRspackPlugin",V=2,f=t=>{try{return m(t,"utf8")}catch{return""}},o={error:t=>{console.error(t)},info:t=>{console.info(t)},warn:t=>{console.warn(t)}},u=async t=>{const e=r=>{o.info(n(r))};await b({confirm:k("[lunora] "),cwd:t.projectRoot,info:e}),F({cwd:t.projectRoot,info:e}),L(t.projectRoot,e),!A(t.projectRoot).installed&&N()&&o.warn(`
2
+ ${n(T)}
3
+ `)};class K{#e;#r;#c;#o;#s=!1;#h=!1;#n;#d;#i=[];#t;#a;constructor(e){this.#e=e,this.#r=c(e.projectRoot,e.schemaDir),this.#c=P(process.env[d]),this.#o=U(this.#r)}async prepareDevSession(){this.#f(),!this.#s&&(this.#s=!0,await u(this.#e))}async generateForDev(){await this.#l(!0)}apply(e){e.hooks.beforeCompile.tapPromise(l,async()=>{await this.#l(e.watchMode===!0)}),e.hooks.afterCompile.tapPromise(l,r=>{r.contextDependencies.add(this.#r);const i=h(this.#r);i!==void 0&&r.fileDependencies.add(i);for(const s of x){const a=c(this.#e.projectRoot,s);g(a)?r.fileDependencies.add(a):r.missingDependencies.add(a)}for(const s of this.#i)r.errors.push(s);return Promise.resolve()})}async#l(e){this.#a??=this.#g(e).finally(()=>{this.#a=void 0}),await this.#a}#f(){this.#h||(this.#h=G(this.#e.projectRoot,e=>{o.warn(n(e))}))}async#g(e){if(this.#f(),e&&this.#c){this.#s||(this.#s=!0,o.info(n(`codegen disabled via ${d} — skipping generation and the wrangler checks.`)));return}const r=this.#w();r!==this.#d&&(this.#o.drop(),this.#d=r,this.#n=void 0);const i=this.#m(r);if(!this.#p(i)){this.#i=[];try{!this.#s&&e&&await u(this.#e),this.#s=!0,await this.#v(e),this.#i.length===0?(this.#n=i,this.#t=void 0):this.#u(i)}catch(s){this.#o.drop(),this.#n=void 0,this.#i.push(s instanceof Error?s:new Error(String(s))),this.#u(i),o.error(s instanceof Error?s.message:String(s))}}}#p(e){return e===this.#n?!0:this.#t!==void 0&&this.#t.fingerprint===e&&this.#t.attempts>=V}#u(e){this.#t=this.#t?.fingerprint===e?{attempts:this.#t.attempts+1,fingerprint:e}:{attempts:1,fingerprint:e}}#m(e){const r=I(this.#e.projectRoot);return[E(this.#r),e,r===void 0?"":f(r)].map(s=>p("sha256").update(s).digest("hex")).join("")}async#v(e){await M(this.#e,o),this.#e.validateWrangler&&H(this.#e,o.warn,"Update your wrangler.jsonc and rebuild.");const r=O(this.#e,o,this.#o.get()),i=await C({cwd:this.#e.projectRoot,logger:o});i.error!==void 0&&this.#i.push(new Error(i.error)),!e&&r!==void 0&&this.#i.push(new Error(r))}#w(){const e=h(this.#r);return e===void 0?"":f(e)}}export{K as LunoraRspackPlugin,l as PLUGIN_NAME};
package/dist/rsbuild.mjs CHANGED
@@ -1 +1 @@
1
- import{formatLunoraEvent as m,lunoraLine as c,acceptsConnection as h,startDevProcess as S,targetRunsOwnDevServer as y,startCelldDevSession as R}from"@lunora/config";import{createStudioMiddleware as k,isNonLoopbackHost as A,studioMountPath as D}from"@lunora/config/studio-host";import{r as b}from"./packem_shared/options-rWtSt-oe.mjs";import{LunoraRspackPlugin as L}from"./packem_shared/LunoraRspackPlugin-DPrjGG-k.mjs";import{existsSync as P,mkdirSync as E}from"node:fs";import{resolve as g,dirname as W}from"node:path";import{findWranglerFile as j,readWranglerJsonc as x}from"@lunora/config/cloudflare";const O=8787,_=3e4,u=(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},f=(r,e=[])=>{const t=u(e,"--config","-c"),o=t===void 0?j(r):g(r,t);if(o===void 0||!P(o))return;const{parsed:n}=x(o);return n===void 0?void 0:{config:n,env:u(e,"--env","-e"),path:o}},$=(r,e,t)=>{if(e!==void 0)return e;const o=f(r,t)?.config.dev?.port;return typeof o=="number"?o:O},T=(r,e)=>{const t=f(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"&&E(g(W(t.path),n),{recursive:!0})},p=r=>{const e=m(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)},C=async r=>{if(await h(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\`.`);T(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:p,port:r.port,readyTimeoutMs:_,shell:e});return{port:r.port,stop:t.stop}},v="/_lunora",M="lunora:rsbuild",N=(r,e)=>{const t=`http://127.0.0.1:${String(e)}`;return Array.isArray(r)?[...r,{changeOrigin:!0,pathFilter:v,target:t,ws:!0}]:{[v]:{changeOrigin:!0,target:t,ws:!0},...r}},F=(r,e)=>{r.onBeforeStartDevServer(({server:t})=>{const{base:o,host:n}=r.getRsbuildConfig().server??{};t.middlewares.use(k({apiSpec:e.apiSpec,base:o,isNonLoopbackBind:A(n),projectRoot:e.projectRoot,schemaDirectory:e.schemaDir}))}),r.onAfterStartDevServer(({port:t})=>{console.info(c(`studio on http://localhost:${String(t)}${D(r.getRsbuildConfig().server?.base)}`))})},J=r=>{const e=b(r),t=$(e.projectRoot,r?.workerPort,r?.wranglerArgs),o=new L(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&&F(n,e),r?.worker===!1)return;let a,l;n.onBeforeStartDevServer(async()=>{if(await o.prepareDevSession(),await o.generateForDev(),console.info(c(`starting the worker on http://127.0.0.1:${String(t)} …`)),y(e.target)){const s=await R({log:(i,{tag:d})=>{p(d==="celld"?i:`[${d}] ${i}`)},port:t,projectRoot:e.projectRoot});l=s;const w=i=>{console.error(c(`the worker on celld exited (code ${String(i)}) — restart \`rsbuild dev\` to bring it back`))};s.exited.then(w).catch(()=>{});return}a=await C({port:t,projectRoot:e.projectRoot,wranglerArgs:r?.wranglerArgs})}),n.onCloseDevServer(async()=>{await a?.stop(),await l?.stop(),a=void 0,l=void 0})}}};export{v as LUNORA_PATH,M as RSBUILD_PLUGIN_NAME,J as lunoraRsbuild,N as withLunoraProxy};
1
+ import{formatLunoraEvent as m,lunoraLine as c,acceptsConnection as h,startDevProcess as S,targetRunsOwnDevServer as y,startCelldDevSession as R}from"@lunora/config";import{createStudioMiddleware as k,isNonLoopbackHost as A,studioMountPath as D}from"@lunora/config/studio-host";import{r as b}from"./packem_shared/options-rWtSt-oe.mjs";import{LunoraRspackPlugin as L}from"./packem_shared/LunoraRspackPlugin-CqOpNzzn.mjs";import{existsSync as P,mkdirSync as E}from"node:fs";import{resolve as g,dirname as W}from"node:path";import{findWranglerFile as j,readWranglerJsonc as x}from"@lunora/config/cloudflare";const O=8787,_=3e4,u=(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},f=(r,e=[])=>{const t=u(e,"--config","-c"),o=t===void 0?j(r):g(r,t);if(o===void 0||!P(o))return;const{parsed:n}=x(o);return n===void 0?void 0:{config:n,env:u(e,"--env","-e"),path:o}},$=(r,e,t)=>{if(e!==void 0)return e;const o=f(r,t)?.config.dev?.port;return typeof o=="number"?o:O},T=(r,e)=>{const t=f(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"&&E(g(W(t.path),n),{recursive:!0})},p=r=>{const e=m(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)},C=async r=>{if(await h(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\`.`);T(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:p,port:r.port,readyTimeoutMs:_,shell:e});return{port:r.port,stop:t.stop}},v="/_lunora",M="lunora:rsbuild",N=(r,e)=>{const t=`http://127.0.0.1:${String(e)}`;return Array.isArray(r)?[...r,{changeOrigin:!0,pathFilter:v,target:t,ws:!0}]:{[v]:{changeOrigin:!0,target:t,ws:!0},...r}},F=(r,e)=>{r.onBeforeStartDevServer(({server:t})=>{const{base:o,host:n}=r.getRsbuildConfig().server??{};t.middlewares.use(k({apiSpec:e.apiSpec,base:o,isNonLoopbackBind:A(n),projectRoot:e.projectRoot,schemaDirectory:e.schemaDir}))}),r.onAfterStartDevServer(({port:t})=>{console.info(c(`studio on http://localhost:${String(t)}${D(r.getRsbuildConfig().server?.base)}`))})},J=r=>{const e=b(r),t=$(e.projectRoot,r?.workerPort,r?.wranglerArgs),o=new L(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&&F(n,e),r?.worker===!1)return;let a,l;n.onBeforeStartDevServer(async()=>{if(await o.prepareDevSession(),await o.generateForDev(),console.info(c(`starting the worker on http://127.0.0.1:${String(t)} …`)),y(e.target)){const s=await R({log:(i,{tag:d})=>{p(d==="celld"?i:`[${d}] ${i}`)},port:t,projectRoot:e.projectRoot});l=s;const w=i=>{console.error(c(`the worker on celld exited (code ${String(i)}) — restart \`rsbuild dev\` to bring it back`))};s.exited.then(w).catch(()=>{});return}a=await C({port:t,projectRoot:e.projectRoot,wranglerArgs:r?.wranglerArgs})}),n.onCloseDevServer(async()=>{await a?.stop(),await l?.stop(),a=void 0,l=void 0})}}};export{v as LUNORA_PATH,M as RSBUILD_PLUGIN_NAME,J 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.24",
3
+ "version": "1.0.0-alpha.26",
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.260",
55
- "@lunora/config": "1.0.0-alpha.303"
54
+ "@lunora/codegen": "1.0.0-alpha.262",
55
+ "@lunora/config": "1.0.0-alpha.305"
56
56
  },
57
57
  "peerDependencies": {
58
58
  "@lunora/studio": ">=1.0.0-alpha.50 <2.0.0-0",
@@ -1,3 +0,0 @@
1
- import{createHash as g}from"node:crypto";import{existsSync as u,readFileSync as p}from"node:fs";import{join as m,resolve as v}from"node:path";import{createCodegenProject as w,refreshCodegenProject as R,runCodegen as j,findTsconfig as a,fingerprintSchemaSources as S}from"@lunora/codegen";import{LUNORA_TAG as y,reportCodegenFindings as E,blockingFindingsMessage as D,isCodegenDisabled as P,CODEGEN_ENV as c,lunoraLine as n,runPostCodegenHook as b,ensureDevVariables as k,createConfirm as C,fillDevSecrets as F,ensureDevWorkerEnv as A,detectAgentRules as L,claimAgentRulesHint as T,AGENT_RULES_HINT as N}from"@lunora/config";import{collectWranglerSecretVariables as _,reconcileWranglerExtras as W,findWranglerFile as h,reconcileBindingsSafely as x,assertWranglerSatisfiesSchema as M}from"@lunora/config/cloudflare";const G=(t,e,r)=>{const i=m(t.projectRoot,t.schemaDir,"schema.ts");if(!u(i)){e.warn(`${y} no schema found at ${i} — run \`lunora init\` or create it, then rebuild.`);return}const s=j({apiSpec:t.apiSpec,lunoraDirectory:t.schemaDir,project:r,projectRoot:t.projectRoot,target:t.target,wranglerVariables:_(t.projectRoot)});return W(t.projectRoot,s.cronTriggers,e),E(s,e),D(s)},H=t=>{let e;return{drop:()=>{e=void 0},get:()=>(e===void 0?e=w(t):R(e,t),e)}},d="LunoraRspackPlugin",I=2,l=t=>{try{return p(t,"utf8")}catch{return""}},o={error:t=>{console.error(t)},info:t=>{console.info(t)},warn:t=>{console.warn(t)}},f=async t=>{const e=r=>{o.info(n(r))};await k({confirm:C("[lunora] "),cwd:t.projectRoot,info:e}),F({cwd:t.projectRoot,info:e}),A(t.projectRoot,e),!L(t.projectRoot).installed&&T()&&o.warn(`
2
- ${n(N)}
3
- `)};class q{#e;#r;#c;#o;#i=!1;#n;#h;#s=[];#t;#a;constructor(e){this.#e=e,this.#r=v(e.projectRoot,e.schemaDir),this.#c=P(process.env[c]),this.#o=H(this.#r)}async prepareDevSession(){this.#i||(this.#i=!0,await f(this.#e))}async generateForDev(){await this.#d(!0)}apply(e){e.hooks.beforeCompile.tapPromise(d,async()=>{await this.#d(e.watchMode===!0)}),e.hooks.afterCompile.tapPromise(d,r=>{r.contextDependencies.add(this.#r);for(const i of[a(this.#r),h(this.#e.projectRoot)])i!==void 0&&r.fileDependencies.add(i);for(const i of this.#s)r.errors.push(i);return Promise.resolve()})}async#d(e){this.#a??=this.#f(e).finally(()=>{this.#a=void 0}),await this.#a}async#f(e){if(e&&this.#c){this.#i||(this.#i=!0,o.info(n(`codegen disabled via ${c} — skipping generation and the wrangler checks.`)));return}const r=this.#m();r!==this.#h&&(this.#o.drop(),this.#h=r,this.#n=void 0);const i=this.#u(r);if(!this.#g(i)){this.#s=[];try{!this.#i&&e&&await f(this.#e),this.#i=!0,await this.#p(e),this.#s.length===0?(this.#n=i,this.#t=void 0):this.#l(i)}catch(s){this.#o.drop(),this.#n=void 0,this.#s.push(s instanceof Error?s:new Error(String(s))),this.#l(i),o.error(s instanceof Error?s.message:String(s))}}}#g(e){return e===this.#n?!0:this.#t!==void 0&&this.#t.fingerprint===e&&this.#t.attempts>=I}#l(e){this.#t=this.#t?.fingerprint===e?{attempts:this.#t.attempts+1,fingerprint:e}:{attempts:1,fingerprint:e}}#u(e){const r=h(this.#e.projectRoot);return[S(this.#r),e,r===void 0?"":l(r)].map(s=>g("sha256").update(s).digest("hex")).join("")}async#p(e){await x(this.#e,o),this.#e.validateWrangler&&M(this.#e,o.warn,"Update your wrangler.jsonc and rebuild.");const r=G(this.#e,o,this.#o.get()),i=await b({cwd:this.#e.projectRoot,logger:o});i.error!==void 0&&this.#s.push(new Error(i.error)),!e&&r!==void 0&&this.#s.push(new Error(r))}#m(){const e=a(this.#r);return e===void 0?"":l(e)}}export{q as LunoraRspackPlugin,d as PLUGIN_NAME};