@lunora/rspack 1.0.0-alpha.10 → 1.0.0-alpha.12
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/rsbuild.mjs +1 -2
- package/package.json +3 -3
package/dist/rsbuild.mjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import{formatLunoraEvent as
|
|
2
|
-
`);r=o.pop()??"";for(const n of o)f(n)}),e?.once("end",()=>{r!==""&&(f(r),r="")})},M=async e=>{if(await w(e.port))throw new Error(`could not start the worker: port ${String(e.port)} is already in use. Stop whatever is serving there (another \`rsbuild dev\` or \`lunora dev\`?), or set \`workerPort\`.`);N(e.projectRoot,e.wranglerArgs);const r=["dev","--port",String(e.port),"--var","WORKER_ENV:development",...e.wranglerArgs??[]],t=process.platform==="win32",o=x(t?"wrangler.cmd":"wrangler",r,{cwd:e.projectRoot,shell:t,stdio:["ignore","pipe","pipe"]});p(o.stdout),p(o.stderr);let n;o.once("error",a=>{n=a.code==="ENOENT"?new Error("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."):a});const s=()=>{o.kill("SIGKILL")};process.once("exit",s);const i=async()=>{process.removeListener("exit",s),!(o.exitCode!==null||o.signalCode!==null)&&await new Promise(a=>{const S=setTimeout(()=>{o.kill("SIGKILL")},$);o.once("exit",()=>{clearTimeout(S),a()}),o.kill("SIGTERM")})};let c;o.once("exit",a=>{c??=new Error(`wrangler dev exited with code ${String(a)} before it was ready`)});const m=Date.now()+d;for(;Date.now()<m;){if(n!==void 0)throw n;if(c!==void 0)throw c;if(await w(e.port)){if(o.exitCode!==null||o.signalCode!==null)throw await i(),new Error(`the worker on port ${String(e.port)} is not the one this plugin started — it exited while something else took the port.`);return{port:e.port,stop:i}}await new Promise(a=>{setTimeout(a,W)})}throw await i(),new Error(`wrangler dev did not start listening on port ${String(e.port)} within ${String(d/1e3)}s`)},g="/_lunora",j="lunora:rsbuild",F=(e,r)=>{const t=`http://127.0.0.1:${String(r)}`;return Array.isArray(e)?[...e,{changeOrigin:!0,pathFilter:g,target:t,ws:!0}]:{[g]:{changeOrigin:!0,target:t,ws:!0},...e}},U=(e,r)=>{e.onBeforeStartDevServer(({server:t})=>{const{base:o,host:n}=e.getRsbuildConfig().server??{};t.middlewares.use(k({apiSpec:r.apiSpec,base:o,isNonLoopbackBind:A(n),projectRoot:r.projectRoot,schemaDirectory:r.schemaDir}))}),e.onAfterStartDevServer(({port:t})=>{console.info(l(`studio on http://localhost:${String(t)}${R(e.getRsbuildConfig().server?.base)}`))})},Q=e=>{const r=E(e),t=I(r.projectRoot,e?.workerPort,e?.wranglerArgs),o=new L(r);return{name:j,setup:n=>{if(n.modifyRspackConfig(i=>({...i,plugins:[...Array.isArray(i.plugins)?i.plugins:[],o]})),n.modifyRsbuildConfig(i=>({...i,server:{...i.server,proxy:F(i.server?.proxy,t)}})),e?.studio!==!1&&U(n,r),e?.worker===!1)return;let s;n.onBeforeStartDevServer(async()=>{await o.prepareDevSession(),await o.generateForDev(),console.info(l(`starting the worker on http://127.0.0.1:${String(t)} …`)),s=await M({port:t,projectRoot:r.projectRoot,wranglerArgs:e?.wranglerArgs})}),n.onCloseDevServer(async()=>{await s?.stop(),s=void 0})}}};export{g as LUNORA_PATH,j as RSBUILD_PLUGIN_NAME,Q as lunoraRsbuild,F 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-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};
|
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.12",
|
|
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.246",
|
|
55
|
+
"@lunora/config": "1.0.0-alpha.291"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"@lunora/studio": ">=1.0.0-alpha.50 <2.0.0-0",
|