@visulima/packem-rollup 1.0.0-alpha.73 → 1.0.0-alpha.75

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,16 @@
1
+ ## @visulima/packem-rollup [1.0.0-alpha.75](https://github.com/visulima/packem/compare/@visulima/packem-rollup@1.0.0-alpha.74...@visulima/packem-rollup@1.0.0-alpha.75) (2026-06-20)
2
+
3
+ ## @visulima/packem-rollup [1.0.0-alpha.74](https://github.com/visulima/packem/compare/@visulima/packem-rollup@1.0.0-alpha.73...@visulima/packem-rollup@1.0.0-alpha.74) (2026-06-16)
4
+
5
+ ### Features
6
+
7
+ * **packem:** route DTS through rolldown natively when rolldown is the bundler ([#208](https://github.com/visulima/packem/issues/208)) ([2802f4d](https://github.com/visulima/packem/commit/2802f4d72f6c4f2d1a74e51388b4771fb33fa3e6))
8
+
9
+
10
+ ### Dependencies
11
+
12
+ * **@visulima/rollup-plugin-dts:** upgraded to 1.0.0-alpha.35
13
+
1
14
  ## @visulima/packem-rollup [1.0.0-alpha.73](https://github.com/visulima/packem/compare/@visulima/packem-rollup@1.0.0-alpha.72...@visulima/packem-rollup@1.0.0-alpha.73) (2026-06-12)
2
15
 
3
16
  ### Features
@@ -1 +1 @@
1
- var x=Object.defineProperty;var d=(t,e)=>x(t,"name",{value:e,configurable:!0});import c from"node:assert/strict";import{extractAssignedNames as y}from"@rollup/pluginutils";var h=Object.defineProperty,n=d((t,e)=>h(t,"name",{value:e,configurable:!0}),"t");const v=n(function*(t){switch(t.declaration?.type){case"ClassDeclaration":case"FunctionDeclaration":{const{id:e}=t.declaration;c.ok(e,"Expected class/function to have a name"),yield e.name;break}case"VariableDeclaration":{for(const e of t.declaration.declarations)for(const a of y(e.id))yield a;break}}},"exportName"),N=n(function*(t){if(t.declaration)for(const e of v(t))yield{exportedName:e,from:"self",type:"named"};else if(t.source)yield{bindings:t.specifiers.map(e=>({exportedName:e.exported.name,importedName:e.local.name})),from:"other",source:t.source.value,type:"named"};else for(const e of t.specifiers)yield{exportedName:e.exported.name,from:"self",type:"named"}},"parseExportNamed"),g=n(function*(t){t.exported?yield{exportedName:t.exported.name,from:"self",type:"named"}:yield{from:"other",source:t.source.value,type:"barrel"}},"parseExportAll"),b=n(function*(){yield{exportedName:"default",from:"self",type:"named"}},"parseExportDefault"),E=n(t=>/\.tsx$/.test(t)?"tsx":/\.[cm]?ts$/.test(t)?"ts":/\.jsx$/.test(t)?"jsx":"js","langForId"),f=n(function(t,e){c.ok(e.code!==null,`Module ${e.id} doesn't have associated code`);let a;try{a=t.parse(e.code,{lang:E(e.id)})}catch{return[]}const r=[];for(const o of a.body)switch(o.type){case"ExportAllDeclaration":{r.push(...g(o));break}case"ExportDefaultDeclaration":{r.push(...b());break}case"ExportNamedDeclaration":{r.push(...N(o));break}}return r},"collectExports"),k=n(function(t,e,a){if(!a)return f(t,e);const r=a.get(e.id);if(r!==void 0)return r;const o=f(t,e);return a.set(e.id,o),o},"parseExports");var $=Object.defineProperty,i=d((t,e)=>$(t,"name",{value:e,configurable:!0}),"i");const m=i(async function(t,e,a){const r=await t.resolve(e,a.id);if(c.ok(r,`Rollup can't resolve ${e} from ${a.id}`),r.external)return;const o=await t.load(r);return c.ok(o,`Rollup doesn't have a module for id ${r.id}`),o},"getImportedModule"),w=i(async function*(t,e,a,r){const o=await m(t,e.source,a);o&&(yield*l(t,o,r))},"gatherBarrelReExports"),D=i(async function*(t,e,a,r){const o=await m(t,e.source,a);if(!o)return;const u=new Map(e.bindings.map(s=>[s.importedName,s]));for await(const s of l(t,o,r)){const p=u.get(s.exportedName);p&&(yield{...s,exportedName:p.exportedName})}},"gatherNamedReExports"),j=i(function*(t,e){yield{exportedName:e.exportedName,id:t.id,sourceName:e.exportedName}},"gatherNamedSelfExports"),l=i(async function*(t,e,a){if(!a.visited.has(e.id)){a.visited.add(e.id);try{for(const r of k(t,e,a.parseCache))r.from==="self"?yield*j(e,r):r.type==="barrel"?yield*w(t,r,e,a):yield*D(t,r,e,a)}finally{a.visited.delete(e.id)}}},"gatherExportsWithState"),S=i(function(t,e){return l(t,e,{parseCache:new Map,visited:new Set})},"gatherExports");var M=Object.defineProperty,P=d((t,e)=>M(t,"name",{value:e,configurable:!0}),"r");const F=P(()=>({moduleParsed:{async handler(t){if(t.isEntry)for await(const e of S(this,t))e.id!==t.id&&this.emitFile({id:e.id,name:e.exportedName,preserveSignature:"exports-only",type:"chunk"})},order:"post"},name:"packem:chunk-splitter"}),"chunkSplitter");export{F as default};
1
+ var x=Object.defineProperty;var d=(t,e)=>x(t,"name",{value:e,configurable:!0});import c from"node:assert/strict";import{extractAssignedNames as y}from"@rollup/pluginutils";var h=Object.defineProperty,n=d((t,e)=>h(t,"name",{value:e,configurable:!0}),"t");const v=n(function*(t){switch(t.declaration?.type){case"ClassDeclaration":case"FunctionDeclaration":{const{id:e}=t.declaration;c.ok(e,"Expected class/function to have a name"),yield e.name;break}case"VariableDeclaration":{for(const e of t.declaration.declarations)for(const a of y(e.id))yield a;break}}},"exportName"),N=n(function*(t){if(t.declaration)for(const e of v(t))yield{exportedName:e,from:"self",type:"named"};else if(t.source)yield{bindings:t.specifiers.map(e=>({exportedName:e.exported.name,importedName:e.local.name})),from:"other",source:t.source.value,type:"named"};else for(const e of t.specifiers)yield{exportedName:e.exported.name,from:"self",type:"named"}},"parseExportNamed"),g=n(function*(t){t.exported?yield{exportedName:t.exported.name,from:"self",type:"named"}:yield{from:"other",source:t.source.value,type:"barrel"}},"parseExportAll"),b=n(function*(){yield{exportedName:"default",from:"self",type:"named"}},"parseExportDefault"),E=/\.tsx$/,k=/\.[cm]?ts$/,$=/\.jsx$/,w=n(t=>E.test(t)?"tsx":k.test(t)?"ts":$.test(t)?"jsx":"js","langForId"),f=n(function(t,e){c.ok(e.code!==null,`Module ${e.id} doesn't have associated code`);let a;try{a=t.parse(e.code,{lang:w(e.id)})}catch{return[]}const r=[];for(const o of a.body)switch(o.type){case"ExportAllDeclaration":{r.push(...g(o));break}case"ExportDefaultDeclaration":{r.push(...b());break}case"ExportNamedDeclaration":{r.push(...N(o));break}}return r},"collectExports"),D=n(function(t,e,a){if(!a)return f(t,e);const r=a.get(e.id);if(r!==void 0)return r;const o=f(t,e);return a.set(e.id,o),o},"parseExports");var j=Object.defineProperty,i=d((t,e)=>j(t,"name",{value:e,configurable:!0}),"i");const m=i(async function(t,e,a){const r=await t.resolve(e,a.id);if(c.ok(r,`Rollup can't resolve ${e} from ${a.id}`),r.external)return;const o=await t.load(r);return c.ok(o,`Rollup doesn't have a module for id ${r.id}`),o},"getImportedModule"),S=i(async function*(t,e,a,r){const o=await m(t,e.source,a);o&&(yield*l(t,o,r))},"gatherBarrelReExports"),M=i(async function*(t,e,a,r){const o=await m(t,e.source,a);if(!o)return;const u=new Map(e.bindings.map(s=>[s.importedName,s]));for await(const s of l(t,o,r)){const p=u.get(s.exportedName);p&&(yield{...s,exportedName:p.exportedName})}},"gatherNamedReExports"),P=i(function*(t,e){yield{exportedName:e.exportedName,id:t.id,sourceName:e.exportedName}},"gatherNamedSelfExports"),l=i(async function*(t,e,a){if(!a.visited.has(e.id)){a.visited.add(e.id);try{for(const r of D(t,e,a.parseCache))r.from==="self"?yield*P(e,r):r.type==="barrel"?yield*S(t,r,e,a):yield*M(t,r,e,a)}finally{a.visited.delete(e.id)}}},"gatherExportsWithState"),R=i(function(t,e){return l(t,e,{parseCache:new Map,visited:new Set})},"gatherExports");var A=Object.defineProperty,C=d((t,e)=>A(t,"name",{value:e,configurable:!0}),"r");const B=C(()=>({moduleParsed:{async handler(t){if(t.isEntry)for await(const e of R(this,t))e.id!==t.id&&this.emitFile({id:e.id,name:e.exportedName,preserveSignature:"exports-only",type:"chunk"})},order:"post"},name:"packem:chunk-splitter"}),"chunkSplitter");export{B as default};
@@ -5,14 +5,14 @@ type JSXRemoveAttributesPlugin = {
5
5
  /**
6
6
  * Remove JSX attributes (e.g. `data-testid`) from automatic-runtime JSX calls.
7
7
  *
8
- * Two modes, because the bundlers run their JSX transform at different times:
9
- * - `"transform"` (rollup): packem's transformer adapter runs as an earlier
10
- * transform plugin, so by the time this transform hook runs the per-module
11
- * source already contains `jsx(...)` calls and `this.parse` sees plain JS.
12
- * - `"renderChunk"` (rolldown): rolldown's native oxc transform runs AFTER
13
- * plugin transform hooks, so a transform hook would see raw JSX and
14
- * `this.parse` would throw. The emitted chunk, however, is fully transpiled —
15
- * so the same AST walk runs there instead.
8
+ * Two modes, because the bundlers run their JSX transform at different times.
9
+ * `"transform"` (rollup): packem's transformer adapter runs as an earlier
10
+ * transform plugin, so by the time this transform hook runs the per-module
11
+ * source already contains `jsx(...)` calls and `this.parse` sees plain JS.
12
+ * `"renderChunk"` (rolldown): rolldown's native oxc transform runs AFTER
13
+ * plugin transform hooks, so a transform hook would see raw JSX and
14
+ * `this.parse` would throw. The emitted chunk, however, is fully transpiled —
15
+ * so the same AST walk runs there instead.
16
16
  */
17
17
  declare const jsxRemoveAttributes: ({
18
18
  attributes,
@@ -24,4 +24,4 @@ declare const jsxRemoveAttributes: ({
24
24
  mode?: "renderChunk" | "transform";
25
25
  sourcemap?: boolean;
26
26
  }) => Plugin;
27
- export { JSXRemoveAttributesPlugin, jsxRemoveAttributes };
27
+ export { type JSXRemoveAttributesPlugin, jsxRemoveAttributes };
@@ -12,4 +12,4 @@ declare const preserveDirectivesPlugin: ({
12
12
  include,
13
13
  logger
14
14
  }: PreserveDirectivesPluginOptions) => Plugin;
15
- export { PreserveDirectivesPluginOptions, preserveDirectivesPlugin };
15
+ export { type PreserveDirectivesPluginOptions, preserveDirectivesPlugin };
@@ -1,5 +1,5 @@
1
- var M=Object.defineProperty;var k=(t,l)=>M(t,"name",{value:l,configurable:!0});import{createFilter as $}from"@rollup/pluginutils";import b from"magic-string";var D=Object.defineProperty,h=k((t,l)=>D(t,"name",{value:l,configurable:!0}),"m");const S=new Set([" "," ","\f","\v"," ","\uFEFF"]),m=new Set([`
2
- `,"\r","\u2028","\u2029"]),x=/"([^"]*)"|'([^']*)'/,I=h(t=>{const l=[],{length:v}=t;let e=0;const g=h(a=>{for(;e<v;){const f=t[e];if(S.has(f))e+=1;else if(m.has(f)){if(!a)return;e+=1}else if(f==="/"&&t[e+1]==="/")for(e+=2;e<v&&!m.has(t[e]);)e+=1;else if(f==="/"&&t[e+1]==="*"){for(e+=2;e<v&&!(t[e]==="*"&&t[e+1]==="/");)e+=1;e+=2}else return}},"skipTrivia");for(;e<v&&(g(!0),!(e>=v));){const a=t[e];if(a!=='"'&&a!=="'")break;const f=e;e+=1;let s=!1;for(;e<v;){const u=t[e];if(u==="\\"){e+=2;continue}if(u===a){e+=1,s=!0;break}if(m.has(u))break;e+=1}if(!s)break;const i=e,c=t.slice(f+1,i-1);g(!1);const o=t[e];if(o===";"){e+=1,l.push({end:e,start:f,value:c});continue}if(e>=v||m.has(o)||o==="}"){l.push({end:i,start:f,value:c});continue}break}return l},"scanLeadingDirectives"),y=h(({directiveRegex:t,exclude:l=[],include:v=[],logger:e})=>{const g={},a={},f=$(v,l);return{name:"packem:preserve-directives",onLog(s,i){if(i.code==="MODULE_LEVEL_DIRECTIVE"&&s==="warn"){const c=x.exec(i.message),o=c?.[1]??c?.[2];if(o!==void 0&&t.test(`"${o}"`))return!1}},renderChunk:{handler(s,i,{sourcemap:c}){const o=h(r=>{const n=this.getModuleInfo(r)?.meta?.preserveDirectives?.directives;return n&&n.length>0?new Set(n):g[r]},"directivesForId"),u=i.moduleIds.map(r=>o(r)).reduce((r,n)=>(n&&n.forEach(w=>{r.add(w)}),r),new Set),d=new b(s);for(const{value:r}of I(s))u.delete(r);u.size>0&&(e.debug({message:`directives for chunk "${i.fileName}" are preserved.`,prefix:"plugin:preserve-directives"}),d.prepend(`${Array.from(u,r=>`'${r.replace(/\\/g,"\\\\").replace(/'/g,"\\'")}';`).join(`
1
+ var M=Object.defineProperty;var k=(i,u)=>M(i,"name",{value:u,configurable:!0});import{createFilter as S}from"@rollup/pluginutils";import b from"magic-string";var $=Object.defineProperty,h=k((i,u)=>$(i,"name",{value:u,configurable:!0}),"m");const D=new Set([" "," ","\f","\v"," ","\uFEFF"]),m=new Set([`
2
+ `,"\r","\u2028","\u2029"]),x=/"([^"]*)"|'([^']*)'/,w=h(i=>{const u=[],{length:v}=i;let e=0;const g=h(a=>{for(;e<v;){const f=i[e];if(D.has(f))e+=1;else if(m.has(f)){if(!a)return;e+=1}else if(f==="/"&&i[e+1]==="/")for(e+=2;e<v&&!m.has(i[e]);)e+=1;else if(f==="/"&&i[e+1]==="*"){for(e+=2;e<v&&!(i[e]==="*"&&i[e+1]==="/");)e+=1;e+=2}else return}},"skipTrivia");for(;e<v&&(g(!0),!(e>=v));){const a=i[e];if(a!=='"'&&a!=="'")break;const f=e;e+=1;let n=!1;for(;e<v;){const l=i[e];if(l==="\\"){e+=2;continue}if(l===a){e+=1,n=!0;break}if(m.has(l))break;e+=1}if(!n)break;const t=e,c=i.slice(f+1,t-1);g(!1);const s=i[e];if(s===";"){e+=1,u.push({end:e,start:f,value:c});continue}if(e>=v||m.has(s)||s==="}"){u.push({end:t,start:f,value:c});continue}break}return u},"scanLeadingDirectives"),y=h(({directiveRegex:i,exclude:u=[],include:v=[],logger:e})=>{const g={},a={},f=S(v,u);return{name:"packem:preserve-directives",onLog(n,t){if(t.code==="MODULE_LEVEL_DIRECTIVE"&&n==="warn"){const c=x.exec(t.message),s=c?.[1]??c?.[2];if(s!==void 0&&i.test(`"${s}"`))return!1}},renderChunk:{handler(n,t,{sourcemap:c}){const s=h(r=>{const o=this.getModuleInfo(r)?.meta?.preserveDirectives?.directives;return o&&o.length>0?new Set(o):g[r]},"directivesForId"),l=t.moduleIds.map(r=>s(r)).reduce((r,o)=>(o&&o.forEach(I=>{r.add(I)}),r),new Set),d=new b(n);for(const{value:r}of w(n))l.delete(r);l.size>0&&(e.debug({message:`directives for chunk "${t.fileName}" are preserved.`,prefix:"plugin:preserve-directives"}),d.prepend(`${Array.from(l,r=>`'${r.replaceAll("\\",String.raw`\\`).replaceAll("'",String.raw`\'`)}';`).join(`
3
3
  `)}
4
- `));let p;if(i.facadeModuleId){const r=this.getModuleInfo(i.facadeModuleId)?.meta?.preserveDirectives?.shebang;typeof r=="string"?p=r:typeof a[i.facadeModuleId]=="string"&&(p=a[i.facadeModuleId])}if(p&&(e.debug({message:`shebang for chunk "${i.fileName}" is preserved.`,prefix:"plugin:preserve-directives"}),d.prepend(`${p}
5
- `)),!(u.size===0&&p===void 0))return{code:d.toString(),map:c?d.generateMap({hires:!0}):void 0}},order:"post"},transform(s,i){if(!f(i))return;delete g[i],delete a[i];let c=!1,o;if(s.startsWith("#")&&s[1]==="!"){let d=s.length;for(let p=s.length,r=2;r<p;r+=1){const n=s.codePointAt(r);if(n===10||n===13||n===8232||n===8233){d=r;break}}d>0&&(a[i]=s.slice(0,d),o=new b(s),o.remove(0,Math.min(d+1,s.length)),c=!0,e.debug({message:`shebang for module "${i}" is preserved.`,prefix:"plugin:preserve-directives"}))}const u=o===void 0?s:o.toString();for(const{end:d,start:p,value:r}of I(u)){if(r==="use strict"||!t.test(`"${r}"`))continue;const n=g[i];n?n.add(r):g[i]=new Set([r]),o??=new b(s),o.remove(p,d),c=!0,e.debug({message:`directive "${r}" for module "${i}" is preserved.`,prefix:"plugin:preserve-directives"})}if(!(!c||o===void 0))return{code:o.toString(),map:o.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...g[i]??[]],shebang:a[i]??void 0}}}}}},"preserveDirectivesPlugin");export{y as preserveDirectivesPlugin};
4
+ `));let p;if(t.facadeModuleId){const r=this.getModuleInfo(t.facadeModuleId)?.meta?.preserveDirectives?.shebang;typeof r=="string"?p=r:typeof a[t.facadeModuleId]=="string"&&(p=a[t.facadeModuleId])}if(p&&(e.debug({message:`shebang for chunk "${t.fileName}" is preserved.`,prefix:"plugin:preserve-directives"}),d.prepend(`${p}
5
+ `)),!(l.size===0&&p===void 0))return{code:d.toString(),map:c?d.generateMap({hires:!0}):void 0}},order:"post"},transform(n,t){if(!f(t))return;delete g[t],delete a[t];let c=!1,s;if(n.startsWith("#")&&n[1]==="!"){let d=n.length;for(let p=n.length,r=2;r<p;r+=1){const o=n.codePointAt(r);if(o===10||o===13||o===8232||o===8233){d=r;break}}d>0&&(a[t]=n.slice(0,d),s=new b(n),s.remove(0,Math.min(d+1,n.length)),c=!0,e.debug({message:`shebang for module "${t}" is preserved.`,prefix:"plugin:preserve-directives"}))}const l=s===void 0?n:s.toString();for(const{end:d,start:p,value:r}of w(l)){if(r==="use strict"||!i.test(`"${r}"`))continue;const o=g[t];o?o.add(r):g[t]=new Set([r]),s??=new b(n),s.remove(p,d),c=!0,e.debug({message:`directive "${r}" for module "${t}" is preserved.`,prefix:"plugin:preserve-directives"})}if(!(!c||s===void 0))return{code:s.toString(),map:s.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...g[t]??[]],shebang:a[t]??void 0}}}}}},"preserveDirectivesPlugin");export{y as preserveDirectivesPlugin};
@@ -1,16 +1,16 @@
1
1
  import { Plugin } from 'rollup';
2
2
  /**
3
- * A plugin that adds `/* @__PURE__ * /` annotations so consumers can tree-shake
3
+ * A plugin that adds `/* \@__PURE__ * /` annotations so consumers can tree-shake
4
4
  * unused calls/instantiations.
5
5
  *
6
- * Two modes, because rolldown and rollup expose pure-annotation timing differently:
7
- * - `"transform"` (rollup, default): annotates `new Constructor(...)`
8
- * (`NewExpression`) only — `rollup-plugin-pure` handles the `CallExpression`
9
- * side separately. Runs `order: "post"` so `this.parse` sees transpiled JS.
10
- * - `"renderChunk"` (rolldown): `rollup-plugin-pure` is transform-only and can't
11
- * run under rolldown (its native oxc transform runs after plugin transforms),
12
- * so this single renderChunk pass annotates BOTH `NewExpression` (constructors)
13
- * and `CallExpression` (functions) on the final transpiled chunk.
6
+ * Two modes, because rolldown and rollup expose pure-annotation timing differently.
7
+ * `"transform"` (rollup, default): annotates `new Constructor(...)`
8
+ * (`NewExpression`) only — `rollup-plugin-pure` handles the `CallExpression`
9
+ * side separately. Runs `order: "post"` so `this.parse` sees transpiled JS.
10
+ * `"renderChunk"` (rolldown): `rollup-plugin-pure` is transform-only and can't
11
+ * run under rolldown (its native oxc transform runs after plugin transforms),
12
+ * so this single renderChunk pass annotates BOTH `NewExpression` (constructors)
13
+ * and `CallExpression` (functions) on the final transpiled chunk.
14
14
  */
