@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
|
|
2
|
-
//# sourceMappingURL=${
|
|
3
|
-
`,"appendMapUrl"),
|
|
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: (
|
|
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;
|