@visulima/packem-rollup 1.0.0-alpha.73 → 1.0.0-alpha.74
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 +11 -0
- package/dist/plugins/chunk-splitter/index.js +1 -1
- package/dist/plugins/jsx-remove-attributes.d.ts +9 -9
- package/dist/plugins/preserve-directives.d.ts +1 -1
- package/dist/plugins/preserve-directives.js +4 -4
- package/dist/plugins/pure-new-expression-plugin.d.ts +9 -9
- package/dist/plugins/pure-new-expression-plugin.js +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
## @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)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
* **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))
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Dependencies
|
|
9
|
+
|
|
10
|
+
* **@visulima/rollup-plugin-dts:** upgraded to 1.0.0-alpha.35
|
|
11
|
+
|
|
1
12
|
## @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
13
|
|
|
3
14
|
### 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
|
|
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
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
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 };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var M=Object.defineProperty;var k=(
|
|
2
|
-
`,"\r","\u2028","\u2029"]),x=/"([^"]*)"|'([^']*)'/,
|
|
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(
|
|
5
|
-
`)),!(
|
|
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 `/*
|
|
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
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
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}),"
|
|
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.
|
|
3
|
+
"version": "1.0.0-alpha.74",
|
|
4
4
|
"description": "Rollup plugins for packem",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"visulima",
|
|
@@ -96,7 +96,7 @@
|
|
|
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.
|
|
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",
|