@visulima/packem-rollup 1.0.0-alpha.25 → 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/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## @visulima/packem-rollup [1.0.0-alpha.26](https://github.com/visulima/packem/compare/@visulima/packem-rollup@1.0.0-alpha.25...@visulima/packem-rollup@1.0.0-alpha.26) (2025-11-08)
2
+
3
+ ### Features
4
+
5
+ * add unbundle mode to preserve source file structure ([317e992](https://github.com/visulima/packem/commit/317e9925eae1344a2459f044250e717241a1d5a5))
6
+
7
+ ### Miscellaneous Chores
8
+
9
+ * update package.json and pnpm-lock.yaml for dependency management ([aa523ca](https://github.com/visulima/packem/commit/aa523ca16f29ba0a874a13693d1f9581acf6f8c3))
10
+
1
11
  ## @visulima/packem-rollup [1.0.0-alpha.25](https://github.com/visulima/packem/compare/@visulima/packem-rollup@1.0.0-alpha.24...@visulima/packem-rollup@1.0.0-alpha.25) (2025-10-28)
2
12
 
3
13
  ### Features
@@ -1,3 +1,3 @@
1
- var M=Object.defineProperty;var $=(t,e)=>M(t,"name",{value:e,configurable:!0});import{createFilter as T}from"@rollup/pluginutils";import{readFile as G}from"@visulima/fs";import{ENDING_REGEX as O}from"@visulima/packem-share/constants";import{getDtsExtension as U}from"@visulima/packem-share/utils";import{dirname as I,toNamespacedPath as w,sep as D,extname as _,join as W,basename as F,relative as C}from"@visulima/path";import{parseAsync as J}from"oxc-parser";import{_ as L}from"../../packem_shared/fix-dts-default-cjs-exports-BQc0nwIG.js";var X=Object.defineProperty,q=$((t,e)=>X(t,"name",{value:e,configurable:!0}),"e");const A=/^([\w-]+):/,P=q(t=>{if(!t||typeof t!="string")throw new Error("Invalid key: Key must be a non-empty string.");const e=[],c=A.exec(t);c&&(e.push(c[1]),t=t.replace(A,""));const a=t.split("/");for(const l of a)(l.includes("*")||l)&&e.push(l);return e},"splitTsconfigPathKey");var z=Object.defineProperty,B=$((t,e)=>z(t,"name",{value:e,configurable:!0}),"h");const H=B((t,e)=>{const c=t.replace(/^\.\//,""),a=e.replace(/^\.\//,"");if(a.startsWith(c))return t+a.slice(c.length);if(t.endsWith(e))return t;const l=P(t),d=P(e);let p=l.length-1,r=d.length-1;for(;p>=0&&r>=0&&l[p]===d[r];)p--,r--;let n=l.slice(0,p).join("/");const m=d.slice(r).join("/");return(!n.startsWith(".")||n==="")&&(n=`./${n}`),n+(m?`/${m}`:"")},"extendString");var Q=Object.defineProperty,V=$((t,e)=>Q(t,"name",{value:e,configurable:!0}),"s");const Y=V((...t)=>{if(t.length===0)return"";if(t.length===1)return I(t[0]);t=t.map(l=>w(l).split(D).join("/"));const[e,...c]=t;let a=e.split("/");for(const l of c){const d=l.split("/",a.length);let p=0;for(const r of d)if(r===a[p])p+=1;else{a=a.slice(0,p);break}a=a.slice(0,p)}return(a.length<=1&&a[0]===""?`/${a[0]}`:a.join("/")).split("/").join(D)},"lowestCommonAncestor");var Z=Object.defineProperty,x=$((t,e)=>Z(t,"name",{value:e,configurable:!0}),"u");const K=x((t,e)=>`${t}
2
- //# sourceMappingURL=${F(e)}.map
3
- `,"appendMapUrl"),k=x((t,e,c)=>JSON.stringify({file:F(c),mappings:t,names:[],sourceRoot:"",sources:[C(I(c),e)],version:3}),"generateDtsMap"),ce=x((t,e)=>{const c=T(e.options.include,e.options.exclude);let a=Object.create(null);const l=x((r,n)=>{a[r.replace(O,"")]={...n,ext:_(r)}},"addOutput");let d=[];e.tsconfig?.config.compilerOptions&&(d=Object.entries(e.tsconfig.config.compilerOptions.paths??{}).map(([r])=>r.endsWith("*")?new RegExp(`^${r.replace("*","(.*)")}$`):new RegExp(`^${r}$`)));async function p(r,n){if(!c(n))return;let m;try{m=(await J(n,r)).program}catch(o){e.logger.debug({message:o.message,prefix:"packem:isolated-declarations"})}if(m){const o=m.body.filter(s=>(s.type==="ImportDeclaration"||s.type==="ExportAllDeclaration"||s.type==="ExportNamedDeclaration")&&s.source);for await(const s of o){if(F(s.source.value).includes("."))continue;const i=await this.resolve(s.source.value,n);if(!(!i||i.external)&&(i.id.endsWith(".ts")||i.id.endsWith(".cts")||i.id.endsWith(".mts")||i.id.endsWith(".tsx")||i.id.endsWith(".ctsx")||i.id.endsWith(".mtsx"))){const g=i.id.replace(`${t}/`,"");let j=s.source.value;d.some(f=>f.test(s.source.value))&&!s.source.value.startsWith(".")&&(j=`./${s.source.value}`),r=r.replaceAll(`from "${s.source.value}"`,`from "${H(j,g)}"`)}}}const{errors:y,map:u,sourceText:v}=await e.options.isolatedDeclarationTransformer(n,r,e.options.sourcemap,e.tsconfig?.config?.compilerOptions);if(y.length>0){if(e.options.rollup.isolatedDeclarations.ignoreErrors){this.warn(y[0]);return}return this.error(y[0])}if(l(n,{map:u,source:v}),!m)return;const h=m.body.filter(o=>!("source"in o)||!o.source?!1:"importKind"in o&&o.importKind==="type"||"exportKind"in o&&o.exportKind==="type"?!0:o.type==="ImportDeclaration"?o.specifiers&&o.specifiers.every(s=>s.type==="ImportSpecifier"&&s.importKind==="type"):o.type==="ExportNamedDeclaration"&&o.specifiers&&o.specifiers.every(s=>s.exportKind==="type"));for await(const o of h){if(!o.source)continue;const s=await this.resolve(o.source.value,n);if(!s)return;const i=s.id;if(c(i)&&!a[i.replace(O,"")])try{const g=await G(i);await p.call(this,g,i)}catch{}}}return $(p,"E"),x(p,"transform"),{buildStart(){a=Object.create(null)},name:"packem:isolated-declarations",async renderStart(r,{input:n}){const m=Y(...Array.isArray(n)?n:Object.values(n));e.logger.debug({message:`Input base:${m}`,prefix:"packem:isolated-declarations"}),typeof r.entryFileNames=="function"&&(r.entryFileNames=r.entryFileNames({name:r.name}));const y=r.entryFileNames.replace(/\.(.)?[jt]sx?$/,(u,v)=>`.d.${v||""}ts`);for await(let[u,{ext:v,map:h,source:o}]of Object.entries(a)){if(e.options.rollup.cjsInterop&&r.format==="cjs"){const f=L(o,{fileName:u,imports:[]},{warn:this.warn});f&&(o=f.code)}const s=o.includes("from '")?"'":'"',i=u+v;if((e.options.declaration===!0||e.options.declaration==="compatible")&&r.format==="cjs"){e.logger.debug({message:`Emit compatible dts file: ${u}`,prefix:"packem:isolated-declarations"});const f=y.replace("[name]",w(u).replace(`${t}/`,"")).replace(".cts",".ts");let b=o;e.options.sourcemap&&h&&(b=K(b.trim(),f),this.emitFile({fileName:`${f}.map`,originalFileName:i,source:k(h,i,W(r.dir,f)),type:"asset"})),this.emitFile({fileName:f,originalFileName:i,source:b.replaceAll(/(from\s)['|"]((.*)\..+|['|"].*)['|"];?/g,(E,N,R,S)=>`${N+s+(S||R)}.d.ts${s};`),type:"asset"})}e.logger.debug({message:`Emit dts file: ${u}`,prefix:"packem:isolated-declarations"});const g=y.replace("[name]",w(u).replace(`${t}/`,""));e.options.sourcemap&&h&&(o=K(o.trim(),g),this.emitFile({fileName:`${g}.map`,originalFileName:i,source:k(h,i,W(r.dir,g)),type:"asset"}));const j=U(e,r.format==="cjs"?"cjs":"esm");this.emitFile({fileName:g,originalFileName:i,source:o.replaceAll(/(from\s)['|"]((.*)\..+|['|"].*)['|"];?/g,(f,b,E,N)=>`${b+s+(N||E)}.${j}${s};`),type:"asset"})}},transform:p}},"isolatedDeclarationsPlugin");export{ce as isolatedDeclarationsPlugin};
1
+ var G=Object.defineProperty;var $=(t,e)=>G(t,"name",{value:e,configurable:!0});import{createFilter as U}from"@rollup/pluginutils";import{readFile as _}from"@visulima/fs";import{ENDING_REGEX as E}from"@visulima/packem-share/constants";import{getDtsExtension as C}from"@visulima/packem-share/utils";import{dirname as S,toNamespacedPath as w,sep as F,extname as J,isAbsolute as L,relative as R,join as k,basename as O}from"@visulima/path";import{parseAsync as X}from"oxc-parser";import{_ as q}from"../../packem_shared/fix-dts-default-cjs-exports-BQc0nwIG.js";var z=Object.defineProperty,B=$((t,e)=>z(t,"name",{value:e,configurable:!0}),"e");const A=/^([\w-]+):/,P=B(t=>{if(!t||typeof t!="string")throw new Error("Invalid key: Key must be a non-empty string.");const e=[],c=A.exec(t);c&&(e.push(c[1]),t=t.replace(A,""));const n=t.split("/");for(const l of n)(l.includes("*")||l)&&e.push(l);return e},"splitTsconfigPathKey");var H=Object.defineProperty,Q=$((t,e)=>H(t,"name",{value:e,configurable:!0}),"h");const V=Q((t,e)=>{const c=t.replace(/^\.\//,""),n=e.replace(/^\.\//,"");if(n.startsWith(c))return t+n.slice(c.length);if(t.endsWith(e))return t;const l=P(t),u=P(e);let p=l.length-1,r=u.length-1;for(;p>=0&&r>=0&&l[p]===u[r];)p--,r--;let o=l.slice(0,p).join("/");const m=u.slice(r).join("/");return(!o.startsWith(".")||o==="")&&(o=`./${o}`),o+(m?`/${m}`:"")},"extendString");var Y=Object.defineProperty,Z=$((t,e)=>Y(t,"name",{value:e,configurable:!0}),"s");const ee=Z((...t)=>{if(t.length===0)return"";if(t.length===1)return S(t[0]);t=t.map(l=>w(l).split(F).join("/"));const[e,...c]=t;let n=e.split("/");for(const l of c){const u=l.split("/",n.length);let p=0;for(const r of u)if(r===n[p])p+=1;else{n=n.slice(0,p);break}n=n.slice(0,p)}return(n.length<=1&&n[0]===""?`/${n[0]}`:n.join("/")).split("/").join(F)},"lowestCommonAncestor");var te=Object.defineProperty,j=$((t,e)=>te(t,"name",{value:e,configurable:!0}),"u");const K=j((t,e)=>`${t}
2
+ //# sourceMappingURL=${O(e)}.map
3
+ `,"appendMapUrl"),I=j((t,e,c)=>JSON.stringify({file:O(c),mappings:t,names:[],sourceRoot:"",sources:[R(S(c),e)],version:3}),"generateDtsMap"),pe=j((t,e)=>{const c=U(e.options.include,e.options.exclude);let n=Object.create(null);const l=j((r,o)=>{n[r.replace(E,"")]={...o,ext:J(r)}},"addOutput");let u=[];e.tsconfig?.config.compilerOptions&&(u=Object.entries(e.tsconfig.config.compilerOptions.paths??{}).map(([r])=>r.endsWith("*")?new RegExp(`^${r.replace("*","(.*)")}$`):new RegExp(`^${r}$`)));async function p(r,o){if(!(o.endsWith(".ts")||o.endsWith(".cts")||o.endsWith(".mts")||o.endsWith(".tsx")||o.endsWith(".ctsx")||o.endsWith(".mtsx"))||!c(o))return;let m;try{m=(await X(o,r)).program}catch(i){e.logger.debug({message:i.message,prefix:"packem:isolated-declarations"})}if(m){const i=m.body.filter(s=>(s.type==="ImportDeclaration"||s.type==="ExportAllDeclaration"||s.type==="ExportNamedDeclaration")&&s.source);for await(const s of i){if(O(s.source.value).includes("."))continue;const a=await this.resolve(s.source.value,o);if(!(!a||a.external)&&(a.id.endsWith(".ts")||a.id.endsWith(".cts")||a.id.endsWith(".mts")||a.id.endsWith(".tsx")||a.id.endsWith(".ctsx")||a.id.endsWith(".mtsx"))){const f=a.id.replace(`${t}/`,"");let h=s.source.value;u.some(W=>W.test(s.source.value))&&!s.source.value.startsWith(".")&&(h=`./${s.source.value}`),r=r.replaceAll(`from "${s.source.value}"`,`from "${V(h,f)}"`)}}}const{errors:y,map:d,sourceText:b}=await e.options.isolatedDeclarationTransformer(o,r,e.options.sourcemap,e.tsconfig?.config?.compilerOptions);if(y.length>0){if(e.options.rollup.isolatedDeclarations.ignoreErrors){this.warn(y[0]);return}return this.error(y[0])}if(l(o,{map:d,source:b}),!m)return;const x=m.body.filter(i=>!("source"in i)||!i.source?!1:"importKind"in i&&i.importKind==="type"||"exportKind"in i&&i.exportKind==="type"?!0:i.type==="ImportDeclaration"?i.specifiers&&i.specifiers.every(s=>s.type==="ImportSpecifier"&&s.importKind==="type"):i.type==="ExportNamedDeclaration"&&i.specifiers&&i.specifiers.every(s=>s.exportKind==="type"));for await(const i of x){if(!i.source)continue;const s=await this.resolve(i.source.value,o);if(!s)return;const a=s.id;if(c(a)&&!n[a.replace(E,"")])try{const f=await _(a);await p.call(this,f,a)}catch{}}}return $(p,"v"),j(p,"transform"),{buildStart(){n=Object.create(null)},name:"packem:isolated-declarations",async renderStart(r,{input:o}){const m=ee(...Array.isArray(o)?o:Object.values(o));e.logger.debug({message:`Input base:${m}`,prefix:"packem:isolated-declarations"}),typeof r.entryFileNames=="function"&&(r.entryFileNames=r.entryFileNames({name:r.name}));const y=r.entryFileNames.replace(/\.(.)?[jt]sx?$/,(d,b)=>`.d.${b||""}ts`);for await(let[d,{ext:b,map:x,source:i}]of Object.entries(n)){let s;if(L(d)){if(!d.startsWith(t)){e.logger.debug({message:`Skipping file outside sourceDirectory: ${d}`,prefix:"packem:isolated-declarations"});continue}s=R(t,d)}else s=d.replace(`${t}/`,"");if(s.startsWith("/")&&(s=s.slice(1)),e.options.rollup.cjsInterop&&r.format==="cjs"){const g=q(i,{fileName:s,imports:[]},{warn:this.warn});g&&(i=g.code)}const a=i.includes("from '")?"'":'"',f=s+b;if((e.options.declaration===!0||e.options.declaration==="compatible")&&r.format==="cjs"){e.logger.debug({message:`Emit compatible dts file: ${s}`,prefix:"packem:isolated-declarations"});const g=y.replace("[name]",w(s)).replace(".cts",".ts");let v=i;e.options.sourcemap&&x&&(v=K(v.trim(),g),this.emitFile({fileName:`${g}.map`,originalFileName:f,source:I(x,f,k(r.dir,g)),type:"asset"})),this.emitFile({fileName:g,originalFileName:f,source:v.replaceAll(/(from\s)['|"]((.*)\..+|['|"].*)['|"];?/g,(D,N,M,T)=>`${N+a+(T||M)}.d.ts${a};`),type:"asset"})}e.logger.debug({message:`Emit dts file: ${s}`,prefix:"packem:isolated-declarations"});const h=y.replace("[name]",w(s));e.options.sourcemap&&x&&(i=K(i.trim(),h),this.emitFile({fileName:`${h}.map`,originalFileName:f,source:I(x,f,k(r.dir,h)),type:"asset"}));const W=C(e,r.format==="cjs"?"cjs":"esm");this.emitFile({fileName:h,originalFileName:f,source:i.replaceAll(/(from\s)['|"]((.*)\..+|['|"].*)['|"];?/g,(g,v,D,N)=>`${v+a+(N||D)}.${W}${a};`),type:"asset"})}},transform:p}},"isolatedDeclarationsPlugin");export{pe as isolatedDeclarationsPlugin};
@@ -2,7 +2,7 @@ import { FilterPattern } from '@rollup/pluginutils';
2
2
  import { ResolvedId, Plugin } from 'rollup';
3
3
 
4
4
  type Awaitable<T> = T | Promise<T>;
5
- type TransformFunction = (id: string, importer: string, rollupResolve: ((id: string, importer?: string) => Promise<ResolvedId | null>)) => Awaitable<boolean | undefined | void>;
5
+ type TransformFunction = (id: string, importer: string, rollupResolve: (id: string, importer?: string) => Promise<ResolvedId | null>) => Awaitable<boolean | undefined | void>;
6
6
  interface Options {
7
7
  builtinNodeModules?: boolean;
8
8
  cwd?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/packem-rollup",
3
- "version": "1.0.0-alpha.25",
3
+ "version": "1.0.0-alpha.26",
4
4
  "description": "Rollup plugins for packem",
5
5
  "keywords": [
6
6
  "visulima",