15
15
  declare const pureNewExpressionPlugin: (options: {
16
16
  constructors: string[];
@@ -1 +1 @@
1
- var b=Object.defineProperty;var x=(e,r)=>b(e,"name",{value:r,configurable:!0});import{w as E}from"../packem_shared/index-Dq8IUFTs.js";import _ from"magic-string";var R=Object.defineProperty,u=x((e,r)=>R(e,"name",{value:r,configurable:!0}),"a");const k=24,v=u(e=>{if(e){if(e.type==="Identifier")return e.name;if(e.type==="MemberExpression"&&!e.computed&&e.property?.type==="Identifier"){const r=v(e.object);return r===void 0?void 0:`${r}.${e.property.name}`}}},"calleeToName"),P=u((e,r)=>e.slice(Math.max(0,r-k),r).includes("__PURE__"),"isAlreadyPure"),I=u(e=>{const r=e.constructors.filter(t=>t.includes(".")),y=(e.functions??[]).filter(t=>t instanceof RegExp);(r.length>0||y.length>0)&&e.logger&&e.logger.warn({message:`ignoring unsupported entries — dotted constructor names (${r.join(", ")||"none"}) and ${String(y.length)} RegExp function/constructor matchers are not supported and were skipped.`,prefix:"plugin:pure-new-expression"});const a=new Set(e.constructors.filter(t=>!t.includes("."))),h=new Set((e.functions??[]).filter(t=>typeof t=="string")),S=u(t=>t.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`),"escapeForRegExp"),f=new Set(a);for(const t of h)f.add(t.split(".")[0]);const c=f.size>0?new RegExp(String.raw`\b(?:${[...f].map(t=>S(t)).join("|")})\b`):void 0;return e.mode==="renderChunk"?{name:"packem:pure-new-expression",renderChunk:{handler(t,d,{sourcemap:o}){if(c===void 0||!c.test(t))return;let i;try{i=this.parse(t)}catch{return}const p=new _(t);let s=!1;if(E(i,{enter(l,m){const n=l;if(typeof n.start!="number"||m?.type==="ExpressionStatement")return;let g=!1;if(n.type==="NewExpression"&&n.callee?.type==="Identifier"&&typeof n.callee.name=="string"&&a.has(n.callee.name))g=!0;else if(n.type==="CallExpression"){const w=v(n.callee);w!==void 0&&h.has(w)&&(g=!0)}g&&!P(t,n.start)&&(p.prependLeft(n.start,"/* @__PURE__ */ "),s=!0)}}),!!s)return{code:p.toString(),map:o?p.generateMap({hires:!0}):void 0}},order:"post"}}:{name:"packem:pure-new-expression",transform:{handler(t){if(a.size===0||c===void 0||!c.test(t))return;let d;try{d=this.parse(t)}catch{return}const o=new _(t);let i=!1;if(E(d,{enter(p){const s=p,l=s.callee?.name,m=s._rollupAnnotations;s.type==="NewExpression"&&s.callee?.type==="Identifier"&&typeof l=="string"&&a.has(l)&&!m?.some(n=>n.type==="pure")&&typeof s.start=="number"&&(o.prependLeft(s.start,"/* @__PURE__ */ "),i=!0)}}),!!i)return{code:o.toString(),map:e.sourcemap?o.generateMap({hires:!0}):void 0}},order:"post"}}},"pureNewExpressionPlugin");export{I as pureNewExpressionPlugin};
1
+ var b=Object.defineProperty;var x=(e,r)=>b(e,"name",{value:r,configurable:!0});import{w as E}from"../packem_shared/index-Dq8IUFTs.js";import _ from"magic-string";var R=Object.defineProperty,u=x((e,r)=>R(e,"name",{value:r,configurable:!0}),"p");const k=24,v=u(e=>{if(e){if(e.type==="Identifier")return e.name;if(e.type==="MemberExpression"&&!e.computed&&e.property?.type==="Identifier"){const r=v(e.object),o=e.property.name;return r===void 0||o===void 0?void 0:`${r}.${o}`}}},"calleeToName"),P=u((e,r)=>e.slice(Math.max(0,r-k),r).includes("__PURE__"),"isAlreadyPure"),I=u(e=>{const r=e.constructors.filter(t=>t.includes(".")),o=(e.functions??[]).filter(t=>t instanceof RegExp);(r.length>0||o.length>0)&&e.logger&&e.logger.warn({message:`ignoring unsupported entries — dotted constructor names (${r.join(", ")||"none"}) and ${String(o.length)} RegExp function/constructor matchers are not supported and were skipped.`,prefix:"plugin:pure-new-expression"});const l=new Set(e.constructors.filter(t=>!t.includes("."))),h=new Set((e.functions??[]).filter(t=>typeof t=="string")),S=u(t=>t.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`),"escapeForRegExp"),f=new Set(l);for(const t of h)f.add(t.split(".")[0]);const d=f.size>0?new RegExp(String.raw`\b(?:${[...f].map(t=>S(t)).join("|")})\b`):void 0;return e.mode==="renderChunk"?{name:"packem:pure-new-expression",renderChunk:{handler(t,m,{sourcemap:i}){if(!d?.test(t))return;let p;try{p=this.parse(t)}catch{return}const a=new _(t);let s=!1;if(E(p,{enter(c,g){const n=c;if(typeof n.start!="number"||g?.type==="ExpressionStatement")return;let y=!1;if(n.type==="NewExpression"&&n.callee?.type==="Identifier"&&typeof n.callee.name=="string"&&l.has(n.callee.name))y=!0;else if(n.type==="CallExpression"){const w=v(n.callee);w!==void 0&&h.has(w)&&(y=!0)}y&&!P(t,n.start)&&(a.prependLeft(n.start,"/* @__PURE__ */ "),s=!0)}}),!!s)return{code:a.toString(),map:i?a.generateMap({hires:!0}):void 0}},order:"post"}}:{name:"packem:pure-new-expression",transform:{handler(t){if(l.size===0||d===void 0||!d.test(t))return;let m;try{m=this.parse(t)}catch{return}const i=new _(t);let p=!1;if(E(m,{enter(a){const s=a,c=s.callee?.name,g=s._rollupAnnotations;s.type==="NewExpression"&&s.callee?.type==="Identifier"&&typeof c=="string"&&l.has(c)&&!g?.some(n=>n.type==="pure")&&typeof s.start=="number"&&(i.prependLeft(s.start,"/* @__PURE__ */ "),p=!0)}}),!!p)return{code:i.toString(),map:e.sourcemap?i.generateMap({hires:!0}):void 0}},order:"post"}}},"pureNewExpressionPlugin");export{I as pureNewExpressionPlugin};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/packem-rollup",
3
- "version": "1.0.0-alpha.73",
3
+ "version": "1.0.0-alpha.75",
4
4
  "description": "Rollup plugins for packem",
5
5
  "keywords": [
6
6
  "visulima",
@@ -90,13 +90,13 @@
90
90
  "@rollup/plugin-replace": "6.0.3",
91
91
  "@rollup/plugin-wasm": "6.2.2",
92
92
  "@rollup/pluginutils": "5.4.0",
93
- "@swc/types": "0.1.26",
93
+ "@swc/types": "0.1.27",
94
94
  "@visulima/find-cache-dir": "3.0.0-alpha.9",
95
95
  "@visulima/fs": "5.0.0-alpha.24",
96
96
  "@visulima/package": "5.0.0-alpha.23",
97
97
  "@visulima/packem-share": "1.0.0-alpha.50",
98
98
  "@visulima/path": "3.0.0-alpha.10",
99
- "@visulima/rollup-plugin-dts": "1.0.0-alpha.34",
99
+ "@visulima/rollup-plugin-dts": "1.0.0-alpha.35",
100
100
  "clean-css": "^5.3.3",
101
101
  "html-minifier-next": "6.2.7",
102
102
  "magic-string": "0.30.21",