In version 2.6.0, the generated .mjs file exposes only a default export of an object containing the Router, the syntax import {Router} from 'itty-router' does not work.
The generated .mjs file contains the following code, and is picked up by Rollup and Webpack by default, causes build to fail. Reverting back to version 2.5.3 works.
export default{Router:function({base:t="",routes:n=[]}={}){return{__proto__:new Proxy({},{get:(e,a,o)=>(e,...r)=>n.push([a.toUpperCase(),RegExp(`^${(t+e).replace(/(\/?)\*/g,"($1.*)?").replace(/\/$/,"").replace(/:(\w+)(\?)?(\.)?/g,"$2(?<$1>[^/]+)$2$3").replace(/\.(?=[\w(])/,"\\.").replace(/\)\.\?\(([^\[]+)\[\^/g,"?)\\.?($1(?<=\\.)[^\\.")}/*$`),r])&&o}),routes:n,async handle(e,...r){let a,o,t=new URL(e.url);e.query=Object.fromEntries(t.searchParams);for(var[p,s,u]of n)if((p===e.method||"ALL"===p)&&(o=t.pathname.match(s))){e.params=o.groups;for(var c of u)if(void 0!==(a=await c(e.proxy||e,...r)))return a}}}}};
In version 2.6.0, the generated
.mjs
file exposes only a default export of an object containing the Router, the syntaximport {Router} from 'itty-router'
does not work.The generated
.mjs
file contains the following code, and is picked up by Rollup and Webpack by default, causes build to fail. Reverting back to version 2.5.3 works.