@visulima/packem-rollup 1.0.0-alpha.63 → 1.0.0-alpha.65

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,23 @@
1
+ ## @visulima/packem-rollup [1.0.0-alpha.65](https://github.com/visulima/packem/compare/@visulima/packem-rollup@1.0.0-alpha.64...@visulima/packem-rollup@1.0.0-alpha.65) (2026-05-07)
2
+
3
+ ### Bug Fixes
4
+
5
+ * **packem-rollup:** deduplicate renamed require helpers ([4eee70c](https://github.com/visulima/packem/commit/4eee70c52a5d4dc8505df3e91de26650fb1a1885))
6
+
7
+
8
+ ### Dependencies
9
+
10
+ * **@visulima/packem-share:** upgraded to 1.0.0-alpha.46
11
+ * **@visulima/rollup-plugin-dts:** upgraded to 1.0.0-alpha.26
12
+
13
+ ## @visulima/packem-rollup [1.0.0-alpha.64](https://github.com/visulima/packem/compare/@visulima/packem-rollup@1.0.0-alpha.63...@visulima/packem-rollup@1.0.0-alpha.64) (2026-04-27)
14
+
15
+
16
+ ### Dependencies
17
+
18
+ * **@visulima/packem-share:** upgraded to 1.0.0-alpha.45
19
+ * **@visulima/rollup-plugin-dts:** upgraded to 1.0.0-alpha.25
20
+
1
21
  ## @visulima/packem-rollup [1.0.0-alpha.63](https://github.com/visulima/packem/compare/@visulima/packem-rollup@1.0.0-alpha.62...@visulima/packem-rollup@1.0.0-alpha.63) (2026-04-24)
2
22
 
3
23
 
@@ -9,13 +9,13 @@ var E=Object.defineProperty;var w=(e,r)=>E(e,"name",{value:r,configurable:!0});i
9
9
  }
10
10
  // Fallback to createRequire
11
11
  return ${T}(module);
12
- };`,g={builtin:/const\s+__cjs_getBuiltinModule\s*=\s*\(module\)\s*=>\s*\{[\s\S]*?\};\s*/g,import:/import\s*\{\s*createRequire(?:\s+as\s+__cjs_createRequire)?\s*\}\s*from\s*["']node:module["'];?\s*/g,process:/const\s+__cjs_getProcess\s*=\s*typeof\s+globalThis[^;]*;\s*/g,require:/const\s+__cjs_require\s*=\s*(?:__cjs_)?createRequire\s*\([^)]*\);\s*/g};let R=!1;const te=m((e,r)=>r&&(K.includes(e)||e.startsWith("node:")),"isBuiltinModule"),oe=m(async(e,r,i,s,o)=>{if(r)return!0;const c=await i?.(e,s,o);return c===void 0?await Y(e,s,o):c},"shouldTransformImport"),ne=m((e,r)=>r?e==="process"||e==="node:process"?{code:"__cjs_getProcess",needsBuiltin:!1,needsProcess:!0,needsRequire:!0}:{code:`__cjs_getBuiltinModule(${JSON.stringify(e)})`,needsBuiltin:!0,needsProcess:!0,needsRequire:!0}:{code:`${T}(${JSON.stringify(e)})`,needsBuiltin:!1,needsProcess:!1,needsRequire:!0},"generateRequireCode"),ie=m(e=>{const r=new S(e),i={builtin:[...e.matchAll(g.builtin)],import:[...e.matchAll(g.import)],process:[...e.matchAll(g.process)],require:[...e.matchAll(g.require)]};return Object.values(i).forEach(s=>{if(s.length>1)for(let o=s.length-1;o>0;o-=1){const c=s[o];c&&r.remove(c.index,c.index+c[0].length)}}),r.toString()},"removeDuplicates"),ce=m(e=>{if(Array.isArray(e.shouldTransform)){const{shouldTransform:r}=e;e.shouldTransform=i=>r.includes(i)}return{builtinNodeModules:!!e.builtinNodeModules,cwd:e.cwd||B.cwd(),exclude:e.exclude||[/node_modules/,/\.d\.[cm]?ts$/],include:e.include||[/\.[cm]?[jt]sx?$/],order:"order"in e?e.order:"pre",shouldTransform:e.shouldTransform}},"resolveOptions"),he=m((e,r)=>{if(B.env.INTERNAL_PACKEM_BUILD)return{name:"require-cjs-transformer"};const{builtinNodeModules:i,cwd:s,exclude:o,include:c,order:A,shouldTransform:C}=ce(e),J=L(c,o);return{async buildStart(){R||(await x(),R=!0)},name:"packem:plugin-require-cjs",renderChunk:{async handler(h,M,O){if(O.format!=="es"||!J(M.fileName))return;const I=H(M.fileName,h,{astType:"js",lang:"js",sourceType:"module"}),u=new S(h);let j=!1,y=!1,v=!1;for await(const t of I.program.body){if(t.type!=="ImportDeclaration"||t.importKind==="type")continue;const l=t.source.value,d=te(l,i),$=this.resolve;if(!await oe(l,d,C,s,$))continue;const{code:b,needsBuiltin:k,needsProcess:W,needsRequire:D}=ne(l,d);if(j||=D,y||=W,v||=k,t.specifiers.length===0){d?u.remove(t.start,t.end):u.overwrite(t.start,t.end,`${b};`);continue}const P=[];let f,a;for(const n of t.specifiers)if(n.type==="ImportNamespaceSpecifier")f=n.local.name;else if(n.type==="ImportSpecifier"&&n.importKind!=="type"){const _=h.slice(n.imported.start,n.imported.end);P.push([_,n.local.name])}else n.type==="ImportDefaultSpecifier"&&(a=n.local.name);const p=[];if(f&&(a||=`_cjs_${f}_default`),a&&p.push(`const ${a} = ${b};`),f&&p.push(`const ${f} = { ...${a}, default: ${a} };`),P.length>0){const n=`const {
13
- ${P.map(([_,q])=>` ${_===q?q:`${_}: ${q}`}`).join(`,
12
+ };`,g={builtin:/const\s+__cjs_getBuiltinModule\s*=\s*\(module\)\s*=>\s*\{[\s\S]*?\};\s*/g,import:/import\s*\{\s*createRequire(?:\s+as\s+__cjs_createRequire)?\s*\}\s*from\s*["']node:module["'];?\s*/g,process:/const\s+__cjs_getProcess\s*=\s*typeof\s+globalThis[^;]*;\s*/g,require:/const\s+__cjs_require\s*=\s*(?:(?:__cjs_)?createRequire|createRequire\$\d+)\s*\([^)]*\);\s*/g};let N=!1;const te=m((e,r)=>r&&(K.includes(e)||e.startsWith("node:")),"isBuiltinModule"),oe=m(async(e,r,i,s,o)=>{if(r)return!0;const c=await i?.(e,s,o);return c===void 0?await Y(e,s,o):c},"shouldTransformImport"),ne=m((e,r)=>r?e==="process"||e==="node:process"?{code:"__cjs_getProcess",needsBuiltin:!1,needsProcess:!0,needsRequire:!0}:{code:`__cjs_getBuiltinModule(${JSON.stringify(e)})`,needsBuiltin:!0,needsProcess:!0,needsRequire:!0}:{code:`${T}(${JSON.stringify(e)})`,needsBuiltin:!1,needsProcess:!1,needsRequire:!0},"generateRequireCode"),ie=m(e=>{const r=new S(e),i={builtin:[...e.matchAll(g.builtin)],import:[...e.matchAll(g.import)],process:[...e.matchAll(g.process)],require:[...e.matchAll(g.require)]};return Object.values(i).forEach(s=>{if(s.length>1)for(let o=s.length-1;o>0;o-=1){const c=s[o];c&&r.remove(c.index,c.index+c[0].length)}}),r.toString()},"removeDuplicates"),ce=m(e=>{if(Array.isArray(e.shouldTransform)){const{shouldTransform:r}=e;e.shouldTransform=i=>r.includes(i)}return{builtinNodeModules:!!e.builtinNodeModules,cwd:e.cwd||B.cwd(),exclude:e.exclude||[/node_modules/,/\.d\.[cm]?ts$/],include:e.include||[/\.[cm]?[jt]sx?$/],order:"order"in e?e.order:"pre",shouldTransform:e.shouldTransform}},"resolveOptions"),he=m((e,r)=>{if(B.env.INTERNAL_PACKEM_BUILD)return{name:"require-cjs-transformer"};const{builtinNodeModules:i,cwd:s,exclude:o,include:c,order:A,shouldTransform:C}=ce(e),J=L(c,o);return{async buildStart(){N||(await x(),N=!0)},name:"packem:plugin-require-cjs",renderChunk:{async handler(h,M,O){if(O.format!=="es"||!J(M.fileName))return;const I=H(M.fileName,h,{astType:"js",lang:"js",sourceType:"module"}),u=new S(h);let j=!1,y=!1,$=!1;for await(const t of I.program.body){if(t.type!=="ImportDeclaration"||t.importKind==="type")continue;const l=t.source.value,d=te(l,i),v=this.resolve;if(!await oe(l,d,C,s,v))continue;const{code:b,needsBuiltin:k,needsProcess:W,needsRequire:D}=ne(l,d);if(j||=D,y||=W,$||=k,t.specifiers.length===0){d?u.remove(t.start,t.end):u.overwrite(t.start,t.end,`${b};`);continue}const q=[];let f,a;for(const n of t.specifiers)if(n.type==="ImportNamespaceSpecifier")f=n.local.name;else if(n.type==="ImportSpecifier"&&n.importKind!=="type"){const _=h.slice(n.imported.start,n.imported.end);q.push([_,n.local.name])}else n.type==="ImportDefaultSpecifier"&&(a=n.local.name);const p=[];if(f&&(a||=`_cjs_${f}_default`),a&&p.push(`const ${a} = ${b};`),f&&p.push(`const ${f} = { ...${a}, default: ${a} };`),q.length>0){const n=`const {
13
+ ${q.map(([_,P])=>` ${_===P?P:`${_}: ${P}`}`).join(`,
14
14
  `)}
15
15
  } = ${a||b};`;p.push(n)}u.overwrite(t.start,t.end,p.join(`
16
- `))}if(j||y||v){const t=[];j&&t.push(z,ee),y&&t.push(re),v&&t.push(se);const l=`${t.join(`
16
+ `))}if(j||y||$){const t=[];j&&t.push(z,ee),y&&t.push(re),$&&t.push(se);const l=`${t.join(`
17
17
 
18
18
  `)}
19
19
 
20
- `,d=u.toString();if(d[0]==="#"){const $=d.indexOf(`
21
- `)+1;u.appendLeft($,l)}else u.prepend(l)}const N=new S(ie(u.toString()));return{code:N.toString(),map:N.generateMap()}},order:A}}},"requireCJSTransformerPlugin");export{he as requireCJSTransformerPlugin};
20
+ `,d=u.toString();if(d[0]==="#"){const v=d.indexOf(`
21
+ `)+1;u.appendLeft(v,l)}else u.prepend(l)}const R=new S(ie(u.toString()));return{code:R.toString(),map:R.generateMap()}},order:A}}},"requireCJSTransformerPlugin");export{he as requireCJSTransformerPlugin};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/packem-rollup",
3
- "version": "1.0.0-alpha.63",
3
+ "version": "1.0.0-alpha.65",
4
4
  "description": "Rollup plugins for packem",
5
5
  "keywords": [
6
6
  "visulima",
@@ -154,9 +154,9 @@
154
154
  "@visulima/find-cache-dir": "3.0.0-alpha.9",
155
155
  "@visulima/fs": "5.0.0-alpha.12",
156
156
  "@visulima/package": "5.0.0-alpha.11",
157
- "@visulima/packem-share": "1.0.0-alpha.44",
157
+ "@visulima/packem-share": "1.0.0-alpha.46",
158
158
  "@visulima/path": "3.0.0-alpha.10",
159
- "@visulima/rollup-plugin-dts": "1.0.0-alpha.24",
159
+ "@visulima/rollup-plugin-dts": "1.0.0-alpha.26",
160
160
  "@visulima/source-map": "3.0.0-alpha.9",
161
161
  "cjs-module-lexer": "2.2.0",
162
162
  "clean-css": "^5.3.3",