@visulima/packem-rollup 1.0.0-alpha.26 → 1.0.0-alpha.27
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 +7 -0
- package/dist/plugins/isolated-declarations/index.d.ts +0 -1
- package/dist/plugins/isolated-declarations/index.js +2 -2
- package/dist/plugins/json.js +1 -1
- package/dist/plugins/jsx-remove-attributes.js +1 -1
- package/dist/plugins/native-modules-plugin.js +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## @visulima/packem-rollup [1.0.0-alpha.27](https://github.com/visulima/packem/compare/@visulima/packem-rollup@1.0.0-alpha.26...@visulima/packem-rollup@1.0.0-alpha.27) (2025-11-11)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* improve isolated declarations plugin and update filtering logic ([7efdf0d](https://github.com/visulima/packem/commit/7efdf0d052805a3d46cf767447728ca3d537fc24))
|
|
6
|
+
* update license files and improve plugin configurations ([6372411](https://github.com/visulima/packem/commit/6372411fefbad9cb67d912c1447994b93a9ebc6f))
|
|
7
|
+
|
|
1
8
|
## @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
9
|
|
|
3
10
|
### Features
|
|
@@ -5,7 +5,6 @@ import { Plugin } from 'rollup';
|
|
|
5
5
|
type IsolatedDeclarationsOptions = {
|
|
6
6
|
exclude?: FilterPattern;
|
|
7
7
|
ignoreErrors?: boolean;
|
|
8
|
-
include?: FilterPattern;
|
|
9
8
|
};
|
|
10
9
|
declare const isolatedDeclarationsPlugin: <T extends Record<string, any>>(sourceDirectory: string, context: BuildContext<T>) => Plugin;
|
|
11
10
|
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
1
|
+
var U=Object.defineProperty;var x=(t,e)=>U(t,"name",{value:e,configurable:!0});import{createFilter as X}from"@rollup/pluginutils";import{readFile as W}from"@visulima/fs";import{EXCLUDE_REGEXP as _,ENDING_REGEX as E}from"@visulima/packem-share/constants";import{getDtsExtension as L}from"@visulima/packem-share/utils";import{dirname as S,toNamespacedPath as D,sep as A,extname as J,isAbsolute as q,relative as C,join as k,basename as O}from"@visulima/path";import{parseAsync as z}from"oxc-parser";import{_ as B}from"../../packem_shared/fix-dts-default-cjs-exports-BQc0nwIG.js";var H=Object.defineProperty,Q=x((t,e)=>H(t,"name",{value:e,configurable:!0}),"e");const P=/^([\w-]+):/,K=Q(t=>{if(!t||typeof t!="string")throw new Error("Invalid key: Key must be a non-empty string.");const e=[],c=P.exec(t);c&&(e.push(c[1]),t=t.replace(P,""));const n=t.split("/");for(const p of n)(p.includes("*")||p)&&e.push(p);return e},"splitTsconfigPathKey");var V=Object.defineProperty,Y=x((t,e)=>V(t,"name",{value:e,configurable:!0}),"h");const Z=Y((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 p=K(t),d=K(e);let l=p.length-1,r=d.length-1;for(;l>=0&&r>=0&&p[l]===d[r];)l--,r--;let a=p.slice(0,l).join("/");const f=d.slice(r).join("/");return(!a.startsWith(".")||a==="")&&(a=`./${a}`),a+(f?`/${f}`:"")},"extendString");var ee=Object.defineProperty,te=x((t,e)=>ee(t,"name",{value:e,configurable:!0}),"s");const re=te((...t)=>{if(t.length===0)return"";if(t.length===1)return S(t[0]);t=t.map(p=>D(p).split(A).join("/"));const[e,...c]=t;let n=e.split("/");for(const p of c){const d=p.split("/",n.length);let l=0;for(const r of d)if(r===n[l])l+=1;else{n=n.slice(0,l);break}n=n.slice(0,l)}return(n.length<=1&&n[0]===""?`/${n[0]}`:n.join("/")).split("/").join(A)},"lowestCommonAncestor");var ie=Object.defineProperty,j=x((t,e)=>ie(t,"name",{value:e,configurable:!0}),"g");const I=j((t,e)=>`${t}
|
|
2
2
|
//# sourceMappingURL=${O(e)}.map
|
|
3
|
-
`,"appendMapUrl"),
|
|
3
|
+
`,"appendMapUrl"),R=j((t,e,c)=>JSON.stringify({file:O(c),mappings:t,names:[],sourceRoot:"",sources:[C(S(c),e)],version:3}),"generateDtsMap"),fe=j((t,e)=>{const c=X(/\.(?:[mc]?ts|[jt]sx?)$/,e.options.rollup.isolatedDeclarations?.exclude||_);let n=Object.create(null);const p=j((r,a)=>{n[r.replace(E,"")]={...a,ext:J(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 l(r,a){if(!c(a))return;e.logger.debug({message:`Processing file: ${a}`,prefix:"packem:isolated-declarations"});let f;try{f=(await z(a,r)).program}catch(s){e.logger.debug({message:s.message,prefix:"packem:isolated-declarations"})}if(f){const s=f.body.filter(i=>(i.type==="ImportDeclaration"||i.type==="ExportAllDeclaration"||i.type==="ExportNamedDeclaration")&&i.source);for await(const i of s){if(O(i.source.value).includes("."))continue;const o=await this.resolve(i.source.value,a);if(!(!o||o.external)&&(o.id.endsWith(".ts")||o.id.endsWith(".cts")||o.id.endsWith(".mts")||o.id.endsWith(".tsx")||o.id.endsWith(".ctsx")||o.id.endsWith(".mtsx"))){const g=o.id.replace(`${t}/`,"");let u=i.source.value;d.some($=>$.test(i.source.value))&&!i.source.value.startsWith(".")&&(u=`./${i.source.value}`),r=r.replaceAll(`from "${i.source.value}"`,`from "${Z(u,g)}"`)}}}const{errors:b,map:w,sourceText:m}=await e.options.isolatedDeclarationTransformer(a,r,e.options.sourcemap,e.tsconfig?.config?.compilerOptions);if(b.length>0){if(e.options.rollup.isolatedDeclarations.ignoreErrors){this.warn(b[0]);return}return this.error(b[0])}if(p(a,{map:w,source:m}),!f)return;const h=f.body.filter(s=>!("source"in s)||!s.source?!1:"importKind"in s&&s.importKind==="type"||"exportKind"in s&&s.exportKind==="type"?!0:s.type==="ImportDeclaration"?s.specifiers&&s.specifiers.every(i=>i.type==="ImportSpecifier"&&i.importKind==="type"):s.type==="ExportNamedDeclaration"&&s.specifiers&&s.specifiers.every(i=>i.exportKind==="type"));for await(const s of h){if(!s.source)continue;const i=await this.resolve(s.source.value,a);if(!i)return;const o=i.id;if(c(o)&&!n[o.replace(E,"")])try{const g=await W(o);await l.call(this,g,o)}catch{}}}return x(l,"N"),j(l,"transform"),{buildStart(){n=Object.create(null)},name:"packem:isolated-declarations",async renderStart(r,{input:a}){const f=re(...Array.isArray(a)?a:Object.values(a));e.logger.debug({message:`Input base:${f}`,prefix:"packem:isolated-declarations"});const b=Array.isArray(a)?a:Object.values(a);for await(const m of b)if(c(m)&&!n[m.replace(E,"")])try{const h=await W(m);await l.call(this,h,m)}catch{}typeof r.entryFileNames=="function"&&(r.entryFileNames=r.entryFileNames({name:r.name}));const w=r.entryFileNames.replace(/\.(.)?[jt]sx?$/,(m,h)=>`.d.${h||""}ts`);for await(let[m,{ext:h,map:s,source:i}]of Object.entries(n)){let o;if(q(m)){if(!m.startsWith(t)){e.logger.debug({message:`Skipping file outside sourceDirectory: ${m}`,prefix:"packem:isolated-declarations"});continue}o=C(t,m)}else o=m.replace(`${t}/`,"");if(o.startsWith("/")&&(o=o.slice(1)),e.options.rollup.cjsInterop&&r.format==="cjs"){const y=B(i,{fileName:o,imports:[]},{warn:this.warn});y&&(i=y.code)}const g=i.includes("from '")?"'":'"',u=o+h;if((e.options.declaration===!0||e.options.declaration==="compatible")&&r.format==="cjs"){e.logger.debug({message:`Emit compatible dts file: ${o}`,prefix:"packem:isolated-declarations"});const y=w.replace("[name]",D(o)).replace(".cts",".ts");let v=i;e.options.sourcemap&&s&&(v=I(v.trim(),y),this.emitFile({fileName:`${y}.map`,originalFileName:u,source:R(s,u,k(r.dir,y)),type:"asset"})),this.emitFile({fileName:y,originalFileName:u,source:v.replaceAll(/(from\s)['|"]((.*)\..+|['|"].*)['|"];?/g,(F,N,M,T)=>`${N+g+(T||M)}.d.ts${g};`),type:"asset"})}e.logger.debug({message:`Emit dts file: ${o}`,prefix:"packem:isolated-declarations"});const $=w.replace("[name]",D(o));e.options.sourcemap&&s&&(i=I(i.trim(),$),this.emitFile({fileName:`${$}.map`,originalFileName:u,source:R(s,u,k(r.dir,$)),type:"asset"}));const G=L(e,r.format==="cjs"?"cjs":"esm");this.emitFile({fileName:$,originalFileName:u,source:i.replaceAll(/(from\s)['|"]((.*)\..+|['|"].*)['|"];?/g,(y,v,F,N)=>`${v+g+(N||F)}.${G}${g};`),type:"asset"})}},transform:l}},"isolatedDeclarationsPlugin");export{fe as isolatedDeclarationsPlugin};
|
package/dist/plugins/json.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var c=Object.defineProperty;var t=(r
|
|
1
|
+
var c=Object.defineProperty;var t=(o,r)=>c(o,"name",{value:r,configurable:!0});import i from"@rollup/plugin-json";var l=Object.defineProperty,d=t((o,r)=>l(o,"name",{value:r,configurable:!0}),"t");const n="export default ",m=d(o=>{const r=i(o);return{...r,name:"packem:json",transform:{filter:{id:/\.json$/},handler(s,a){const e=r.transform?.call(this,s,a);return e&&typeof e!="string"&&"code"in e&&e.code?.startsWith(n)&&(e.code=e.code.replace(n,"module.exports = ")),e}}}},"JsonPlugin");export{m as JsonPlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var c=Object.defineProperty;var p=(e,a)=>c(e,"name",{value:a,configurable:!0});import{w as y}from"../packem_shared/index-Dq8IUFTs.js";import f from"magic-string";var b=Object.defineProperty,v=p((e,a)=>b(e,"name",{value:a,configurable:!0}),"l");const g=v(({attributes:e,logger:a})=>{if(!Array.isArray(e)||e.length===0)throw new Error("[packem:jsx-remove-attributes]: attributes must be a non-empty array of strings.");return{name:"packem:jsx-remove-attributes",transform:{filter:{id:/\.[tj]sx$/},async handler(i,u){let n;try{n=this.parse(i,{allowReturnOutsideFunction:!0})}catch(r){this.warn({code:"PARSE_ERROR",message:`[packem:jsx-remove-attributes]: failed to parse "${u}" and remove the jsx attribute.`}),a.warn(r);return}let l=!1;const o=new f(i);if(y(n,{enter(r){if(r.type==="CallExpression"&&r.callee.type==="Identifier"&&r.callee.name==="jsx"){const m=r.arguments.filter(s=>s.type==="ObjectExpression"&&Array.isArray(s.properties));for(const s of m)for(const t of s.properties)t.type==="Property"&&t.key.type==="Literal"&&t.value.type==="Literal"&&e.includes(t.key.value)&&(o.overwrite(t.start-2,t.end,""),l=!0)}}}),!!l)return{code:o.toString(),map:o.generateMap({hires:!0})}}}}},"jsxRemoveAttributes");export{g as jsxRemoveAttributes};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var h=Object.defineProperty;var m=(s,o)=>h(s,"name",{value:o,configurable:!0});import{copyFile as w}from"node:fs/promises";import{isAccessible as A,ensureDir as P}from"@visulima/fs";import{resolve as v,dirname as c,basename as f,extname as b,join as g}from"@visulima/path";var x=Object.defineProperty,y=m((s,o)=>x(s,"name",{value:o,configurable:!0}),"c");const d="\0natives:",B=y((s={})=>{const{nativesDirectory:o="natives"}=s,a=new Map;let n;return{buildStart(){a.clear()},generateBundle:y(async r=>{if(!n){const e=Array.isArray(r)?r[0]:r;e&&e.dir?n=e.dir:e&&e.file&&(n=c(e.file))}if(a.size===0)return;if(!n){(void 0).error("Output directory not detected. Please ensure Rollup output options are configured.");return}const t=g(n,o);await P(t),await Promise.all([...a.entries()].map(([e,i])=>{const u=g(t,i);return w(e,u)}))},"generateBundle"),load(r){if(!r.startsWith(d))return;const t=r.slice(d.length),e=a.get(t);if(e||this.error(`Could not find staged native module for: ${t}`),!n){const i=this;if(i&&i.meta&&i.meta.rollupVersion)return`export default require("./${o}/${e}");`;this.error("Output directory not detected. Please ensure Rollup output options are configured.")}return`export default require("${`./${o}/${e}`.replaceAll("\\","/")}");`},name:"native-modules",options(r){const t=r;if(t.output){const e=Array.isArray(t.output)?t.output[0]:t.output;e.dir?n=e.dir:e.file&&(n=c(e.file))}return r},resolveId:{filter:{id:/\.node$/},async handler(r,t){if(r.startsWith(d))return;const e=t?v(c(t),r):v(r);if(!await A(e)){this.warn(`Native module not found: ${e}`);return}const i=f(e);let u=i,p=1;const $=new Set([...a.values()].map(l=>f(l)));for(;$.has(u);){const l=b(i);u=`${f(i,l)}_${p}${l}`,p+=1}return a.set(e,u),d+e}}}},"nativeModulesPlugin");export{B as nativeModulesPlugin};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/packem-rollup",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.27",
|
|
4
4
|
"description": "Rollup plugins for packem",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"visulima",
|
|
@@ -139,7 +139,7 @@
|
|
|
139
139
|
"dependencies": {
|
|
140
140
|
"@babel/parser": "7.28.4",
|
|
141
141
|
"@rollup/plugin-alias": "5.1.1",
|
|
142
|
-
"@rollup/plugin-commonjs": "
|
|
142
|
+
"@rollup/plugin-commonjs": "29.0.0",
|
|
143
143
|
"@rollup/plugin-dynamic-import-vars": "2.1.5",
|
|
144
144
|
"@rollup/plugin-inject": "5.0.5",
|
|
145
145
|
"@rollup/plugin-json": "6.1.0",
|
|
@@ -153,10 +153,10 @@
|
|
|
153
153
|
"@visulima/packem-share": "1.0.0-alpha.13",
|
|
154
154
|
"@visulima/path": "1.4.0",
|
|
155
155
|
"@visulima/source-map": "1.0.20",
|
|
156
|
-
"cjs-module-lexer": "^2.1.
|
|
156
|
+
"cjs-module-lexer": "^2.1.1",
|
|
157
157
|
"clean-css": "^5.3.3",
|
|
158
158
|
"glob-parent": "6.0.2",
|
|
159
|
-
"html-minifier-next": "^
|
|
159
|
+
"html-minifier-next": "^4.1.0",
|
|
160
160
|
"magic-string": "0.30.19",
|
|
161
161
|
"mlly": "1.8.0",
|
|
162
162
|
"oxc-parser": "0.93.0",
|