@visulima/packem-rollup 1.0.0-alpha.70 → 1.0.0-alpha.72

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,34 @@
1
+ ## @visulima/packem-rollup [1.0.0-alpha.72](https://github.com/visulima/packem/compare/@visulima/packem-rollup@1.0.0-alpha.71...@visulima/packem-rollup@1.0.0-alpha.72) (2026-06-04)
2
+
3
+ ### Bug Fixes
4
+
5
+ * **packem-rollup:** shared-loader mutation, chunk-splitter recursion/sourcemap fixes, parse perf + bench ([7a90c64](https://github.com/visulima/packem/commit/7a90c6400bd6aee9a3225a9479b53fa5ffcda89b))
6
+
7
+ ### Styles
8
+
9
+ * clear eslint debt from the audit/types passes ([fd68951](https://github.com/visulima/packem/commit/fd68951681817078ae579dcad10963b1a07c1d27))
10
+
11
+ ### Code Refactoring
12
+
13
+ * **packem-rollup:** tighten internal TypeScript types ([c381f84](https://github.com/visulima/packem/commit/c381f84b62f250426e962126c87663bdd3001c48))
14
+
15
+
16
+ ### Dependencies
17
+
18
+ * **@visulima/packem-share:** upgraded to 1.0.0-alpha.49
19
+ * **@visulima/rollup-plugin-dts:** upgraded to 1.0.0-alpha.33
20
+
21
+ ## @visulima/packem-rollup [1.0.0-alpha.71](https://github.com/visulima/packem/compare/@visulima/packem-rollup@1.0.0-alpha.70...@visulima/packem-rollup@1.0.0-alpha.71) (2026-06-03)
22
+
23
+ ### Bug Fixes
24
+
25
+ * **packem:** replace node-resolve with oxc resolver & isolate DTS cache per entry-set ([#206](https://github.com/visulima/packem/issues/206)) ([b2eb482](https://github.com/visulima/packem/commit/b2eb4822b44393add900d1d2272bc886b13ce738))
26
+
27
+
28
+ ### Dependencies
29
+
30
+ * **@visulima/rollup-plugin-dts:** upgraded to 1.0.0-alpha.32
31
+
1
32
  ## @visulima/packem-rollup [1.0.0-alpha.70](https://github.com/visulima/packem/compare/@visulima/packem-rollup@1.0.0-alpha.69...@visulima/packem-rollup@1.0.0-alpha.70) (2026-06-03)
2
33
 
3
34
 
package/dist/index.d.ts CHANGED
@@ -10,8 +10,6 @@ export { type Alias, type ResolverObject as AliasResolverObject, type ResolvedAl
10
10
  import { RollupCommonJSOptions } from '@rollup/plugin-commonjs';
11
11
  export { type RollupCommonJSOptions, default as commonjs } from '@rollup/plugin-commonjs';
12
12
  import { RollupJsonOptions } from '@rollup/plugin-json';
13
- import { RollupNodeResolveOptions } from '@rollup/plugin-node-resolve';
14
- export { type RollupNodeResolveOptions, default as nodeResolve } from '@rollup/plugin-node-resolve';
15
13
  import { RollupReplaceOptions } from '@rollup/plugin-replace';
16
14
  export { type RollupReplaceOptions, default as replace } from '@rollup/plugin-replace';
17
15
  import { RollupWasmOptions } from '@rollup/plugin-wasm';
@@ -664,15 +662,41 @@ interface RollupDynamicImportVariablesOptions {
664
662
  */
665
663
  warnOnError?: boolean;
666
664
  }
667
- interface ExtendedRollupNodeResolveOptions extends RollupNodeResolveOptions {
665
+ /**
666
+ * Legacy `@rollup/plugin-node-resolve` option keys. Module resolution is now
667
+ * handled by the oxc resolver, but these keys are still accepted and mapped onto
668
+ * the equivalent oxc-resolver options at build time so existing configs (and the
669
+ * svelte/solid presets) keep working. Prefer the native oxc keys
670
+ * (`conditionNames`, `aliasFields`, …) in new configs.
671
+ */
672
+ interface LegacyNodeResolveOptions {
673
+ /** Node-resolve `allowExportsFolderMapping`; ignored by the oxc resolver (dropped at build time). */
674
+ allowExportsFolderMapping?: boolean;
675
+ /** Node-resolve `browser`; maps to the `"browser"` condition + the `browser` alias field. */
676
+ browser?: boolean;
677
+ /** Node-resolve `exportConditions`; maps to (and is prepended onto) `conditionNames`. */
678
+ exportConditions?: string[];
679
+ /**
680
+ * Node-resolve `preferBuiltins`. Node builtins are externalized by the externals
681
+ * plugin, so this is dropped before reaching the oxc resolver; it is retained as a
682
+ * config key only because the build runtime still sets it from `runtime`.
683
+ */
684
+ preferBuiltins?: boolean;
685
+ }
686
+ /**
687
+ * Module-resolution options, passed to the oxc-resolver-backed resolve plugin.
688
+ * Accepts the native oxc-resolver options plus a few legacy node-resolve keys
689
+ * ({@link LegacyNodeResolveOptions}) that are mapped onto their oxc equivalents.
690
+ */
691
+ type ResolveOptions = LegacyNodeResolveOptions & OXCResolveOptions & {
668
692
  /**
669
- * Controls how unresolved import warnings from the node-resolve plugin are handled.
670
- * - `"error"` (default): Treat unresolved imports as errors, causing the build to fail
671
- * - `"warn"`: Treat unresolved imports as warnings, allowing the build to continue
693
+ * Controls how unresolved imports are handled.
694
+ * - `"error"` (default): treat unresolved imports as errors, failing the build.
695
+ * - `"warn"`: emit a warning and continue.
672
696
  * @default "error"
673
697
  */
674
698
  unresolvedImportBehavior?: "error" | "warn";
675
- }
699
+ };
676
700
  interface PackemRollupOptions {
677
701
  alias?: RollupAliasOptions | false;
678
702
  babel?: BabelPluginConfig | false;
@@ -690,9 +714,6 @@ interface PackemRollupOptions {
690
714
  dts?: Options$2;
691
715
  dynamicVars?: RollupDynamicImportVariablesOptions | false;
692
716
  esbuild?: Options$3 | false;
693
- experimental?: {
694
- resolve?: OXCResolveOptions | false;
695
- };
696
717
  json?: RollupJsonOptions | false;
697
718
  jsxRemoveAttributes?: JSXRemoveAttributesPlugin | false;
698
719
  license?: LicenseOptions | false;
@@ -714,7 +735,7 @@ interface PackemRollupOptions {
714
735
  raw?: RawLoaderOptions | false;
715
736
  replace?: Omit<RollupReplaceOptions, "cwd"> | false;
716
737
  requireCJS?: Options | false;
717
- resolve?: ExtendedRollupNodeResolveOptions | false;
738
+ resolve?: ResolveOptions | false;
718
739
  resolveExternals?: ResolveExternalsPluginOptions;
719
740
  shebang?: Partial<ShebangOptions> | false;
720
741
  shim?: EsmShimCjsSyntaxOptions | false;
@@ -733,4 +754,4 @@ type RollupPlugins = {
733
754
  plugin: Plugin;
734
755
  type?: "build" | "dts";
735
756
  }[];
736
- export { type ExtendedRollupNodeResolveOptions, type JSXRemoveAttributesPlugin, type PackemRollupOptions, type RollupPlugins };
757
+ export { type JSXRemoveAttributesPlugin, type LegacyNodeResolveOptions, type PackemRollupOptions, type ResolveOptions, type RollupPlugins };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{default as o}from"./plugins/chunk-splitter/index.js";import{default as a}from"./packem_shared/browserslistToEsbuild-HD6SaWPt.js";import{jsxRemoveAttributes as s}from"./plugins/jsx-remove-attributes.js";import{preserveDirectivesPlugin as l}from"./plugins/preserve-directives.js";import{pureNewExpressionPlugin as u}from"./plugins/pure-new-expression-plugin.js";import{default as x}from"@rollup/plugin-alias";import{default as n}from"@rollup/plugin-commonjs";import{default as v}from"@rollup/plugin-dynamic-import-vars";import{default as g}from"@rollup/plugin-inject";import{default as h}from"@rollup/plugin-node-resolve";import{default as w}from"@rollup/plugin-replace";import{default as T}from"@rollup/plugin-wasm";import{importTrace as N,patchErrorWithTrace as R}from"rollup-plugin-import-trace";import{default as z}from"rollup-plugin-polyfill-node";import{PluginPure as D}from"rollup-plugin-pure";import{default as S}from"rollup-plugin-visualizer";export{x as alias,a as browserslistToEsbuild,o as chunkSplitter,n as commonjs,v as dynamicImportVars,N as importTrace,g as inject,s as jsxRemoveAttributes,h as nodeResolve,R as patchErrorWithTrace,z as polyfillNode,l as preserveDirectivesPlugin,u as pureNewExpressionPlugin,D as purePlugin,w as replace,S as visualizer,T as wasm};
1
+ import{default as o}from"./plugins/chunk-splitter/index.js";import{default as a}from"./packem_shared/browserslistToEsbuild-HD6SaWPt.js";import{jsxRemoveAttributes as s}from"./plugins/jsx-remove-attributes.js";import{preserveDirectivesPlugin as l}from"./plugins/preserve-directives.js";import{pureNewExpressionPlugin as u}from"./plugins/pure-new-expression-plugin.js";import{default as x}from"@rollup/plugin-alias";import{default as c}from"@rollup/plugin-commonjs";import{default as P}from"@rollup/plugin-dynamic-import-vars";import{default as v}from"@rollup/plugin-inject";import{default as h}from"@rollup/plugin-replace";import{default as w}from"@rollup/plugin-wasm";import{importTrace as T,patchErrorWithTrace as y}from"rollup-plugin-import-trace";import{default as k}from"rollup-plugin-polyfill-node";import{PluginPure as A}from"rollup-plugin-pure";import{default as I}from"rollup-plugin-visualizer";export{x as alias,a as browserslistToEsbuild,o as chunkSplitter,c as commonjs,P as dynamicImportVars,T as importTrace,v as inject,s as jsxRemoveAttributes,y as patchErrorWithTrace,k as polyfillNode,l as preserveDirectivesPlugin,u as pureNewExpressionPlugin,A as purePlugin,h as replace,I as visualizer,w as wasm};
@@ -0,0 +1 @@
1
+ var x=Object.defineProperty;var l=(e,r)=>x(e,"name",{value:r,configurable:!0});import{createFilter as k}from"@rollup/pluginutils";import{DEFAULT_LOADERS as O}from"@visulima/packem-share/constants";import{join as E,extname as M}from"@visulima/path";import{formatMessages as S,transform as D,build as A}from"esbuild";import{findCacheDirSync as P}from"@visulima/find-cache-dir";import{readFileSync as R}from"@visulima/fs";import*as F from"rs-module-lexer";var L=Object.defineProperty,C=l((e,r)=>L(e,"name",{value:r,configurable:!0}),"n");const _=C(async(e,r)=>{r.length>0&&(await S(r,{color:!0,kind:"warning"})).forEach(n=>{e.warn(n)})},"warn");var W=Object.defineProperty,z=l((e,r)=>W(e,"name",{value:r,configurable:!0}),"t");const $=z(e=>{if(e==="es")return"esm";if(e==="cjs")return e},"getEsbuildFormat"),I=z(({sourceMap:e=!0,...r})=>async function(n,s,i){if(r.minify||r.minifyWhitespace||r.minifyIdentifiers||r.minifySyntax){const t=$(i.format),c=await D(n,{format:t,loader:"js",sourcemap:e,...r});if(await _(this,c.warnings),c.code)return{code:c.code,map:c.map||void 0}}},"getRenderChunk");var T=Object.defineProperty,j=l((e,r)=>T(e,"name",{value:r,configurable:!0}),"o");const w=j(e=>e.replaceAll("\\","/"),"slash"),{parseAsync:q}=F,y=/.*/,N=j(async e=>{const r=P("@visulima/packem/optimize-deps",{create:!0,cwd:e.cwd});if(!r)throw new Error('[packem:optimize-deps]: failed to find or create cache directory "node_modules/.cache/packem/optimize_deps".');await A({absWorkingDir:e.cwd,bundle:!0,entryPoints:e.include,format:"esm",ignoreAnnotations:!0,metafile:!0,outdir:r,sourcemap:e.sourceMap,splitting:!0,...e.esbuildOptions,plugins:[{name:"optimize-deps",setup(s){s.onResolve({filter:y},async i=>{if(e.exclude?.includes(i.path))return{external:!0};if(!i.pluginData?.__resolving_dep_path__&&e.include.includes(i.path)){const t=await s.resolve(i.path,{kind:"import-statement",pluginData:{__resolving_dep_path__:!0},resolveDir:i.resolveDir});return t.errors.length>0||t.warnings.length>0?t:{namespace:"optimize-deps",path:i.path,pluginData:{absolute:t.path,resolveDir:i.resolveDir}}}}),s.onLoad({filter:y,namespace:"optimize-deps"},async i=>{const{absolute:t,resolveDir:c}=i.pluginData,p=R(t),{output:g}=await q({input:[{code:p,filename:t}]});return{contents:(g[0]?.exports??[]).length>0?`export * from '${w(t)}'`:`module.exports = require('${w(t)}')`,resolveDir:c}})}},...e.esbuildOptions?.plugins??[]]});const n=new Map;for(const s of e.include)n.set(s,{file:E(r,`${s}.js`)});return{cacheDir:r,optimized:n}},"optimizeDeps");var U=Object.defineProperty,B=l((e,r)=>U(e,"name",{value:r,configurable:!0}),"b");const G=/\.[cm]ts/,H=new Set(["base64","binary","dataurl","json","text"]),J=B(({exclude:e,include:r,loaders:n,logger:s,optimizeDeps:i,sourceMap:t,...c})=>{const p={...O};if(n!==void 0)for(const[a,o]of Object.entries(n)){const d=a.startsWith(".")?a:`.${a}`;typeof o=="string"?p[d]=o:delete p[d]}const g=Object.keys(p),h=new RegExp(String.raw`\.(${g.map(a=>a.slice(1)).join("|")})$`),v=r||e?k(r??h,e):void 0;let u,b=process.cwd();return{async buildStart(){!i||u||(u=await N({cwd:b,sourceMap:t??!1,...i}),s.debug("optimized %O",u.optimized))},name:"packem:esbuild",options({context:a}){a&&(b=a)},renderChunk:I({...c,sourceMap:t}),resolveId(a){if(u?.optimized.has(a)){const o=u.optimized.get(a);if(o)return s.debug("resolved %s to %s",a,o.file),o.file}},transform:{filter:{id:h},async handler(a,o){if(v&&!v(o)||u?.optimized.has(o))return;const d=M(o),m=p[d];if(s.debug("transforming %s with %s loader",o,m),!m)return;const f=await D(a,{format:H.has(m)?"esm":void 0,loader:m,sourcefile:o.replace(G,".ts"),sourcemap:t,...c});if(await _(this,f.warnings),f.code)return{code:f.code,map:f.map||void 0}}}}},"esbuildTransformer");J.NAME="esbuild";export{J as default};
@@ -1 +1 @@
1
- var m=Object.defineProperty;var s=(e,a)=>m(e,"name",{value:a,configurable:!0});import c from"node:assert/strict";import{extractAssignedNames as u}from"@rollup/pluginutils";var y=Object.defineProperty,n=s((e,a)=>y(e,"name",{value:a,configurable:!0}),"r$1");const x=n(function*(e){switch(e.declaration?.type){case"ClassDeclaration":case"FunctionDeclaration":{const{id:a}=e.declaration;c.ok(a,"Expected class/function to have a name"),yield a.name;break}case"VariableDeclaration":{for(const a of e.declaration.declarations)for(const o of u(a.id))yield o;break}}},"exportName"),N=n(function*(e){if(e.declaration)for(const a of x(e))yield{exportedName:a,from:"self",type:"named"};else if(e.source)yield{bindings:e.specifiers.map(a=>({exportedName:a.exported.name,importedName:a.local.name})),from:"other",source:e.source.value,type:"named"};else for(const a of e.specifiers)yield{exportedName:a.exported.name,from:"self",type:"named"}},"parseExportNamed"),b=n(function*(e){e.exported?yield{exportedName:e.exported.name,from:"self",type:"named"}:yield{from:"other",source:e.source.value,type:"barrel"}},"parseExportAll"),h=n(function*(){yield{exportedName:"default",from:"self",type:"named"}},"parseExportDefault"),v=n(function*(e,a){c.ok(a.code!==null,`Module ${a.id} doesn't have associated code`);const o=e.parse(a.code);for(const r of o.body)switch(r.type){case"ExportAllDeclaration":{yield*b(r);break}case"ExportDefaultDeclaration":{yield*h();break}case"ExportNamedDeclaration":{yield*N(r);break}}},"parseExports");var g=Object.defineProperty,i=s((e,a)=>g(e,"name",{value:a,configurable:!0}),"n$1");const f=i(async function(e,a,o){const r=await e.resolve(a,o.id);if(c.ok(r,`Rollup can't resolve ${a} from ${o.id}`),r.external)return;const d=await e.load(r);return c.ok(d,`Rollup doesn't have a module for id ${r.id}`),d},"getImportedModule"),k=i(async function*(e,a,o){const r=await f(e,a.source,o);r&&(yield*l(e,r))},"gatherBarrelReExports"),E=i(async function*(e,a,o){const r=await f(e,a.source,o);if(!r)return;const d=new Map(a.bindings.map(t=>[t.importedName,t]));for await(const t of l(e,r)){const p=d.get(t.exportedName);p&&(yield{...t,exportedName:p.exportedName})}},"gatherNamedReExports"),$=i(function*(e,a){yield{exportedName:a.exportedName,id:e.id,sourceName:a.exportedName}},"gatherNamedSelfExports"),l=i(async function*(e,a){for(const o of v(e,a))o.from==="self"?yield*$(a,o):o.type==="barrel"?yield*k(e,o,a):yield*E(e,o,a)},"gatherExports");var w=Object.defineProperty,D=s((e,a)=>w(e,"name",{value:a,configurable:!0}),"r");const A=D(()=>({moduleParsed:{async handler(e){if(e.isEntry)for await(const a of l(this,e))a.id!==e.id&&this.emitFile({id:a.id,name:a.exportedName,preserveSignature:"exports-only",type:"chunk"})},order:"post"},name:"packem:chunk-splitter"}),"chunkSplitter");export{A 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}),"a");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"),b=n(function*(t){t.exported?yield{exportedName:t.exported.name,from:"self",type:"named"}:yield{from:"other",source:t.source.value,type:"barrel"}},"parseExportAll"),g=n(function*(){yield{exportedName:"default",from:"self",type:"named"}},"parseExportDefault"),f=n(function(t,e){c.ok(e.code!==null,`Module ${e.id} doesn't have associated code`);const a=t.parse(e.code),r=[];for(const o of a.body)switch(o.type){case"ExportAllDeclaration":{r.push(...b(o));break}case"ExportDefaultDeclaration":{r.push(...g());break}case"ExportNamedDeclaration":{r.push(...N(o));break}}return r},"collectExports"),E=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 k=Object.defineProperty,i=d((t,e)=>k(t,"name",{value:e,configurable:!0}),"i");const u=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 u(t,e.source,a);o&&(yield*l(t,o,r))},"gatherBarrelReExports"),$=i(async function*(t,e,a,r){const o=await u(t,e.source,a);if(!o)return;const m=new Map(e.bindings.map(s=>[s.importedName,s]));for await(const s of l(t,o,r)){const p=m.get(s.exportedName);p&&(yield{...s,exportedName:p.exportedName})}},"gatherNamedReExports"),D=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 E(t,e,a.parseCache))r.from==="self"?yield*D(e,r):r.type==="barrel"?yield*w(t,r,e,a):yield*$(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 C=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{C as default};
@@ -1,2 +1,2 @@
1
- var d=Object.defineProperty;var u=(e,r)=>d(e,"name",{value:r,configurable:!0});import c from"magic-string";var i=Object.defineProperty,s=u((e,r)=>i(e,"name",{value:r,configurable:!0}),"p");const f=/(exports(?:\['default'\]|\.default)) = (.*);/i,m=/(?:module\.)?exports(?:\['default'\]|\.default)/i,j=s(({addDefaultProperty:e=!1,logger:r})=>({name:"packem:cjs-interop",renderChunk:s((p,l,a)=>{if(l.isEntry&&a.format==="cjs"&&a.exports==="auto"){const o=f.exec(p);if(o===null||o.length<3)return;const t=new c(p);t.replace("Object.defineProperty(exports, '__esModule', { value: true });",""),t.replaceAll(/exports\.(.*) = (.*);/g,"module.exports.$1 = $2;"),e&&t.append(`
2
- module.exports.default = ${o[2]};`);let n=t.toString();return n=n.replace(m,"module.exports"),r.debug({message:`Applied CommonJS interop to entry chunk ${l.fileName}.`,prefix:"plugin:cjs-interop"}),{code:n,map:t.generateMap({hires:!0})}}},"renderChunk")}),"cjsInteropPlugin");export{j as cjsInteropPlugin};
1
+ var g=Object.defineProperty;var d=(t,r)=>g(t,"name",{value:r,configurable:!0});import m from"magic-string";var x=Object.defineProperty,f=d((t,r)=>x(t,"name",{value:r,configurable:!0}),"s");const v=/(exports(?:\['default'\]|\.default)) = (.*);/i,y=f(({addDefaultProperty:t=!1,logger:r})=>({name:"packem:cjs-interop",renderChunk:f((n,a,s)=>{if(a.isEntry&&s.format==="cjs"&&s.exports==="auto"){const u=v.exec(n);if(u===null||u.length<3)return;const e=new m(n);e.replace("Object.defineProperty(exports, '__esModule', { value: true });","");const i=/exports(?:\['default'\]|\.([A-Za-z_$][\w$]*)) = /g;let o=i.exec(n);for(;o!==null;){const p=o.index,c=p+o[0].length-3,l=o[1];l===void 0||l==="default"?e.overwrite(p,c,"module.exports"):e.overwrite(p,c,`module.exports.${l}`),o=i.exec(n)}return t&&e.append(`
2
+ module.exports.default = ${u[2]};`),r.debug({message:`Applied CommonJS interop to entry chunk ${a.fileName}.`,prefix:"plugin:cjs-interop"}),{code:e.toString(),map:e.generateMap({hires:!0})}}},"renderChunk")}),"cjsInteropPlugin");export{y as cjsInteropPlugin};
@@ -1 +1 @@
1
- import{default as l}from"../../packem_shared/browserslistToEsbuild-HD6SaWPt.js";import{default as r}from"../../packem_shared/esbuildPlugin-BStpbA6S.js";export{l as browserslistToEsbuild,r as esbuildPlugin};
1
+ import{default as l}from"../../packem_shared/browserslistToEsbuild-HD6SaWPt.js";import{default as r}from"../../packem_shared/esbuildPlugin-B1VwtwkS.js";export{l as browserslistToEsbuild,r as esbuildPlugin};
@@ -1 +1 @@
1
- var c=Object.defineProperty;var l=(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 v=Object.defineProperty,b=l((e,a)=>v(e,"name",{value:a,configurable:!0}),"l");const d=/\.[jt]sx$/,w=b(({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:d},handler(o,u){let i;try{i=this.parse(o,{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}const n=new f(o);y(i,{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)&&n.overwrite(t.start-2,t.end,"")}}});const p=n.toString();if(p!==o)return{code:p,map:n.generateMap({hires:!0})}}}}},"jsxRemoveAttributes");export{w as jsxRemoveAttributes};
1
+ var c=Object.defineProperty;var l=(e,a)=>c(e,"name",{value:a,configurable:!0});import{w as f}from"../packem_shared/index-Dq8IUFTs.js";import y from"magic-string";var v=Object.defineProperty,x=l((e,a)=>v(e,"name",{value:a,configurable:!0}),"l");const b=/\.[jt]sx$/,d=new Set(["jsx","jsxDEV","jsxs"]),h=x(({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:b},handler(o,u){let n;try{n=this.parse(o,{allowReturnOutsideFunction:!0})}catch(t){this.warn({code:"PARSE_ERROR",message:`[packem:jsx-remove-attributes]: failed to parse "${u}" and remove the jsx attribute.`}),a.warn(t);return}const i=new y(o);f(n,{enter(t){if(t.type==="CallExpression"&&t.callee.type==="Identifier"&&d.has(t.callee.name)){const m=t.arguments.filter(s=>s.type==="ObjectExpression"&&Array.isArray(s.properties));for(const s of m)for(const r of s.properties)r.type==="Property"&&r.key.type==="Literal"&&r.value.type==="Literal"&&e.includes(r.key.value)&&i.overwrite(r.start-2,r.end,"")}}});const p=i.toString();if(p!==o)return{code:p,map:i.generateMap({hires:!0})}}}}},"jsxRemoveAttributes");export{h as jsxRemoveAttributes};
@@ -1,4 +1,4 @@
1
- var y=Object.defineProperty;var v=(a,c)=>y(a,"name",{value:c,configurable:!0});import{createFilter as I}from"@rollup/pluginutils";import g from"magic-string";var w=Object.defineProperty,m=v((a,c)=>w(a,"name",{value:c,configurable:!0}),"l");const S=m(({directiveRegex:a,exclude:c=[],include:h=[],logger:p})=>{const f={},l={},b=I(h,c);return{name:"packem:preserve-directives",onLog(n,i){if(i.code==="MODULE_LEVEL_DIRECTIVE"&&n==="warn")return!1},renderChunk:{handler(n,i,{sourcemap:u}){const o=m(r=>{const s=this.getModuleInfo(r)?.meta?.preserveDirectives?.directives;return s&&s.length>0?new Set(s):f[r]},"directivesForId"),d=i.moduleIds.map(r=>o(r)).reduce((r,s)=>(s&&s.forEach(x=>{r.add(x)}),r),new Set),e=new g(n);d.size>0&&(p.debug({message:`directives for chunk "${i.fileName}" are preserved.`,prefix:"plugin:preserve-directives"}),e.prepend(`${Array.from(d,r=>`'${r}';`).join(`
1
+ var y=Object.defineProperty;var v=(a,c)=>y(a,"name",{value:c,configurable:!0});import{createFilter as I}from"@rollup/pluginutils";import g from"magic-string";var M=Object.defineProperty,m=v((a,c)=>M(a,"name",{value:c,configurable:!0}),"l");const S=m(({directiveRegex:a,exclude:c=[],include:h=[],logger:p})=>{const l={},f={},b=I(h,c);return{name:"packem:preserve-directives",onLog(s,i){if(i.code==="MODULE_LEVEL_DIRECTIVE"&&s==="warn")return!1},renderChunk:{handler(s,i,{sourcemap:u}){const o=m(r=>{const n=this.getModuleInfo(r)?.meta?.preserveDirectives?.directives;return n&&n.length>0?new Set(n):l[r]},"directivesForId"),d=i.moduleIds.map(r=>o(r)).reduce((r,n)=>(n&&n.forEach(x=>{r.add(x)}),r),new Set),e=new g(s);d.size>0&&(p.debug({message:`directives for chunk "${i.fileName}" are preserved.`,prefix:"plugin:preserve-directives"}),e.prepend(`${Array.from(d,r=>`'${r}';`).join(`
2
2
  `)}
3
- `));let t;if(i.facadeModuleId){const r=this.getModuleInfo(i.facadeModuleId)?.meta?.preserveDirectives?.shebang;typeof r=="string"?t=r:typeof l[i.facadeModuleId]=="string"&&(t=l[i.facadeModuleId])}if(t&&(p.debug({message:`shebang for chunk "${i.fileName}" is preserved.`,prefix:"plugin:preserve-directives"}),e.prepend(`${t}
4
- `)),!(d.size===0&&t===void 0))return{code:e.toString(),map:u?e.generateMap({hires:!0}):void 0}},order:"post"},transform(n,i){if(!b(i))return;let u=!1;const o=new g(n);if(n.startsWith("#")&&n[1]==="!"){let e=0;for(let t=n.length,r=2;r<t;r+=1){const s=n.codePointAt(r);if(s===10||s===13||s===8232||s===8233){e=r;break}}e&&(l[i]=n.slice(0,e),o.remove(0,e+1),u=!0,p.debug({message:`shebang for module "${i}" is preserved.`,prefix:"plugin:preserve-directives"}))}let d;try{d=this.parse(o.toString(),{allowReturnOutsideFunction:!0})}catch(e){this.warn({code:"PARSE_ERROR",message:`failed to parse "${i}" and extract the directives.`}),p.warn(e);return}for(const e of d.body.filter(Boolean)){if(e.type!=="ExpressionStatement")break;let t;if("directive"in e?t=e.directive:e.expression.type==="Literal"&&typeof e.expression.value=="string"&&a.test(e.expression.value)&&(t=e.expression.value),t!=="use strict"&&t){const r=f[i];r?r.add(t):f[i]=new Set([t]),"start"in e&&typeof e.start=="number"&&"end"in e&&typeof e.end=="number"&&(o.remove(e.start,e.end),u=!0),p.debug({message:`directive "${t}" for module "${i}" is preserved.`,prefix:"plugin:preserve-directives"})}}if(u)return{code:o.toString(),map:o.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...f[i]??[]],shebang:l[i]??void 0}}}}}},"preserveDirectivesPlugin");export{S as preserveDirectivesPlugin};
3
+ `));let t;if(i.facadeModuleId){const r=this.getModuleInfo(i.facadeModuleId)?.meta?.preserveDirectives?.shebang;typeof r=="string"?t=r:typeof f[i.facadeModuleId]=="string"&&(t=f[i.facadeModuleId])}if(t&&(p.debug({message:`shebang for chunk "${i.fileName}" is preserved.`,prefix:"plugin:preserve-directives"}),e.prepend(`${t}
4
+ `)),!(d.size===0&&t===void 0))return{code:e.toString(),map:u?e.generateMap({hires:!0}):void 0}},order:"post"},transform(s,i){if(!b(i))return;let u=!1;const o=new g(s);if(s.startsWith("#")&&s[1]==="!"){let e=s.length;for(let t=s.length,r=2;r<t;r+=1){const n=s.codePointAt(r);if(n===10||n===13||n===8232||n===8233){e=r;break}}e>0&&(f[i]=s.slice(0,e),o.remove(0,Math.min(e+1,s.length)),u=!0,p.debug({message:`shebang for module "${i}" is preserved.`,prefix:"plugin:preserve-directives"}))}let d;try{d=this.parse(o.toString(),{allowReturnOutsideFunction:!0})}catch(e){this.warn({code:"PARSE_ERROR",message:`failed to parse "${i}" and extract the directives.`}),p.warn(e);return}for(const e of d.body.filter(Boolean)){if(e.type!=="ExpressionStatement")break;let t;if("directive"in e?t=e.directive:e.expression.type==="Literal"&&typeof e.expression.value=="string"&&a.test(e.expression.value)&&(t=e.expression.value),t!=="use strict"&&t){const r=l[i];r?r.add(t):l[i]=new Set([t]),"start"in e&&typeof e.start=="number"&&"end"in e&&typeof e.end=="number"&&(o.remove(e.start,e.end),u=!0),p.debug({message:`directive "${t}" for module "${i}" is preserved.`,prefix:"plugin:preserve-directives"})}}if(u)return{code:o.toString(),map:o.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...l[i]??[]],shebang:f[i]??void 0}}}}}},"preserveDirectivesPlugin");export{S as preserveDirectivesPlugin};
@@ -1 +1 @@
1
- var m=Object.defineProperty;var c=(r,e)=>m(r,"name",{value:e,configurable:!0});import{w as d}from"../packem_shared/index-Dq8IUFTs.js";import w from"magic-string";var y=Object.defineProperty,g=c((r,e)=>y(r,"name",{value:e,configurable:!0}),"l");const _=g(r=>{const e=new Set(r.constructors.filter(t=>!t.includes(".")));return{name:"packem:pure-new-expression",transform:{handler(t){if(e.size===0)return;let a=!1;for(const o of e)if(t.includes(o)){a=!0;break}if(!a)return;let i;try{i=this.parse(t)}catch{return}const s=new w(t);d(i,{enter(o){const n=o,u=n.callee?.name,l=o._rollupAnnotations;n.type==="NewExpression"&&n.callee?.type==="Identifier"&&typeof u=="string"&&e.has(u)&&!l?.some(f=>f.type==="pure")&&typeof n.start=="number"&&s.prependLeft(n.start,"/* @__PURE__ */ ")}});const p=s.toString();if(p!==t)return{code:p,map:r.sourcemap?s.generateMap({hires:!0}):void 0}},order:"post"}}},"pureNewExpressionPlugin");export{_ as pureNewExpressionPlugin};
1
+ var w=Object.defineProperty;var u=(t,r)=>w(t,"name",{value:r,configurable:!0});import{w as d}from"../packem_shared/index-Dq8IUFTs.js";import v from"magic-string";var x=Object.defineProperty,c=u((t,r)=>x(t,"name",{value:r,configurable:!0}),"o");const h=c(t=>{const r=new Set(t.constructors.filter(e=>!e.includes("."))),l=c(e=>e.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`),"escapeForRegExp"),s=r.size>0?new RegExp(String.raw`\b(?:${[...r].map(e=>l(e)).join("|")})\b`):void 0;return{name:"packem:pure-new-expression",transform:{handler(e){if(r.size===0||s===void 0||!s.test(e))return;let p;try{p=this.parse(e)}catch{return}const o=new v(e);d(p,{enter(m){const n=m,i=n.callee?.name,f=n._rollupAnnotations;n.type==="NewExpression"&&n.callee?.type==="Identifier"&&typeof i=="string"&&r.has(i)&&!f?.some(g=>g.type==="pure")&&typeof n.start=="number"&&o.prependLeft(n.start,"/* @__PURE__ */ ")}});const a=o.toString();if(a!==e)return{code:a,map:t.sourcemap?o.generateMap({hires:!0}):void 0}},order:"post"}}},"pureNewExpressionPlugin");export{h as pureNewExpressionPlugin};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/packem-rollup",
3
- "version": "1.0.0-alpha.70",
3
+ "version": "1.0.0-alpha.72",
4
4
  "description": "Rollup plugins for packem",
5
5
  "keywords": [
6
6
  "visulima",
@@ -86,16 +86,15 @@
86
86
  "@rollup/plugin-dynamic-import-vars": "2.1.5",
87
87
  "@rollup/plugin-inject": "5.0.5",
88
88
  "@rollup/plugin-json": "6.1.0",
89
- "@rollup/plugin-node-resolve": "16.0.3",
90
89
  "@rollup/plugin-replace": "6.0.3",
91
90
  "@rollup/plugin-wasm": "6.2.2",
92
91
  "@rollup/pluginutils": "5.4.0",
93
92
  "@visulima/find-cache-dir": "3.0.0-alpha.9",
94
93
  "@visulima/fs": "5.0.0-alpha.24",
95
94
  "@visulima/package": "5.0.0-alpha.23",
96
- "@visulima/packem-share": "1.0.0-alpha.48",
95
+ "@visulima/packem-share": "1.0.0-alpha.49",
97
96
  "@visulima/path": "3.0.0-alpha.10",
98
- "@visulima/rollup-plugin-dts": "1.0.0-alpha.31",
97
+ "@visulima/rollup-plugin-dts": "1.0.0-alpha.33",
99
98
  "clean-css": "^5.3.3",
100
99
  "html-minifier-next": "6.2.7",
101
100
  "magic-string": "0.30.21",
@@ -1 +0,0 @@
1
- var x=Object.defineProperty;var l=(e,r)=>x(e,"name",{value:r,configurable:!0});import{createFilter as k}from"@rollup/pluginutils";import{DEFAULT_LOADERS as O}from"@visulima/packem-share/constants";import{join as E,extname as M}from"@visulima/path";import{formatMessages as A,transform as D,build as S}from"esbuild";import{findCacheDirSync as P}from"@visulima/find-cache-dir";import{readFileSync as R}from"@visulima/fs";import*as F from"rs-module-lexer";var C=Object.defineProperty,L=l((e,r)=>C(e,"name",{value:r,configurable:!0}),"n");const _=L(async(e,r)=>{r.length>0&&(await A(r,{color:!0,kind:"warning"})).forEach(s=>{e.warn(s)})},"warn");var W=Object.defineProperty,z=l((e,r)=>W(e,"name",{value:r,configurable:!0}),"t");const $=z(e=>{if(e==="es")return"esm";if(e==="cjs")return e},"getEsbuildFormat"),I=z(({sourceMap:e=!0,...r})=>async function(s,n,i){if(r.minify||r.minifyWhitespace||r.minifyIdentifiers||r.minifySyntax){const t=$(i.format),c=await D(s,{format:t,loader:"js",sourcemap:e,...r});if(await _(this,c.warnings),c.code)return{code:c.code,map:c.map||void 0}}},"getRenderChunk");var T=Object.defineProperty,j=l((e,r)=>T(e,"name",{value:r,configurable:!0}),"o");const w=j(e=>e.replaceAll("\\","/"),"slash"),{parseAsync:q}=F,y=/.*/,N=j(async e=>{const r=P("@visulima/packem/optimize-deps",{create:!0,cwd:e.cwd});if(!r)throw new Error('[packem:optimize-deps]: failed to find or create cache directory "node_modules/.cache/packem/optimize_deps".');await S({absWorkingDir:e.cwd,bundle:!0,entryPoints:e.include,format:"esm",ignoreAnnotations:!0,metafile:!0,outdir:r,sourcemap:e.sourceMap,splitting:!0,...e.esbuildOptions,plugins:[{name:"optimize-deps",setup(n){n.onResolve({filter:y},async i=>{if(e.exclude?.includes(i.path))return{external:!0};if(!i.pluginData?.__resolving_dep_path__&&e.include.includes(i.path)){const t=await n.resolve(i.path,{kind:"import-statement",pluginData:{__resolving_dep_path__:!0},resolveDir:i.resolveDir});return t.errors.length>0||t.warnings.length>0?t:{namespace:"optimize-deps",path:i.path,pluginData:{absolute:t.path,resolveDir:i.resolveDir}}}}),n.onLoad({filter:y,namespace:"optimize-deps"},async i=>{const{absolute:t,resolveDir:c}=i.pluginData,p=R(t),{output:g}=await q({input:[{code:p,filename:t}]});return{contents:(g[0]?.exports??[]).length>0?`export * from '${w(t)}'`:`module.exports = require('${w(t)}')`,resolveDir:c}})}},...e.esbuildOptions?.plugins??[]]});const s=new Map;for(const n of e.include)s.set(n,{file:E(r,`${n}.js`)});return{cacheDir:r,optimized:s}},"optimizeDeps");var U=Object.defineProperty,B=l((e,r)=>U(e,"name",{value:r,configurable:!0}),"E");const G=/\.[cm]ts/,H=B(({exclude:e,include:r,loaders:s,logger:n,optimizeDeps:i,sourceMap:t,...c})=>{const p=O;if(s!==void 0)for(const[o,a]of Object.entries(s)){const d=o.startsWith(".")?o:`.${o}`;typeof a=="string"?p[d]=a:delete p[d]}const g=Object.keys(p),v=new RegExp(String.raw`\.(${g.map(o=>o.slice(1)).join("|")})$`),h=r||e?k(r??v,e):void 0;let u,b=process.cwd();return{async buildStart(){!i||u||(u=await N({cwd:b,sourceMap:t??!1,...i}),n.debug("optimized %O",u.optimized))},name:"packem:esbuild",options({context:o}){o&&(b=o)},renderChunk:I({...c,sourceMap:t}),resolveId(o){if(u?.optimized.has(o)){const a=u.optimized.get(o);if(a)return n.debug("resolved %s to %s",o,a.file),a.file}},transform:{filter:{id:v},async handler(o,a){if(h&&!h(a)||u?.optimized.has(a))return;const d=M(a),m=p[d];if(n.debug("transforming %s with %s loader",a,m),!m)return;const f=await D(o,{format:["base64","binary","dataurl","text","json"].includes(m)?"esm":void 0,loader:m,sourcefile:a.replace(G,".ts"),sourcemap:t,...c});if(await _(this,f.warnings),f.code)return{code:f.code,map:f.map||void 0}}}}},"esbuildTransformer");H.NAME="esbuild";export{H as default};