@visulima/packem 1.7.1 → 1.7.2
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 +6 -0
- package/dist/cli.mjs +2 -2
- package/dist/packem.cjs +16 -16
- package/dist/packem.mjs +16 -16
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## @visulima/packem [1.7.2](https://github.com/visulima/packem/compare/@visulima/packem@1.7.1...@visulima/packem@1.7.2) (2024-11-17)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* updated oxc deps ([5989b86](https://github.com/visulima/packem/commit/5989b86dfd589bd3afb8557a8d962b368e077f0b))
|
|
6
|
+
|
|
1
7
|
## @visulima/packem [1.7.1](https://github.com/visulima/packem/compare/@visulima/packem@1.7.0...@visulima/packem@1.7.1) (2024-11-17)
|
|
2
8
|
|
|
3
9
|
### Bug Fixes
|
package/dist/cli.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
|
|
|
5
5
|
const __filename = __cjs_url__.fileURLToPath(import.meta.url);
|
|
6
6
|
const __dirname = __cjs_path__.dirname(__filename);
|
|
7
7
|
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
8
|
-
const yn="@visulima/packem",bn="1.7.
|
|
8
|
+
const yn="@visulima/packem",bn="1.7.1";var wn=Object.defineProperty,kn=g((e,t)=>wn(e,"name",{value:t,configurable:!0}),"t$c");const xi=kn(async(e,t="")=>{let i=t;if(!i){const o=["packem.config.js","packem.config.mjs","packem.config.cjs","packem.config.ts","packem.config.cts","packem.config.mts"];for(const n of o)if(await Be(j(e,n))){i="./"+n;break}}if(!/\.(?:js|mjs|cjs|ts|cts|mts)$/.test(i))throw new Error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts, .cts and .mts extensions are allowed.");return i},"findPackemFile"),yi={less:["less"],lightningcss:["lightningcss"],"node-sass":["node-sass"],postcss:["postcss","postcss-load-config","postcss-modules-extract-imports","postcss-modules-local-by-default","postcss-modules-scope","postcss-modules-values","postcss-value-parser","icss-utils"],sass:["sass"],"sass-embedded":["sass-embedded"],stylus:["stylus"]};var jn=Object.defineProperty,Mt=g((e,t)=>jn(e,"name",{value:t,configurable:!0}),"f$i");const $n=["typedoc","typedoc-plugin-markdown","typedoc-plugin-rename-defaults","@ckeditor/typedoc-plugins"],En=Mt(e=>{e.addCommand({argument:{description:"Add a packem feature to your project",name:"feature",required:!0},description:"Add a optional packem feature to your project",execute:Mt(async({argument:t,logger:i,options:o})=>{const n=pt(),a=E(ni(),o.dir??".");let s;try{s=await xi(a,o.config)}catch{i.error("Could not find a packem config file, please run `packem init` first.");return}const l=await $e(s,{buffer:!1});let c="cjs";l.includes("import")&&(c="esm");const r=new G(l);if(t.includes("typedoc")){if(l.includes("typedoc: typedocBuilder")||l.includes("@visulima/packem/builder/typedoc")){i.warn("Typedoc has already been added to the packem config.");return}c==="cjs"?r.prepend(`const typedocBuilder = require("@visulima/packem/builder/typedoc");
|
|
9
9
|
`):r.prepend(`import typedocBuilder from "@visulima/packem/builder/typedoc";
|
|
10
10
|
`),l.includes("builder: {")?r.replace("builder: {",`builder: {
|
|
11
11
|
typedoc: typedocBuilder,
|
|
@@ -58,7 +58,7 @@ ${l}`),i.info({message:`Generated types for ${J(a).replace(t+"/","")}`,prefix:"d
|
|
|
58
58
|
`),e&&(o+=`const __filename = import.meta.filename; // -- packem CommonJS __filename shim --
|
|
59
59
|
`),t&&(o+=`const __dirname = import.meta.dirname; // -- packem CommonJS __dirname shim --
|
|
60
60
|
`),i&&(o+=`const require = __cjs_mod__.createRequire(import.meta.url);
|
|
61
|
-
`),o},"generateCJSShimNode20_11"),as=Ge((e,t)=>{const i=Y(t.include,t.exclude);return{name:"packem:esm-shim-cjs-syntax",renderChunk(o,n,a){if(a.format==="es"&&i(n.fileName)){let s=os;if(e.engines?.node){const l=fi(e.engines.node);l&&l.major>=20&&l.minor>=11&&(s=ns)}return is(o,s)}return null}}},"esmShimCjsSyntaxPlugin");var ss=Object.defineProperty,rs=g((e,t)=>ss(e,"name",{value:t,configurable:!0}),"m$d");const ls=rs(()=>({name:"packem:fix-dynamic-import-extension",renderChunk(e,t,i){return i.format==="es"||i.format==="cjs"?{code:e.replaceAll(/(import\(.*)(.ts)(['´"`]\))/g,"$1."+(i.format==="es"?"mjs":"cjs")+"$3"),map:null}:null}}),"fixDynamicImportExtension");var ps=Object.defineProperty,cs=g((e,t)=>ps(e,"name",{value:t,configurable:!0}),"a$k");const ds=cs((e,t)=>{const i=e.replace(/^\.\//,""),o=t.replace(/^\.\//,"");if(o.startsWith(i))return e+o.slice(i.length);if(e.endsWith(t))return e;const n=e.split("/"),a=t.split("/");let s=n.length-1,l=a.length-1;for(;s>=0&&l>=0&&n[s]===a[l];)s--,l--;const c=n.slice(0,s).join("/"),r=a.slice(l).join("/");return c+(r?"/"+r:"")},"extendString");var ms=Object.defineProperty,us=g((e,t)=>ms(e,"name",{value:t,configurable:!0}),"s$d");const fs=us((...e)=>{if(e.length===0)return"";if(e.length===1)return M(e[0]);e=e.map(n=>Ae(n));const[t,...i]=e;let o=t.split("/");for(const n of i){const a=n.split("/",o.length);let s=0;for(const l of a)if(l===o[s])s+=1;else{o=o.slice(0,s);break}o=o.slice(0,s)}return o.length<=1&&o[0]===""?`/${o[0]}`:o.join("/")},"lowestCommonAncestor");var gs=Object.defineProperty,nt=g((e,t)=>gs(e,"name",{value:t,configurable:!0}),"m$b");const vs=nt((e,t,i,o,n={})=>{const a=Y(n.include,n.exclude),s={},l=nt((r,p)=>{s[r.replace(ne,"")]=p},"addOutput");async function c(r,p){if(!a(p))return;let m;try{
|
|
61
|
+
`),o},"generateCJSShimNode20_11"),as=Ge((e,t)=>{const i=Y(t.include,t.exclude);return{name:"packem:esm-shim-cjs-syntax",renderChunk(o,n,a){if(a.format==="es"&&i(n.fileName)){let s=os;if(e.engines?.node){const l=fi(e.engines.node);l&&l.major>=20&&l.minor>=11&&(s=ns)}return is(o,s)}return null}}},"esmShimCjsSyntaxPlugin");var ss=Object.defineProperty,rs=g((e,t)=>ss(e,"name",{value:t,configurable:!0}),"m$d");const ls=rs(()=>({name:"packem:fix-dynamic-import-extension",renderChunk(e,t,i){return i.format==="es"||i.format==="cjs"?{code:e.replaceAll(/(import\(.*)(.ts)(['´"`]\))/g,"$1."+(i.format==="es"?"mjs":"cjs")+"$3"),map:null}:null}}),"fixDynamicImportExtension");var ps=Object.defineProperty,cs=g((e,t)=>ps(e,"name",{value:t,configurable:!0}),"a$k");const ds=cs((e,t)=>{const i=e.replace(/^\.\//,""),o=t.replace(/^\.\//,"");if(o.startsWith(i))return e+o.slice(i.length);if(e.endsWith(t))return e;const n=e.split("/"),a=t.split("/");let s=n.length-1,l=a.length-1;for(;s>=0&&l>=0&&n[s]===a[l];)s--,l--;const c=n.slice(0,s).join("/"),r=a.slice(l).join("/");return c+(r?"/"+r:"")},"extendString");var ms=Object.defineProperty,us=g((e,t)=>ms(e,"name",{value:t,configurable:!0}),"s$d");const fs=us((...e)=>{if(e.length===0)return"";if(e.length===1)return M(e[0]);e=e.map(n=>Ae(n));const[t,...i]=e;let o=t.split("/");for(const n of i){const a=n.split("/",o.length);let s=0;for(const l of a)if(l===o[s])s+=1;else{o=o.slice(0,s);break}o=o.slice(0,s)}return o.length<=1&&o[0]===""?`/${o[0]}`:o.join("/")},"lowestCommonAncestor");var gs=Object.defineProperty,nt=g((e,t)=>gs(e,"name",{value:t,configurable:!0}),"m$b");const vs=nt((e,t,i,o,n={})=>{const a=Y(n.include,n.exclude),s={},l=nt((r,p)=>{s[r.replace(ne,"")]=p},"addOutput");async function c(r,p){if(!a(p))return;let m;try{m=(await pn(r,{sourceFilename:p})).program}catch{}if(m){const v=m.body.filter(h=>h.type==="ImportDeclaration"||h.type==="ExportAllDeclaration"||h.type==="ExportNamedDeclaration");for(const h of v){if(!h.source||oe(h.source.value).includes("."))continue;const u=await this.resolve(h.source.value,p);if(!(!u||u.external)&&(u.id.endsWith(".ts")||u.id.endsWith(".cts")||u.id.endsWith(".mts")||u.id.endsWith(".tsx")||u.id.endsWith(".ctsx")||u.id.endsWith(".mtsx"))){const y=u.id.replace(e+"/","");r=r.replaceAll('from "'+h.source.value+'"','from "'+ds(h.source.value,y)+'"')}}}const{errors:d,sourceText:f}=await t(p,r);if(d.length>0){if(n.ignoreErrors){this.warn(d[0]);return}return this.error(d[0])}if(l(p,f),!m)return;const x=m.body.filter(v=>v.type==="ImportDeclaration"?v.importKind==="type"?!0:v.specifiers?.every(h=>h.type==="ImportSpecifier"&&h.importKind==="type"):v.type==="ExportNamedDeclaration"||v.type==="ExportAllDeclaration"?v.exportKind==="type"?!0:v.type==="ExportNamedDeclaration"&&v.specifiers?.every(h=>h.type==="ExportSpecifier"&&h.exportKind==="type"):!1);for await(const v of x){if(!v.source)continue;const h=await this.resolve(v.source.value,p);if(!h)return;const u=h.id;if(a(u)&&!s[u.replace(ne,"")])try{const y=await $e(u);await c.call(this,y,u)}catch{}}}return g(c,"h"),nt(c,"transform"),{name:"packem:isolated-declarations",async renderStart(r,{input:p}){const m=fs(...Array.isArray(p)?p:Object.values(p));typeof r.entryFileNames=="function"&&(r.entryFileNames=r.entryFileNames({name:r.name}));const d=r.entryFileNames.replace(/\.(.)?[jt]sx?$/,(f,x)=>`.d.${x||""}ts`);for await(let[f,x]of Object.entries(s)){if(o&&r.format==="cjs"){const h=ji(x);h!==null&&(x=h.code)}const v=x.includes("from '")?"'":'"';(i===!0||i==="compatible")&&r.format==="cjs"&&this.emitFile({fileName:d.replace("[name]",N(m,f)).replace(".cts",".ts"),source:x.replaceAll(/(from\s)['|"]((.*)\..+|['|"].*)['|"];?/g,(h,u,y,k)=>u+v+(k||y)+".d.ts"+v+";"),type:"asset"}),this.emitFile({fileName:d.replace("[name]",N(m,f)),source:x.replaceAll(/(from\s)['|"]((.*)\..+|['|"].*)['|"];?/g,(h,u,y,k)=>u+v+(k||y)+(r.format==="cjs"?".d.cts":".d.mts")+v+";"),type:"asset"})}},transform:c}},"isolatedDeclarationsPlugin");var hs=Object.defineProperty,xs=g((e,t)=>hs(e,"name",{value:t,configurable:!0}),"n$b");const qt="export default ",Mi=xs(e=>{const t=cn(e);return{...t,name:"packem:json",transform(i,o){const n=t.transform?.call(this,i,o);return n&&typeof n!="string"&&"code"in n&&n.code?.startsWith(qt)&&(n.code=n.code.replace(qt,"module.exports = ")),n}}},"JSONPlugin");var ys=Object.defineProperty,Pe=g((e,t)=>ys(e,"name",{value:t,configurable:!0}),"i$a");class Ti{static{g(this,"WalkerBase")}static{Pe(this,"WalkerBase")}constructor(){this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:Pe(()=>this.should_skip=!0,"skip"),remove:Pe(()=>this.should_remove=!0,"remove"),replace:Pe(t=>this.replacement=t,"replace")}}replace(t,i,o,n){t&&i&&(o!=null?t[i][o]=n:t[i]=n)}remove(t,i,o){t&&i&&(o!=null?t[i].splice(o,1):delete t[i])}}var bs=Object.defineProperty,be=g((e,t)=>bs(e,"name",{value:t,configurable:!0}),"c$g");class ws extends Ti{static{g(this,"SyncWalker")}static{be(this,"SyncWalker")}constructor(t,i){super(),this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:be(()=>this.should_skip=!0,"skip"),remove:be(()=>this.should_remove=!0,"remove"),replace:be(o=>this.replacement=o,"replace")},this.enter=t,this.leave=i}visit(t,i,o,n){if(t){if(this.enter){const s=this.should_skip,l=this.should_remove,c=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.enter.call(this.context,t,i,o,n),this.replacement&&(t=this.replacement,this.replace(i,o,n,t)),this.should_remove&&this.remove(i,o,n);const r=this.should_skip,p=this.should_remove;if(this.should_skip=s,this.should_remove=l,this.replacement=c,r)return t;if(p)return null}let a;for(a in t){const s=t[a];if(s&&typeof s=="object")if(Array.isArray(s)){const l=s;for(let c=0;c<l.length;c+=1){const r=l[c];ut(r)&&(this.visit(r,t,a,c)||c--)}}else ut(s)&&this.visit(s,t,a,null)}if(this.leave){const s=this.replacement,l=this.should_remove;this.replacement=null,this.should_remove=!1,this.leave.call(this.context,t,i,o,n),this.replacement&&(t=this.replacement,this.replace(i,o,n,t)),this.should_remove&&this.remove(i,o,n);const c=this.should_remove;if(this.replacement=s,this.should_remove=l,c)return null}}return t}}function ut(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}g(ut,"n$a");be(ut,"isNode");var ks=Object.defineProperty,we=g((e,t)=>ks(e,"name",{value:t,configurable:!0}),"c$f");class js extends Ti{static{g(this,"AsyncWalker")}static{we(this,"AsyncWalker")}constructor(t,i){super(),this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:we(()=>this.should_skip=!0,"skip"),remove:we(()=>this.should_remove=!0,"remove"),replace:we(o=>this.replacement=o,"replace")},this.enter=t,this.leave=i}async visit(t,i,o,n){if(t){if(this.enter){const s=this.should_skip,l=this.should_remove,c=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,await this.enter.call(this.context,t,i,o,n),this.replacement&&(t=this.replacement,this.replace(i,o,n,t)),this.should_remove&&this.remove(i,o,n);const r=this.should_skip,p=this.should_remove;if(this.should_skip=s,this.should_remove=l,this.replacement=c,r)return t;if(p)return null}let a;for(a in t){const s=t[a];if(s&&typeof s=="object")if(Array.isArray(s)){const l=s;for(let c=0;c<l.length;c+=1){const r=l[c];ft(r)&&(await this.visit(r,t,a,c)||c--)}}else ft(s)&&await this.visit(s,t,a,null)}if(this.leave){const s=this.replacement,l=this.should_remove;this.replacement=null,this.should_remove=!1,await this.leave.call(this.context,t,i,o,n),this.replacement&&(t=this.replacement,this.replace(i,o,n,t)),this.should_remove&&this.remove(i,o,n);const c=this.should_remove;if(this.replacement=s,this.should_remove=l,c)return null}}return t}}function ft(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}g(ft,"a$i");we(ft,"isNode");var $s=Object.defineProperty,Ii=g((e,t)=>$s(e,"name",{value:t,configurable:!0}),"a$h");function wt(e,{enter:t,leave:i}){return new ws(t,i).visit(e,null)}g(wt,"walk");Ii(wt,"walk");async function Es(e,{enter:t,leave:i}){return await new js(t,i).visit(e,null)}g(Es,"asyncWalk");Ii(Es,"asyncWalk");var Ss=Object.defineProperty,Os=g((e,t)=>Ss(e,"name",{value:t,configurable:!0}),"u$9");const Ds=Os(({attributes:e,logger:t})=>{const i=Y([/\.[tj]sx$/],/node_modules/);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(o,n){if(!i(n))return null;let a=null;try{a=this.parse(o,{allowReturnOutsideFunction:!0})}catch(c){return this.warn({code:"PARSE_ERROR",message:`[packem:jsx-remove-attributes]: failed to parse "${n}" and remove the jsx attribute.`}),t.warn(c),null}let s=!1;const l=new G(o);return wt(a,{enter(c){if(c.type==="CallExpression"&&c.callee.type==="Identifier"&&c.callee.name==="jsx"){const r=c.arguments.filter(p=>p.type==="ObjectExpression"&&Array.isArray(p.properties));for(const p of r)for(const m of p.properties)m.type==="Property"&&m.key.type==="Literal"&&m.value.type==="Literal"&&e.includes(m.key.value)&&(l.overwrite(m.start-2,m.end,""),s=!0)}}}),s?{code:l.toString(),map:l.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var Ps=Object.defineProperty,Cs=g((e,t)=>Ps(e,"name",{value:t,configurable:!0}),"r$b");const Ns=Cs((e,t,i)=>{const o=new RegExp(`(<!-- ${t} -->)[\\s\\S]*?(<!-- /${t} -->)`,"g");if(o.test(e))return e.replace(o,`$1
|
|
62
62
|
${i}
|
|
63
63
|
$2`)},"replaceContentWithin");var _s=Object.defineProperty,Ai=g((e,t)=>_s(e,"name",{value:t,configurable:!0}),"d$b");const Ms=Ai(e=>{const t=[],i=[];return e.forEach(o=>{o.startsWith("(")?t.push(o):i.push(o)}),[...i.sort(),...t.sort()]},"sortLicenses"),zi=Ai(({dtsMarker:e,licenseFilePath:t,licenseTemplate:i,logger:o,marker:n,mode:a,packageName:s})=>dn({thirdParty(l){const c=new Set,r=l.sort(({name:m},{name:d})=>(m||0)>(d||0)?1:(d||0)>(m||0)?-1:0).map(({author:m,contributors:d,license:f,licenseText:x,maintainers:v,name:h,repository:u})=>{let y="## "+h+`
|
|
64
64
|
`;f&&(y+=`License: ${f}
|