@visulima/rollup-plugin-dts 1.0.0-alpha.34 → 1.0.0-alpha.35
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/filename.d.ts +1 -1
- package/dist/filename.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/packem_chunks/index.js +1 -1
- package/dist/packem_chunks/resolver.js +1 -1
- package/dist/packem_shared/{createGeneratePlugin-lIEMRZwK.js → createGeneratePlugin-qobkPqWu.js} +1 -1
- package/dist/packem_shared/{filename.d-BqANlmrG.d.ts → filename.d-CMm5yggz.d.ts} +2 -1
- package/dist/packem_shared/generate-B50-mrCC.js +14 -0
- package/dist/packem_shared/{resolveOptions-xvkhsYiy.js → resolveOptions-CH0xNcZj.js} +1 -1
- package/package.json +1 -1
- package/dist/packem_shared/generate-DM3s9XS6.js +0 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
## @visulima/rollup-plugin-dts [1.0.0-alpha.35](https://github.com/visulima/packem/compare/@visulima/rollup-plugin-dts@1.0.0-alpha.34...@visulima/rollup-plugin-dts@1.0.0-alpha.35) (2026-06-16)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
* **rollup-plugin-dts:** sync upstream fixes ([#208](https://github.com/visulima/packem/issues/208)/[#238](https://github.com/visulima/packem/issues/238)/[#254](https://github.com/visulima/packem/issues/254)/[#259](https://github.com/visulima/packem/issues/259)) + js-sibling skip ([190e045](https://github.com/visulima/packem/commit/190e04502f9ed331e230f93e3c318afae1ef0196)), closes [#92](https://github.com/visulima/packem/issues/92)
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
* **rollup-plugin-dts:** build-mode dts sourcemaps and JSDoc .js re-exports ([#255](https://github.com/visulima/packem/issues/255)) ([e34f3da](https://github.com/visulima/packem/commit/e34f3daab981b9319c5884eace871f6f1116cf39))
|
|
10
|
+
* **rollup-plugin-dts:** rewrite inferred re-export specifiers to the imported dependency ([#227](https://github.com/visulima/packem/issues/227)) ([36e5c49](https://github.com/visulima/packem/commit/36e5c49ec4c1b300741b09d3d1757ede7965df09))
|
|
11
|
+
|
|
1
12
|
## @visulima/rollup-plugin-dts [1.0.0-alpha.34](https://github.com/visulima/packem/compare/@visulima/rollup-plugin-dts@1.0.0-alpha.33...@visulima/rollup-plugin-dts@1.0.0-alpha.34) (2026-06-12)
|
|
2
13
|
|
|
3
14
|
### Features
|
package/dist/filename.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { a as RE_CSS, b as RE_DTS, c as RE_DTS_MAP, d as RE_JS, e as RE_JSON, f as RE_NODE_MODULES, g as RE_TS, h as RE_VUE, i as
|
|
1
|
+
export { a as RE_CSS, b as RE_DTS, c as RE_DTS_MAP, d as RE_JS, e as RE_JSON, f as RE_NODE_MODULES, g as RE_TS, h as RE_VUE, i as dtsEntryFileName, j as filenameDtsTo, k as filenameJsToDts, l as filenameToDts, r as replaceTemplateName, m as resolveTemplateFunction } from "./packem_shared/filename.d-CMm5yggz.js";
|
|
2
2
|
import 'estree';
|
package/dist/filename.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var r=Object.defineProperty;var n=(e,s)=>r(e,"name",{value:s,configurable:!0});var m=Object.defineProperty,t=n((e,s)=>m(e,"name",{value:s,configurable:!0}),"t");const l=/\.([cm]?)jsx?$/,o=/\.([cm]?)tsx?$/,c=/\.d\.([cm]?)ts$/,$=/\.d\.([cm]?)ts\.map$/,d=/[\\/]node_modules[\\/]/,f=/\.(?:css|scss|sass|less|styl|stylus)$/,p=/\.vue$/,i=/\.json$/,u=t(e=>e.replace(l,".d.$1ts"),"filenameJsToDts"),_=t(e=>e.replace(p,".vue.ts").replace(o,".d.$1ts").replace(l,".d.$1ts").replace(i,".json.d.ts"),"filenameToDts"),D=t((e,s)=>e.replace(c,`.$1${s}`),"filenameDtsTo"),R=t((e,s)=>typeof e=="function"?e(s):e,"resolveTemplateFunction"),E=t((e,s)=>e.replaceAll("[name]",s),"replaceTemplateName"),S=t((e,s,a)=>{if(c.test(e))return E(e,a?s.slice(0,-2):s);if(l.test(e))return a&&e.includes("[name]")?e.replace(l,".$1ts"):u(e)},"dtsEntryFileName");export{f as RE_CSS,c as RE_DTS,$ as RE_DTS_MAP,l as RE_JS,i as RE_JSON,d as RE_NODE_MODULES,o as RE_TS,p as RE_VUE,S as dtsEntryFileName,D as filenameDtsTo,u as filenameJsToDts,_ as filenameToDts,E as replaceTemplateName,R as resolveTemplateFunction};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as RenderedChunk, P as Plugin } from "./packem_shared/filename.d-
|
|
2
|
-
export { a as RE_CSS, b as RE_DTS, c as RE_DTS_MAP, d as RE_JS, e as RE_JSON, f as RE_NODE_MODULES, g as RE_TS, h as RE_VUE } from "./packem_shared/filename.d-
|
|
1
|
+
import { R as RenderedChunk, P as Plugin } from "./packem_shared/filename.d-CMm5yggz.js";
|
|
2
|
+
export { a as RE_CSS, b as RE_DTS, c as RE_DTS_MAP, d as RE_JS, e as RE_JSON, f as RE_NODE_MODULES, g as RE_TS, h as RE_VUE } from "./packem_shared/filename.d-CMm5yggz.js";
|
|
3
3
|
import { TsConfigJson } from '@visulima/tsconfig';
|
|
4
4
|
import { IsolatedDeclarationsOptions } from 'oxc-transform';
|
|
5
5
|
import 'estree';
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
2
|
-
`)}if(
|
|
3
|
-
${
|
|
1
|
+
var I=Object.defineProperty;var p=(e,t)=>I(e,"name",{value:t,configurable:!0});import{createDebug as C}from"obug";import A from"magic-string";import{RE_DTS as m,resolveTemplateFunction as M,replaceTemplateName as _,RE_TS as W,RE_VUE as q,RE_JSON as z,RE_JS as $,RE_NODE_MODULES as R,RE_CSS as B,filenameToDts as F,filenameJsToDts as U}from"./filename.js";import{RE_DTS_MAP as be}from"./filename.js";import G from"./packem_shared/createFakeJsPlugin-DeA0eOgM.js";import{c as L}from"./packem_shared/generate-B50-mrCC.js";import{resolveOptions as V}from"./packem_shared/resolveOptions-CH0xNcZj.js";import{existsSync as k,readFileSync as H}from"node:fs";import h from"node:path";import{ResolverFactory as K}from"oxc-resolver";var Q=Object.defineProperty,X=p((e,t)=>Q(e,"name",{value:t,configurable:!0}),"o$2");const Y=X(({banner:e,footer:t})=>({name:"rollup-plugin-dts:banner",async renderChunk(n,o){if(!m.test(o.fileName))return;const l=new A(n);if(e){const a=await(typeof e=="function"?e(o):e);a&&l.prepend(`${a}
|
|
2
|
+
`)}if(t){const a=await(typeof t=="function"?t(o):t);a&&l.append(`
|
|
3
|
+
${a}`)}return{code:l.toString(),get map(){return l.generateMap({hires:"boundary",includeContent:!0,source:o.fileName})}}}}),"createBannerPlugin");var Z=Object.defineProperty,ee=p((e,t)=>Z(e,"name",{value:t,configurable:!0}),"o$1");const te=ee(({entry:e,sideEffects:t})=>({buildStart(){e&&this.warn("The `entry` option has no effect in `dtsInput` mode; control which declaration files are emitted via the plugin's input list instead.")},name:"rollup-plugin-dts:dts-input",options:t?void 0:n=>({...n,treeshake:n.treeshake===!1?!1:{...typeof n.treeshake=="object"?n.treeshake:{},moduleSideEffects:!1}}),outputOptions(n){return{...n,entryFileNames(o){const{entryFileNames:l}=n;if(l){const a=M(l,o),w=_(a,o.name);if(m.test(w))return a;const g=_(a,`${o.name}.d`);if(m.test(g))return g}return m.test(o.name)?o.name:o.name.endsWith(".d")?"[name].ts":"[name].d.ts"}}}}),"createDtsInputPlugin");var ne=Object.defineProperty,y=p((e,t)=>ne(e,"name",{value:t,configurable:!0}),"f");const b=y(e=>W.test(e)||q.test(e)||z.test(e),"isSourceFile"),re=y(({cwd:e,emitJs:t,resolve:n,resolver:o,sideEffects:l,tsconfig:a,tsconfigRaw:w})=>{const g=y(r=>t&&$.test(r)&&!R.test(r),"isRedirectableJs"),T=new K({conditionNames:["types","typings","import","require"],mainFields:["types","typings","module","main"],tsconfig:a?{configFile:a,references:"auto"}:void 0}),S=l?!0:null;return{name:"rollup-plugin-dts:resolver",resolveId:{async handler(r,s,c){if(!s||!m.test(s))return;const i={external:!0,id:r,moduleSideEffects:l};if(B.test(r))return i;if(!v(r)&&x(r)){const f=await D(r,s,null);if(f&&m.test(f))return{id:f,moduleSideEffects:S};if(f&&b(f))return await this.load({id:f}),{id:F(f),moduleSideEffects:S};this.warn(`Could not resolve declaration (.d.ts) types for "${r}" (requested via the \`resolve\` option, imported from ${s}); it will be left external. Ensure the package ships types or provides a \`types\` condition in its exports.`)}const u=await this.resolve(r,s,c);if(u?.external)return i;const d=await D(r,s,u);return d?R.test(d)&&!x(r)&&!(v(r)&&R.test(s)&&J(s))?i:m.test(d)?{id:d,moduleSideEffects:S}:b(d)||g(d)?(await this.load({id:d}),{id:F(d),moduleSideEffects:S}):null:(v(r)||this.warn(`Could not resolve declaration (.d.ts) types for bare specifier "${r}" (imported from ${s}); leaving it external.`),v(r)?null:i)},order:"pre"}};function x(r){return typeof n=="boolean"?n:n.some(s=>typeof s=="string"?r===s:s.test(r))}function J(r){const s=r.replaceAll("\\","/"),c="/node_modules/",i=s.lastIndexOf(c);if(i===-1)return!1;const u=s.slice(i+c.length),d=u.indexOf("/");let f=d===-1?u:u.slice(0,d);if(f.startsWith("@")){const O=u.slice(f.length+1),P=O.indexOf("/"),j=P===-1?O:O.slice(0,P);f=`${f}/${j}`}return x(f)}async function D(r,s,c){let i;if(o==="tsc"){const{default:u}=await import("./packem_chunks/resolver.js");i=u(r,s,e,a,w)}else i=T.resolveDtsSync(s,r).path;if(i&&(i=h.normalize(i)),i&&$.test(i)&&ie(i)){const u=U(i);if(k(u))return u}return!i||!(b(i)||g(i))?c&&v(c.id)&&(b(c.id)||g(c.id))&&!c.external?c.id:null:i}},"createDtsResolvePlugin"),v=y(e=>e.startsWith(".")||h.isAbsolute(e),"isFilePath"),E=new Map,ie=y(e=>{const t=h.dirname(e);if(E.has(t))return E.get(t);let n=t;for(;n!==h.dirname(n);){const o=h.join(n,"package.json");if(k(o)){let l=!1;try{const{exports:a}=JSON.parse(H(o,"utf8"));l=a===void 0||typeof a=="string"}catch{}return E.set(t,l),l}n=h.dirname(n)}return E.set(t,!1),!1},"canFallBackToSiblingDts");var se=Object.defineProperty,oe=p((e,t)=>se(e,"name",{value:t,configurable:!0}),"o");const N=C("rollup-plugin-dts:options"),ve=oe((e={})=>{N("resolving dts options");const t=V(e);N("resolved dts options %o",t);const n=[];return e.dtsInput?n.push(te(t)):n.push(L(t)),n.push(re(t),G(t)),(e.banner||e.footer)&&n.push(Y(t)),n},"dts");export{B as RE_CSS,m as RE_DTS,be as RE_DTS_MAP,$ as RE_JS,z as RE_JSON,R as RE_NODE_MODULES,W as RE_TS,q as RE_VUE,G as createFakeJsPlugin,L as createGeneratePlugin,ve as dts,V as resolveOptions};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var U=Object.defineProperty;var h=(e,t)=>U(e,"name",{value:t,configurable:!0});import{createDebug as P}from"obug";import c from"typescript";import{g as x}from"../packem_shared/generate-DM3s9XS6.js";import{posix as F}from"node:path";import{pathToFileURL as S}from"node:url";import{dirname as B}from"@visulima/path";var J=Object.defineProperty,$=h((e,t)=>J(e,"name",{value:t,configurable:!0}),"c$1");const W=P("rollup-plugin-dts:tsc-system"),j=$(e=>{const t=e.replaceAll("\\","/"),o=[];let s=t.slice(0,Math.max(0,t.lastIndexOf("/")));for(;s.includes("/");)o.push(s),s=s.slice(0,s.lastIndexOf("/"));return s&&o.push(s),o},"ancestorDirectories"),M=$((e,t)=>{const o=new Set;for(const r of e.keys())for(const i of j(r))o.add(i);const s=$(r=>{for(const i of j(r))o.add(i)},"trackDirectories");return{...c.sys,deleteFile(r,...i){e.delete(r),t&&c.sys.deleteFile?.(r,...i)},directoryExists(r){return o.has(r.replaceAll("\\","/"))?!0:c.sys.directoryExists(r)},fileExists(r){return e.has(r)?!0:c.sys.fileExists(r)},readFile(r,...i){return e.has(r)?e.get(r):c.sys.readFile(r,...i)},resolvePath(r){return e.has(r)?r:c.sys.resolvePath(r)},write(r){W(r)},writeFile(r,i,...a){e.set(r,i),s(r),t&&c.sys.writeFile(r,i,...a)}}},"createSystem"),R=$(e=>M(e,!0),"createFsSystem"),A=$(e=>M(e,!1),"createMemorySystem");var H=Object.defineProperty,b=h((e,t)=>H(e,"name",{value:t,configurable:!0}),"o$1");const I=b(e=>{const t=b(o=>c.isPropertySignature(o)&&c.isPrivateIdentifier(o.name)?e.factory.updatePropertySignature(o,o.modifiers,e.factory.createStringLiteral(o.name.text),o.questionToken,o.type):c.visitEachChild(o,t,e),"visitor");return o=>c.visitNode(o,t,c.isSourceFile)},"stripPrivateFields"),D={getCanonicalFileName:c.sys.useCaseSensitiveFileNames?e=>e:e=>e.toLowerCase(),getCurrentDirectory:b(()=>c.sys.getCurrentDirectory(),"getCurrentDirectory"),getNewLine:b(()=>c.sys.newLine,"getNewLine")},k={afterDeclarations:[I]},L=b((e,t,o)=>{if(!e||e.sourceRoot)return;const s=F.dirname(S(t).pathname),r=F.dirname(S(o).pathname);s!==r&&(e.sourceRoot=F.relative(r,s))},"setSourceMapRoot");var G=Object.defineProperty,m=h((e,t)=>G(e,"name",{value:t,configurable:!0}),"f$1");const g=P("rollup-plugin-dts:tsc-build"),V=m((e,t,o,s,r)=>{let i=e.projects.get(o);return i?(g(`skip building projects for ${o}`),i):(i=K(t,o,s,r),e.projects.set(o,i),i)},"getOrBuildProjects"),K=m((e,t,o,s)=>{g(`start building projects for ${t}`);const r=Y(t,e,o,s);g("collected %d projects: %j",r.length,r.map(l=>l.tsconfigPath));const i=c.createSolutionBuilderHost(e,Q),a=c.createSolutionBuilder(i,[t],{force:o,verbose:!0}).build(void 0,void 0,void 0,l=>(g(`transforming project ${l}`),k));g(`built solution for ${t} with exit status ${a}`);const n=new Map;for(const l of r)for(const u of l.parsedConfig.fileNames)n.set(e.resolvePath(u),l);return n},"buildProjects"),Y=m((e,t,o,s)=>{const r=new Set,i=[],a=[t.resolvePath(e)];for(;;){const n=a.pop();if(!n)break;if(r.has(n))continue;r.add(n);const l=z(n,t);if(l){l.options=q(l.options,{force:o,sourcemap:s,tsconfigPath:n}),i.push({parsedConfig:l,tsconfigPath:n});for(const u of l.projectReferences??[])a.push(c.resolveProjectReferencePath(u))}}return i},"collectProjectGraph"),z=m((e,t)=>{const o=[],s=c.getParsedCommandLineOfConfigFile(e,void 0,{...t,onUnRecoverableConfigFileDiagnostic:m(r=>{o.push(r)},"onUnRecoverableConfigFileDiagnostic")});if(o.length>0)throw new Error(`[rollup-plugin-dts] Unable to read ${e}: ${c.formatDiagnostics(o,D)}`);return s},"parseTsconfig"),q=m((e,t)=>{const o=e.noEmit??!1,s=e.declaration??!!e.composite,r=e.declarationMap??!1,i=t?.tsconfigPath&&!t.force;return o&&(e={...e,noEmit:!1},i&&console.warn(`[rollup-plugin-dts] ${t.tsconfigPath} has "noEmit" set to true. Please set it to false to generate declaration files.`)),s||(e={...e,declaration:!0},i&&console.warn(`[rollup-plugin-dts] ${t.tsconfigPath} has "declaration" set to false. Please set it to true to generate declaration files.`)),!r&&t?.sourcemap&&(e={...e,declarationMap:!0},i&&console.warn(`[rollup-plugin-dts] ${t.tsconfigPath} has "declarationMap" set to false. Please set it to true if you want to generate source maps for declaration files.`)),e},"patchCompilerOptions"),Q=m((e,t,...o)=>c.createEmitAndSemanticDiagnosticsBuilderProgram(e,q(t??{},null),...o),"createProgramWithPatchedCompilerOptions"),N=m(e=>{const{context:t=x,id:o,incremental:s,sourcemap:r,tsconfig:i}=e;if(g(`running tscEmitBuild id: ${o}, tsconfig: ${i}, incremental: ${s}`),!i)return{error:"[rollup-plugin-dts] build mode requires a tsconfig path"};const a=(s?R:A)(t.files),n=a.resolvePath(o);n!==o&&g(`resolved id from ${o} to ${n}`);const l=V(t,a,i,!s,r).get(n);if(!l)return g(`unable to locate a project containing ${n}`),{error:`Unable to locate ${o} from the given tsconfig file ${i}`};g(`loaded project ${l.tsconfigPath} for ${o}`);const u=!a.useCaseSensitiveFileNames,f=c.getOutputFileNames(l.parsedConfig,n,u);let v,y;for(const d of f){if(d.endsWith(".d.ts")){if(!a.fileExists(d)){console.warn(`[rollup-plugin-dts] Unable to read file ${d}`);continue}v=a.readFile(d);continue}if(d.endsWith(".d.ts.map")){if(!a.fileExists(d))continue;const E=a.readFile(d);if(!E){console.warn(`[rollup-plugin-dts] Unexpected sourcemap ${d}`);continue}y=JSON.parse(E),L(y,d,n)}}return v?{code:v,map:y}:s?(g("incremental build failed"),N({...e,incremental:!1})):(g(`unable to build .d.ts file for ${o}`),l.parsedConfig.options.declaration!==!0?{error:`Unable to build .d.ts file for ${o}; Make sure the "declaration" option is set to true in ${l.tsconfigPath}`}:{error:`Unable to build .d.ts file for ${o}; This seems like a bug of rollup-plugin-dts. Please report this issue to https://github.com/visulima/packem/issues`})},"tscEmitBuild");var X=Object.defineProperty,C=h((e,t)=>X(e,"name",{value:t,configurable:!0}),"g");const Z=C(()=>{const e=P("rollup-plugin-dts:vue");e("loading vue language tools");try{const t=require.resolve("vue-tsc"),{proxyCreateProgram:o}=require(require.resolve("@volar/typescript",{paths:[t]})),s=require(require.resolve("@vue/language-core",{paths:[t]}));return{getLanguagePlugin:C((r,i)=>{const a=i.options.$rootDir,n=i.options.$configRaw,l=new s.CompilerOptionsResolver(r,r.sys.readFile);l.addConfig(n?.vueCompilerOptions??{},a);const u=l.build();return s.createVueLanguagePlugin(r,i.options,u,f=>f)},"getLanguagePlugin"),proxyCreateProgram:o}}catch(t){throw e("vue language tools not found",t),new Error("Failed to load vue language tools. Please manually install vue-tsc.")}},"loadVueLanguageTools"),_=C(()=>{const e=P("rollup-plugin-dts:ts-macro");e("loading ts-macro language tools");try{const t=require.resolve("@ts-macro/tsc"),{proxyCreateProgram:o}=require(require.resolve("@volar/typescript",{paths:[t]})),s=require(require.resolve("@ts-macro/language-plugin",{paths:[t]})),{getOptions:r}=require(require.resolve("@ts-macro/language-plugin/options",{paths:[t]}));return{getLanguagePlugin:C((i,a)=>{const n=a.options.$rootDir;return s.getLanguagePlugins(i,a.options,r(i,n))[0]},"getLanguagePlugin"),proxyCreateProgram:o}}catch(t){throw e("ts-macro language tools not found",t),new Error("Failed to load ts-macro language tools. Please manually install @ts-macro/tsc.")}},"loadTsMacro"),ee=C((e,t)=>{const o=t.vue?Z():void 0,s=t.tsMacro?_():void 0,r=o?.proxyCreateProgram||s?.proxyCreateProgram;return r?r(e,e.createProgram,(i,a)=>{const n=[];return o&&n.push(o.getLanguagePlugin(i,a)),s&&n.push(s.getLanguagePlugin(i,a)),{languagePlugins:n}}):e.createProgram},"createProgramFactory");var te=Object.defineProperty,w=h((e,t)=>te(e,"name",{value:t,configurable:!0}),"u");const p=P("rollup-plugin-dts:tsc-compiler"),re={checkJs:!1,declaration:!0,declarationMap:!1,emitDeclarationOnly:!0,moduleResolution:c.ModuleResolutionKind.Bundler,noEmit:!1,noEmitOnError:!0,resolveJsonModule:!0,skipLibCheck:!0,target:99},oe=w(({baseDirectory:e,entries:t,fsSystem:o,id:s,parsedConfig:r,tsMacro:i,vue:a})=>{const n={...re,...r.options,$configRaw:r.raw,$rootDir:e},l=[...new Set([s,...t??r.fileNames].map(y=>o.resolvePath(y)))],u=c.createCompilerHost(n,!0),f=ee(c,{tsMacro:i,vue:a})({host:u,options:n,projectReferences:r.projectReferences,rootNames:l}),v=f.getSourceFile(s);if(!v)throw p(`source file not found in program: ${s}`),r.projectReferences?.length?new Error(`[rollup-plugin-dts] Unable to load ${s}; You have "references" in your tsconfig file. Perhaps you want to add \`dts: { build: true }\` in your config?`):o.fileExists(s)?(p(`File ${s} exists on disk.`),new Error(`Unable to load file ${s} from the program. This seems like a bug of rollup-plugin-dts. Please report this issue to https://github.com/visulima/packem/issues`)):(p(`File ${s} does not exist on disk.`),new Error(`Source file not found: ${s}`));return{file:v,program:f}},"createTsProgramFromParsedConfig"),se=w(({context:e=x,cwd:t,entries:o,id:s,tsconfig:r,tsconfigRaw:i,tsMacro:a,vue:n})=>{const l=R(e.files),u=r?B(r):t,f=c.parseJsonConfigFileContent(i,l,u);return p(`Creating program for root project: ${u}`),oe({baseDirectory:u,entries:o,fsSystem:l,id:s,parsedConfig:f,tsMacro:a,vue:n})},"createTsProgram"),O=new WeakMap,ie=w(e=>{let t=O.get(e);return t||(t=new Set(e.getRootFileNames()),O.set(e,t)),t},"getProgramRoots"),ae=w(e=>{const{context:t=x,entries:o,id:s}=e,r=t.programs.find(a=>{const n=ie(a);return o?o.every(l=>n.has(l)):n.has(s)});if(r){const a=r.getSourceFile(s);if(a)return{file:a,program:r}}p(`create program for module: ${s}`);const i=se(e);return p(`created program for module: ${s}`),t.programs.push(i.program),i},"createOrGetTsModule"),ne=w(e=>{p(`running tscEmitCompiler ${e.id}`);const t=ae(e),{file:o,program:s}=t;p(`got source file: ${o.fileName}`);let r,i;const{diagnostics:a,emitSkipped:n}=s.emit(o,(l,u)=>{l.endsWith(".map")?(p(`emit dts sourcemap: ${l}`),i=JSON.parse(u),L(i,l,e.id)):(p(`emit dts: ${l}`),r=u)},void 0,!0,k,!0);return n&&a.length>0?{error:c.formatDiagnostics(a,D)}:(!r&&o.isDeclarationFile&&(p("nothing was emitted. fallback to sourceFile text."),r=o.getFullText()),{code:r,map:i})},"tscEmitCompiler");var le=Object.defineProperty,ce=h((e,t)=>le(e,"name",{value:t,configurable:!0}),"r");const T=P("rollup-plugin-dts:tsc");T(`loaded typescript: ${c.version}`);const ve=ce(e=>(T(`running tscEmit ${e.id}`),e.build?N(e):ne(e)),"tscEmit");export{ve as tscEmit};
|
|
1
|
+
var U=Object.defineProperty;var h=(e,t)=>U(e,"name",{value:t,configurable:!0});import{createDebug as y}from"obug";import c from"typescript";import{g as x}from"../packem_shared/generate-B50-mrCC.js";import{posix as F}from"node:path";import{pathToFileURL as E}from"node:url";import{dirname as B}from"@visulima/path";var J=Object.defineProperty,$=h((e,t)=>J(e,"name",{value:t,configurable:!0}),"c$1");const W=y("rollup-plugin-dts:tsc-system"),j=$(e=>{const t=e.replaceAll("\\","/"),o=[];let s=t.slice(0,Math.max(0,t.lastIndexOf("/")));for(;s.includes("/");)o.push(s),s=s.slice(0,s.lastIndexOf("/"));return s&&o.push(s),o},"ancestorDirectories"),M=$((e,t)=>{const o=new Set;for(const r of e.keys())for(const i of j(r))o.add(i);const s=$(r=>{for(const i of j(r))o.add(i)},"trackDirectories");return{...c.sys,deleteFile(r,...i){e.delete(r),t&&c.sys.deleteFile?.(r,...i)},directoryExists(r){return o.has(r.replaceAll("\\","/"))?!0:c.sys.directoryExists(r)},fileExists(r){return e.has(r)?!0:c.sys.fileExists(r)},readFile(r,...i){return e.has(r)?e.get(r):c.sys.readFile(r,...i)},resolvePath(r){return e.has(r)?r:c.sys.resolvePath(r)},write(r){W(r)},writeFile(r,i,...l){e.set(r,i),s(r),t&&c.sys.writeFile(r,i,...l)}}},"createSystem"),O=$(e=>M(e,!0),"createFsSystem"),A=$(e=>M(e,!1),"createMemorySystem");var H=Object.defineProperty,b=h((e,t)=>H(e,"name",{value:t,configurable:!0}),"o$1");const I=b(e=>{const t=b(o=>c.isPropertySignature(o)&&c.isPrivateIdentifier(o.name)?e.factory.updatePropertySignature(o,o.modifiers,e.factory.createStringLiteral(o.name.text),o.questionToken,o.type):c.visitEachChild(o,t,void 0),"visitor");return o=>c.visitNode(o,t,c.isSourceFile)},"stripPrivateFields"),R={getCanonicalFileName:c.sys.useCaseSensitiveFileNames?e=>e:e=>e.toLowerCase(),getCurrentDirectory:b(()=>c.sys.getCurrentDirectory(),"getCurrentDirectory"),getNewLine:b(()=>c.sys.newLine,"getNewLine")},k={afterDeclarations:[I]},L=b((e,t,o)=>{if(!e||e.sourceRoot)return;const s=F.dirname(E(t).pathname),r=F.dirname(E(o).pathname);s!==r&&(e.sourceRoot=F.relative(r,s))},"setSourceMapRoot");var G=Object.defineProperty,m=h((e,t)=>G(e,"name",{value:t,configurable:!0}),"d");const g=y("rollup-plugin-dts:tsc-build"),V=m((e,t,o,s,r)=>{let i=e.projects.get(o);return i?(g(`skip building projects for ${o}`),i):(i=K(t,o,s,r),e.projects.set(o,i),i)},"getOrBuildProjects"),K=m((e,t,o,s)=>{g(`start building projects for ${t}`);const r=Y(t,e,o,s);g("collected %d projects: %j",r.length,r.map(a=>a.tsconfigPath));const i=c.createSolutionBuilderHost(e,Q(s)),l=c.createSolutionBuilder(i,[t],{force:o,verbose:!0}).build(void 0,void 0,void 0,a=>(g(`transforming project ${a}`),k));g(`built solution for ${t} with exit status ${l}`);const n=new Map;for(const a of r)for(const u of a.parsedConfig.fileNames)n.set(e.resolvePath(u),a);return n},"buildProjects"),Y=m((e,t,o,s)=>{const r=new Set,i=[],l=[t.resolvePath(e)];for(;;){const n=l.pop();if(!n)break;if(r.has(n))continue;r.add(n);const a=z(n,t);if(a){a.options=q(a.options,{force:o,sourcemap:s,tsconfigPath:n}),i.push({parsedConfig:a,tsconfigPath:n});for(const u of a.projectReferences??[])l.push(c.resolveProjectReferencePath(u))}}return i},"collectProjectGraph"),z=m((e,t)=>{const o=[],s=c.getParsedCommandLineOfConfigFile(e,void 0,{...t,onUnRecoverableConfigFileDiagnostic:m(r=>{o.push(r)},"onUnRecoverableConfigFileDiagnostic")});if(o.length>0)throw new Error(`[rollup-plugin-dts] Unable to read ${e}: ${c.formatDiagnostics(o,R)}`);return s},"parseTsconfig"),q=m((e,t)=>{const o=e.noEmit??!1,s=e.declaration??!!e.composite,r=e.declarationMap??!1,i=t?.tsconfigPath&&!t.force;return o&&(e={...e,noEmit:!1},i&&console.warn(`[rollup-plugin-dts] ${t.tsconfigPath} has "noEmit" set to true. Please set it to false to generate declaration files.`)),s||(e={...e,declaration:!0},i&&console.warn(`[rollup-plugin-dts] ${t.tsconfigPath} has "declaration" set to false. Please set it to true to generate declaration files.`)),!r&&t?.sourcemap&&(e={...e,declarationMap:!0},i&&console.warn(`[rollup-plugin-dts] ${t.tsconfigPath} has "declarationMap" set to false. Please set it to true if you want to generate source maps for declaration files.`)),e},"patchCompilerOptions"),Q=m(e=>(t,o,...s)=>c.createEmitAndSemanticDiagnosticsBuilderProgram(t,q(o??{},{force:!0,sourcemap:e,tsconfigPath:""}),...s),"createProgramFactory"),N=m(e=>{const{context:t=x,id:o,incremental:s,sourcemap:r,tsconfig:i}=e;if(g(`running tscEmitBuild id: ${o}, tsconfig: ${i}, incremental: ${s}`),!i)return{error:"[rollup-plugin-dts] build mode requires a tsconfig path"};const l=(s?O:A)(t.files),n=l.resolvePath(o);n!==o&&g(`resolved id from ${o} to ${n}`);const a=V(t,l,i,!s,r).get(n);if(!a)return g(`unable to locate a project containing ${n}`),{error:`Unable to locate ${o} from the given tsconfig file ${i}`};g(`loaded project ${a.tsconfigPath} for ${o}`);const u=!l.useCaseSensitiveFileNames,f=c.getOutputFileNames(a.parsedConfig,n,u);let v,P;for(const d of f){if(d.endsWith(".d.ts")){if(!l.fileExists(d)){console.warn(`[rollup-plugin-dts] Unable to read file ${d}`);continue}v=l.readFile(d);continue}if(d.endsWith(".d.ts.map")){if(!l.fileExists(d))continue;const S=l.readFile(d);if(!S){console.warn(`[rollup-plugin-dts] Unexpected sourcemap ${d}`);continue}P=JSON.parse(S),L(P,d,n)}}return v?{code:v,map:P}:s?(g("incremental build failed"),N({...e,incremental:!1})):(g(`unable to build .d.ts file for ${o}`),a.parsedConfig.options.declaration!==!0?{error:`Unable to build .d.ts file for ${o}; Make sure the "declaration" option is set to true in ${a.tsconfigPath}`}:{error:`Unable to build .d.ts file for ${o}; This seems like a bug of rollup-plugin-dts. Please report this issue to https://github.com/visulima/packem/issues`})},"tscEmitBuild");var X=Object.defineProperty,w=h((e,t)=>X(e,"name",{value:t,configurable:!0}),"g");const Z=w(()=>{const e=y("rollup-plugin-dts:vue");e("loading vue language tools");try{const t=require.resolve("vue-tsc"),{proxyCreateProgram:o}=require(require.resolve("@volar/typescript",{paths:[t]})),s=require(require.resolve("@vue/language-core",{paths:[t]}));return{getLanguagePlugin:w((r,i)=>{const l=i.options.$rootDir,n=i.options.$configRaw,a=new s.CompilerOptionsResolver(r,r.sys.readFile);a.addConfig(n?.vueCompilerOptions??{},l);const u=a.build();return s.createVueLanguagePlugin(r,i.options,u,f=>f)},"getLanguagePlugin"),proxyCreateProgram:o}}catch(t){throw e("vue language tools not found",t),new Error("Failed to load vue language tools. Please manually install vue-tsc.")}},"loadVueLanguageTools"),_=w(()=>{const e=y("rollup-plugin-dts:ts-macro");e("loading ts-macro language tools");try{const t=require.resolve("@ts-macro/tsc"),{proxyCreateProgram:o}=require(require.resolve("@volar/typescript",{paths:[t]})),s=require(require.resolve("@ts-macro/language-plugin",{paths:[t]})),{getOptions:r}=require(require.resolve("@ts-macro/language-plugin/options",{paths:[t]}));return{getLanguagePlugin:w((i,l)=>{const n=l.options.$rootDir;return s.getLanguagePlugins(i,l.options,r(i,n))[0]},"getLanguagePlugin"),proxyCreateProgram:o}}catch(t){throw e("ts-macro language tools not found",t),new Error("Failed to load ts-macro language tools. Please manually install @ts-macro/tsc.")}},"loadTsMacro"),ee=w((e,t)=>{const o=t.vue?Z():void 0,s=t.tsMacro?_():void 0,r=o?.proxyCreateProgram||s?.proxyCreateProgram;return r?r(e,e.createProgram,(i,l)=>{const n=[];return o&&n.push(o.getLanguagePlugin(i,l)),s&&n.push(s.getLanguagePlugin(i,l)),{languagePlugins:n}}):e.createProgram},"createProgramFactory");var te=Object.defineProperty,C=h((e,t)=>te(e,"name",{value:t,configurable:!0}),"u");const p=y("rollup-plugin-dts:tsc-compiler"),re={checkJs:!1,declaration:!0,declarationMap:!1,emitDeclarationOnly:!0,moduleResolution:c.ModuleResolutionKind.Bundler,noEmit:!1,noEmitOnError:!0,resolveJsonModule:!0,skipLibCheck:!0,target:99},oe=C(({baseDirectory:e,entries:t,fsSystem:o,id:s,parsedConfig:r,tsMacro:i,vue:l})=>{const n={...re,...r.options,$configRaw:r.raw,$rootDir:e,declaration:!0,emitDeclarationOnly:!0},a=[...new Set([s,...t??r.fileNames].map(P=>o.resolvePath(P)))],u=c.createCompilerHost(n,!0),f=ee(c,{tsMacro:i,vue:l})({host:u,options:n,projectReferences:r.projectReferences,rootNames:a}),v=f.getSourceFile(s);if(!v)throw p(`source file not found in program: ${s}`),r.projectReferences?.length?new Error(`[rollup-plugin-dts] Unable to load ${s}; You have "references" in your tsconfig file. Perhaps you want to add \`dts: { build: true }\` in your config?`):o.fileExists(s)?(p(`File ${s} exists on disk.`),new Error(`Unable to load file ${s} from the program. This seems like a bug of rollup-plugin-dts. Please report this issue to https://github.com/visulima/packem/issues`)):(p(`File ${s} does not exist on disk.`),new Error(`Source file not found: ${s}`));return{file:v,program:f}},"createTsProgramFromParsedConfig"),se=C(({context:e=x,cwd:t,entries:o,id:s,tsconfig:r,tsconfigRaw:i,tsMacro:l,vue:n})=>{const a=O(e.files),u=r?B(r):t,f=c.parseJsonConfigFileContent(i,a,u);return p(`Creating program for root project: ${u}`),oe({baseDirectory:u,entries:o,fsSystem:a,id:s,parsedConfig:f,tsMacro:l,vue:n})},"createTsProgram"),D=new WeakMap,ie=C(e=>{let t=D.get(e);return t||(t=new Set(e.getRootFileNames()),D.set(e,t)),t},"getProgramRoots"),ae=C(e=>{const{context:t=x,entries:o,id:s}=e,r=t.programs.find(l=>{const n=ie(l);return o?o.every(a=>n.has(a)):n.has(s)});if(r){const l=r.getSourceFile(s);if(l)return{file:l,program:r}}p(`create program for module: ${s}`);const i=se(e);return p(`created program for module: ${s}`),t.programs.push(i.program),i},"createOrGetTsModule"),ne=C(e=>{p(`running tscEmitCompiler ${e.id}`);const t=ae(e),{file:o,program:s}=t;p(`got source file: ${o.fileName}`);let r,i;const{diagnostics:l,emitSkipped:n}=s.emit(o,(a,u)=>{a.endsWith(".map")?(p(`emit dts sourcemap: ${a}`),i=JSON.parse(u),L(i,a,e.id)):(p(`emit dts: ${a}`),r=u)},void 0,!0,k,!0);if(n){const a=l.filter(u=>u.category===c.DiagnosticCategory.Error);if(a.length>0)return{error:c.formatDiagnostics(a,R)}}return!r&&o.isDeclarationFile&&(p("nothing was emitted. fallback to sourceFile text."),r=o.getFullText()),{code:r,map:i}},"tscEmitCompiler");var le=Object.defineProperty,ce=h((e,t)=>le(e,"name",{value:t,configurable:!0}),"r");const T=y("rollup-plugin-dts:tsc");T(`loaded typescript: ${c.version}`);const ve=ce(e=>(T(`running tscEmit ${e.id}`),e.build?N(e):ne(e)),"tscEmit");export{ve as tscEmit};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var v=Object.defineProperty;var n=(e,o)=>v(e,"name",{value:o,configurable:!0});import g from"node:path";import{createDebug as m}from"obug";import s from"typescript";var c=Object.defineProperty,a=n((e,o)=>c(e,"name",{value:o,configurable:!0}),"r");const C=m("rollup-plugin-dts:tsc-resolver"),i=new WeakMap,b=a((e,o)=>{if(typeof e!="object"||e===null)return s.parseJsonConfigFileContent(e,s.sys,o);let r=i.get(e);r||(r=new Map,i.set(e,r));let t=r.get(o);return t||(t=s.parseJsonConfigFileContent(e,s.sys,o),r.set(o,t)),t},"getParsedConfig"),w=a((e,o,r,t,d,
|
|
1
|
+
var v=Object.defineProperty;var n=(e,o)=>v(e,"name",{value:o,configurable:!0});import g from"node:path";import{createDebug as m}from"obug";import s from"typescript";var c=Object.defineProperty,a=n((e,o)=>c(e,"name",{value:o,configurable:!0}),"r");const C=m("rollup-plugin-dts:tsc-resolver"),i=new WeakMap,b=a((e,o)=>{if(typeof e!="object"||e===null)return s.parseJsonConfigFileContent(e,s.sys,o);let r=i.get(e);r||(r=new Map,i.set(e,r));let t=r.get(o);return t||(t=s.parseJsonConfigFileContent(e,s.sys,o),r.set(o,t)),t},"getParsedConfig"),w=a((e,o,r,t,d,p)=>{const u=t?g.dirname(t):r,f=b(d,u),l=s.bundlerModuleNameResolver(e,o,f.options,s.sys,void 0,p);return C('tsc resolving id "%s" from "%s" -> %O',e,o,l.resolvedModule),l.resolvedModule?.resolvedFileName},"tscResolve");export{w as default};
|
package/dist/packem_shared/{createGeneratePlugin-lIEMRZwK.js → createGeneratePlugin-qobkPqWu.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"node:child_process";import"node:fs";import"node:fs/promises";import"node:path";import"@babel/parser";import"@rollup/pluginutils";import"obug";import"oxc-transform";import"../filename.js";import{c as g}from"./generate-
|
|
1
|
+
import"node:child_process";import"node:fs";import"node:fs/promises";import"node:path";import"@babel/parser";import"@rollup/pluginutils";import"obug";import"oxc-transform";import"../filename.js";import{c as g}from"./generate-B50-mrCC.js";export{g as createGeneratePlugin};
|
|
@@ -830,4 +830,5 @@ declare const filenameToDts: (id: string) => string;
|
|
|
830
830
|
declare const filenameDtsTo: (id: string, extension: "js" | "ts") => string;
|
|
831
831
|
declare const resolveTemplateFunction: (function_: ((chunk: PreRenderedChunk) => string) | string, chunk: PreRenderedChunk) => string;
|
|
832
832
|
declare const replaceTemplateName: (template: string, name: string) => string;
|
|
833
|
-
|
|
833
|
+
declare const dtsEntryFileName: (template: string, name: string, hasDExtension: boolean) => string | undefined;
|
|
834
|
+
export { Plugin as P, RenderedChunk as R, RE_CSS as a, RE_DTS as b, RE_DTS_MAP as c, RE_JS as d, RE_JSON as e, RE_NODE_MODULES as f, RE_TS as g, RE_VUE as h, dtsEntryFileName as i, filenameDtsTo as j, filenameJsToDts as k, filenameToDts as l, resolveTemplateFunction as m, replaceTemplateName as r };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
var Se=Object.defineProperty;var J=(o,e)=>Se(o,"name",{value:e,configurable:!0});import{spawn as Ee,fork as je}from"node:child_process";import{readFileSync as me,existsSync as U}from"node:fs";import{mkdtemp as _e,writeFile as Me,rm as ue,readFile as oe}from"node:fs/promises";import g from"node:path";import{parse as ge}from"@babel/parser";import{createFilter as Oe}from"@rollup/pluginutils";import{createDebug as Y}from"obug";import{transformSync as Te,isolatedDeclarationSync as Ae}from"oxc-transform";import{RE_DTS as _,RE_NODE_MODULES as H,filenameToDts as se,RE_JSON as ne,RE_TS as K,RE_VUE as Q,RE_JS as X,resolveTemplateFunction as Re,dtsEntryFileName as ie,replaceTemplateName as Fe,RE_DTS_MAP as ae}from"../filename.js";import{ResolverFactory as ke}from"oxc-resolver";import{resolve as De}from"@visulima/path";import{createRequire as Ie}from"node:module";import{tmpdir as Ne}from"node:os";var Pe=Object.defineProperty,M=J((o,e)=>Pe(o,"name",{value:e,configurable:!0}),"p");const le=/\bimport\(\s*["']([^"']+)["']\s*\)\.(\w+)/g,ce=/\bimport\b([^'"]*)["']([^"']+)["']/g,Ce=/\{([^}]*)\}/,ye=/\s+as\s+/,he=/^type\s+/,pe=/\bexport\s+\*\s+from\s*["']([^"']+)["']/g,de=/\bexport\s+(?:type\s+)?\{([^}]*)\}\s*from\s*["']([^"']+)["']/g,Je=M(o=>o.length>0&&!o.startsWith(".")&&!g.isAbsolute(o),"isBareSpecifier"),fe=M(o=>{const e=new Map,p=M((n,a)=>{if(!Je(n))return;let c=e.get(n);c||(c=new Set,e.set(n,c)),a&&c.add(a)},"add");let r;for(le.lastIndex=0;r=le.exec(o);)p(r[1],r[2]);for(ce.lastIndex=0;r=ce.exec(o);){const n=r[1],a=r[2],c=Ce.exec(n);if(c)for(const u of c[1].split(",")){const m=u.trim().split(ye).pop();m&&p(a,m.replace(he,"").trim())}else p(a)}return e},"collectReferencedSpecifiers"),We=M(o=>{const e=new Map,p=M(n=>{let a=e.get(n);return a||(a={all:!1,names:new Set},e.set(n,a)),a},"get");let r;for(pe.lastIndex=0;r=pe.exec(o);)p(r[1]).all=!0;for(de.lastIndex=0;r=de.exec(o);){const n=p(r[2]);for(const a of r[1].split(",")){const c=a.trim().replace(he,"");c&&(ye.test(c)||n.names.add(c))}}return e},"parseReexports"),Ge=M((o,e,p)=>o.replaceAll(`import("${e}")`,`import("${p}")`).replaceAll(`import('${e}')`,`import('${p}')`).replaceAll(`from "${e}"`,`from "${p}"`).replaceAll(`from '${e}'`,`from '${p}'`),"replaceSpecifier"),Le=M(o=>{const e=new ke({conditionNames:["types","typings","import","require"],mainFields:["types","typings","module","main"],tsconfig:o?{configFile:o,references:"auto"}:void 0}),p=new Map,r=new Map,n=M((c,u)=>{const m=`${g.dirname(u)}\0${c}`;if(r.has(m))return r.get(m);let h;try{const w=e.resolveDtsSync(u,c);w.path&&_.test(w.path)&&(h=w.path)}catch{}return r.set(m,h),h},"resolveDts"),a=M((c,u)=>{const m=n(c,u);if(!m)return;let h=p.get(m);if(!h){let w;try{w=me(m,"utf8")}catch{return}h=We(w),p.set(m,h)}return h},"getReexports");return(c,u,m)=>{const h=fe(c);if(h.size===0)return c;const w=fe(m);if(w.size===0)return c;let b=c;for(const[S,E]of h){if(w.has(S))continue;const R=[];for(const F of w.keys()){const I=a(F,u)?.get(S);I&&(I.all||[...E].every(q=>I.names.has(q)))&&R.push(F)}R.length===1&&(b=Ge(b,S,R[0]))}return b}},"createReexportSpecifierRewriter");var Ue=Object.defineProperty,we=J((o,e)=>Ue(o,"name",{value:e,configurable:!0}),"o");const ze=Y("rollup-plugin-dts:tsc-context"),ve=we(()=>({files:new Map,programs:[],projects:new Map}),"createContext"),qe=we((o,e)=>{const p=De(e).replaceAll("\\","/");ze(`invalidating context file: ${p}`),o.files.delete(p),o.programs=o.programs.filter(r=>!r.getSourceFiles().some(n=>n.fileName===p)),o.projects.clear()},"invalidateContextFile"),Ve=ve();var Be=Object.defineProperty,z=J((o,e)=>Be(o,"name",{value:e,configurable:!0}),"m$1");const D=Y("rollup-plugin-dts:tsgo"),He=z(async(...o)=>{await new Promise((e,p)=>{const r=Ee(...o);let n="";r.stderr?.on("data",a=>{n+=a.toString()}),r.on("close",(a,c)=>{if(a===0){e();return}const u=`tsgo ${a===null?`was terminated by signal ${String(c)}`:`exited with code ${String(a)}`}${n.trim()?`
|
|
2
|
+
${n.trim()}`:""}`;p(new Error(u))}),r.on("error",a=>{p(a)})})},"spawnAsync"),Ke=z(()=>{const o=Ie(import.meta.url),e=o.resolve("@typescript/native-preview/package.json"),p=g.dirname(e),r=o(g.join(p,"lib","getExePath.js")),n=typeof r=="function"?r:r.default;if(!n)throw new Error("Failed to resolve getExePath from @typescript/native-preview");return n()},"getTsgoPathFromNodeModules"),Qe=z((o,e,p,r)=>["--noEmit","false","--declaration","--emitDeclarationOnly",...o?["-p",o]:[],"--outDir",e,"--rootDir",p,"--noCheck",...r?["--declarationMap"]:[]],"buildTsgoArgs"),Xe=z(async(o,e,p,r,n)=>{D("[tsgo] rootDir",o);let a;r?(a=r,D("[tsgo] using custom path",a)):(a=Ke(),D("[tsgo] using tsgo from node_modules",a));const c=await _e(g.join(Ne(),"rollup-plugin-dts-"));D("[tsgo] tsgoDist",c);let u=e,m;if(n&&Object.keys(n.compilerOptions??{}).length>0){const w=e?g.dirname(e):o,{compilerOptions:b,...S}=n;m=g.join(w,`tsconfig.tsgo-${g.basename(c)}.json`);const E=e?{compilerOptions:b,extends:e}:{...S,compilerOptions:b};await Me(m,JSON.stringify(E),"utf8"),D("[tsgo] wrote temp project %s",m),u=m}const h=Qe(u,c,o,p);D("[tsgo] args %o",h);try{await He(a,h,{stdio:"inherit"})}finally{m&&await ue(m,{force:!0}).catch(()=>{})}return c},"runTsgo");var Ye=Object.defineProperty,W=J((o,e)=>Ye(o,"name",{value:e,configurable:!0}),"T");const $=Y("rollup-plugin-dts:generate"),Ze=import.meta.WORKER_URL??"./tsc/worker.js",yt=W(({build:o,cwd:e,eager:p,emitDtsOnly:r,emitJs:n,entry:a,exclude:c,include:u,incremental:m,newContext:h,oxc:w,parallel:b,sourcemap:S,tsconfig:E,tsconfigRaw:R,tsgo:F,tsMacro:I,vue:q})=>{const Z=u||c?Oe(u,c):null,xe=a?.filter(i=>i[0]!=="!"),$e=a?.filter(i=>i[0]==="!").map(i=>i.slice(1)),ee=a?i=>{const s=i.split(g.sep).join("/");return xe.some(t=>g.posix.matchesGlob(s,t))&&!$e.some(t=>g.posix.matchesGlob(s,t))}:void 0,T=new Map,G=new Set,te=new Map,be=Le(E);let k,V,B,L,N;const re=E?g.dirname(E):e;return{async buildEnd(){k?.kill(),!$.enabled&&N&&await ue(N,{force:!0,recursive:!0}).catch(()=>{}),N=void 0,h&&(L=void 0)},async buildStart(i){F?N=await Xe(re,E,S,F.path,R):w||(b?(k=je(new URL(Ze,import.meta.url),{stdio:"inherit"}),await new Promise((t,l)=>{k.once("spawn",()=>{t()}),k.once("error",d=>{l(new Error(`Failed to start the parallel tsc worker: ${d.message}`,{cause:d}))})}),V=(await import("birpc")).createBirpc({},{on:W(t=>k.on("message",t),"on"),post:W(t=>k.send(t),"post")})):(B=await import("../packem_chunks/index.js"),h&&(L=ve())));const s=Array.isArray(i.input)?i.input.map(t=>[void 0,t]):Object.entries(i.input).map(([t,l])=>[t,l]);for(const[t,l]of s){$("resolving input %s (alias %s)",l,t??"<derived>");let d=await this.resolve(l);l.startsWith("./")||(d||=await this.resolve(`./${l}`));const y=d?.id||l,f=t??g.basename(y).replace(K,"").replace(X,"");$("resolved input %s -> %s (%s)",l,y,f),te.set(y,f)}},generateBundle(i,s){for(const t of Object.keys(s)){const l=s[t];if(l){if(l.type==="asset"&&ae.test(t)&&typeof l.source=="string"){const d=JSON.parse(l.source);d.names=[],delete d.sourcesContent,l.source=JSON.stringify(d)}r&&l.type==="chunk"&&!_.test(t)&&!ae.test(t)&&delete s[t]}}},load:{filter:{id:{exclude:[H],include:[_]}},async handler(i){if(!T.has(i))return;const{code:s,id:t,jsFile:l}=T.get(i);let d,y;if($("generate dts %s from %s",i,t),l&&U(i)){$("dts file already exists for %s, skipping generation",t);return}if(F){if(Q.test(t))throw new Error("tsgo does not support Vue files.");const f=g.resolve(N,g.relative(re,se(t)));if(U(f)){if(d=await oe(f,"utf8"),S){const O=`${f}.map`;if(U(O)){const v=JSON.parse(await oe(O,"utf8"));if(Array.isArray(v.sources)){const A=g.dirname(O);v.sources=v.sources.map(x=>x==null?x:g.resolve(A,x))}y=v}}}else throw $("[tsgo]",f,"is missing"),new Error(`tsgo did not generate dts file for ${t}, please check your tsconfig.`)}else if(w&&!Q.test(t)){const f=Ae(t,s,w);if(f.errors.length>0){const[O]=f.errors,v=f.errors.length,A=v===1?"isolated declarations error":`${v} isolated declarations errors`,x=f.errors.map((j,P)=>{const C=j?.message??"Unknown error";return j?.codeframe?`${P+1}. ${C}
|
|
3
|
+
${j.codeframe}`:`${P+1}. ${C}`}).join(`
|
|
4
|
+
|
|
5
|
+
`);return this.error({frame:O?.codeframe||void 0,message:`${A} in ${t}:
|
|
6
|
+
|
|
7
|
+
${x}`})}d=f.code,f.map&&(f.map.sourcesContent=void 0,f.map.names=[],y=f.map)}else{const f=p?void 0:[...G],O={build:o,context:L,cwd:e,entries:f,id:t,incremental:m,sourcemap:S,tsconfig:E,tsconfigRaw:R,tsMacro:I,vue:q};let v;if(b){if(!V)return this.error(new Error("Parallel tsc worker is not initialized"));v=await V.tscEmit(O)}else v=B.tscEmit(O);if(v.error)return this.error(v.error);if(d=v.code,y=v.map,d&&ne.test(t))if(d.includes("declare const _exports")){if(d.includes("declare const _exports: {")&&!d.includes(`
|
|
8
|
+
}[];`)){const A=tt(d);let x=0;d+=A.map(j=>{const P=`_${j.replaceAll(/[^\w$]/g,"_")}${x++}`,C=JSON.stringify(j);return`declare let ${P}: typeof _exports[${C}]
|
|
9
|
+
export { ${P} as ${C} }`}).join(`
|
|
10
|
+
`)}}else{const A=et(d);d+=`
|
|
11
|
+
declare namespace __json_default_export {
|
|
12
|
+
export { ${Array.from(A.entries(),([x,j])=>x===j?x:`${j} as ${x}`).join(", ")} }
|
|
13
|
+
}
|
|
14
|
+
export { __json_default_export as default }`}}return d&&!l&&(d=be(d,t,s)),{code:d||"",map:y}}},name:"rollup-plugin-dts:generate",outputOptions(i){return{...i,entryFileNames(s){const{entryFileNames:t}=i,l=Re(t||"[name].js",s);if(s.name.endsWith(".d"))return ie(l,s.name,!0)??l;if(r){if(s.facadeModuleId&&_.test(s.facadeModuleId)){const d=ie(l,s.name,!1);if(d!==void 0)return d}return Fe("[name].js",s.name)}return l}}},async resolveId(i,s){if(T.has(i))return $("resolve dts id %s",i),{id:i};if(!s&&_.test(i)&&!H.test(i)){const t=g.isAbsolute(i)?i:g.resolve(e,i),l=t.replace(_,""),d=[t.replace(_,".$1ts"),`${l}.tsx`,`${l}.ts`,`${l}.mts`,`${l}.cts`];if(!T.has(t)){for(const y of d)if(U(y)){const f=me(y,"utf8");T.set(t,{code:f,id:y,isEntry:!0,jsFile:X.test(y)}),G.add(y),$("populated dtsMap from source for cached re-resolution: %s (via %s)",t,y);break}}return T.has(t)?($("resolve dts id %s (from cache re-resolution)",t),{id:t}):null}if(s&&K.test(s)&&(i.startsWith("./")||i.startsWith("../"))&&!g.extname(i))for(const t of[".ts",".tsx",".mts",".cts"]){const l=await this.resolve(i+t,s,{skipSelf:!0});if(l)return l}return null},shouldTransformCachedModule({id:i}){return _.test(i)},transform:{handler(i,s){if(s.startsWith("\0")||_.test(s)||H.test(s)||Z&&!Z(s))return;const t=X.test(s);if(!t||n){const l=!!this.getModuleInfo(s)?.isEntry,d=ee?l&&ee(g.relative(e,s)):l,y=se(s);if(T.set(y,{code:i,id:s,isEntry:d,jsFile:t}),$("register dts source: %s",s),d){G.add(s);const f=te.get(s);this.emitFile({id:y,name:f?`${f}.d`:void 0,type:"chunk"})}else G.delete(s)}return r?ne.test(s)?"{}":"export { }":K.test(s)||Q.test(s)?Te(s,i,{}).code:null},order:"pre"},watchChange(i){B&&qe(L||Ve,i)}}},"createGeneratePlugin"),et=W(o=>{const e=new Map,{program:p}=ge(o,{errorRecovery:!0,plugins:[["typescript",{dts:!0}]],sourceType:"module"});for(const r of p.body)if(r.type==="ExportNamedDeclaration"){if(r.declaration)if(r.declaration.type==="VariableDeclaration")for(const n of r.declaration.declarations)n.id.type==="Identifier"&&e.set(n.id.name,n.id.name);else r.declaration.type==="TSModuleDeclaration"&&r.declaration.id.type==="Identifier"&&e.set(r.declaration.id.name,r.declaration.id.name);else if(r.specifiers.length>0)for(const n of r.specifiers)n.type==="ExportSpecifier"&&n.exported.type==="Identifier"&&e.set(n.exported.name,n.local.type==="Identifier"?n.local.name:n.exported.name)}return e},"collectJsonExportMap"),tt=W(o=>{const e=[],{program:p}=ge(o,{plugins:[["typescript",{dts:!0}]],sourceType:"module"}),[r]=p.body,n=r?.type==="VariableDeclaration"?r.declarations[0]:void 0,a=n?.id.type==="Identifier"?n.id.typeAnnotation:void 0,c=(a?.type==="TSTypeAnnotation"&&a.typeAnnotation.type==="TSTypeLiteral"?a.typeAnnotation:void 0)?.members;if(!Array.isArray(c))throw new TypeError("rollup-plugin-dts: unexpected JSON declaration shape — expected `declare const _exports: { ... }` with an object type literal. The emitted dts may have changed; cannot extract named exports.");for(const u of c)u.key.type==="Identifier"?e.push(u.key.name):u.key.type==="StringLiteral"&&e.push(u.key.value);return e},"collectJsonExports");export{yt as c,Ve as g};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var Y=Object.defineProperty;var O=(e,t)=>Y(e,"name",{value:t,configurable:!0});import{existsSync as Z}from"node:fs";import{createRequire as _}from"node:module";import m from"node:path";import I from"node:process";import{findTsConfigSync as $,readTsConfig as H}from"@visulima/tsconfig";import C from"typescript";var K=Object.defineProperty,r=O((e,t)=>K(e,"name",{value:t,configurable:!0}),"i");let E=!1;const N=r(e=>e?e.incremental===!1?-1:e.incremental===!0||typeof e.tsBuildInfoFile=="string"?1:0:0,"checkCompilerOptionsIncremental"),Q=r((e,t)=>{if(e.startsWith("."))return m.resolve(t,e.endsWith(".json")?e:`${e}.json`);try{return _(m.join(t,"package.json")).resolve(e)}catch{return}},"resolveExtendedTsconfigPath"),U=r(e=>{if(Z(e))return C.sys.readFile(e)},"readTsconfigFile"),P=r((e,t=new Set)=>{if(t.has(e))return!1;t.add(e);const o=C.readConfigFile(e,U);if(o.error||!o.config)return!1;const i=o.config,n=N(i.compilerOptions);if(n!==0)return n===1;if(!i.extends)return!1;const s=Array.isArray(i.extends)?i.extends:[i.extends],g=m.dirname(e);for(const a of s){if(typeof a!="string")continue;const f=Q(a,g);if(f&&P(f,t))return!0}return!1},"hasExplicitIncrementalInTsconfig"),ee=r((e,t)=>{if(e===!0||e===void 0)try{const o=$(t);return{resolvedTsconfig:o.config,tsconfig:o.path}}catch{return{resolvedTsconfig:void 0,tsconfig:void 0}}if(typeof e=="string"){const o=m.resolve(t||I.cwd(),e);return{resolvedTsconfig:H(o),tsconfig:o}}return{resolvedTsconfig:void 0,tsconfig:void 0}},"resolveTsconfigPath"),te=r((e,t,o,i)=>{if(e){if(t)throw new Error("[@visulima/rollup-plugin-dts] The `tsgo` option is not compatible with the `vue` option. Please disable one of them.");if(o)throw new Error("[@visulima/rollup-plugin-dts] The `tsgo` option is not compatible with the `tsMacro` option. Please disable one of them.");if(i)throw new Error("[@visulima/rollup-plugin-dts] The `tsgo` option is not compatible with the `oxc` option. Please disable one of them.")}},"validateTsgoCompatibility"),oe=r((e,t,o)=>{if(e){if(t)throw new Error("[@visulima/rollup-plugin-dts] The `oxc` option is not compatible with the `vue` option. Please disable one of them.");if(o)throw new Error("[@visulima/rollup-plugin-dts] The `oxc` option is not compatible with the `tsMacro` option. Please disable one of them.")}},"validateOxcCompatibility"),ie=r(e=>e===!1?!1:e===!0?{}:e.enabled===!1?!1:{path:e.path},"normalizeTsgo"),se=r((e,t,o,i,n)=>{let s;switch(e){case!1:{s=!1;break}case!0:{s={};break}case void 0:{s=t.isolatedDeclarations&&!o&&!i&&!n?{}:!1;break}default:s=e}return s&&(s.stripInternal??=t.stripInternal??!1,s.sourcemap=t.declarationMap??!1),s},"normalizeOxc"),ue=r(({banner:e,build:t=!1,cjsDefault:o=!1,compilerOptions:i={},cwd:n=I.cwd(),dtsInput:s=!1,eager:g=!1,emitDtsOnly:a=!1,emitJs:f,entry:c,exclude:j,footer:k,include:M,incremental:D=!1,newContext:F=!1,oxc:A,parallel:J=!1,resolve:R=!1,resolver:z="oxc",sideEffects:S=!1,sourcemap:W,tsconfig:B,tsconfigRaw:q={},tsgo:G=!1,tsMacro:p=!1,vue:u=!1})=>{const{resolvedTsconfig:w,tsconfig:h}=ee(B,n),b=i,l={...w?.compilerOptions,...i},L=D||b.incremental===!0||typeof b.tsBuildInfoFile=="string"||typeof h=="string"&&P(h),y=W??!!l.declarationMap;l.declarationMap=y;let x;if(c!==void 0){const T=Array.isArray(c)?c:[c];x=T.length>0?T:void 0}const V={...w,...q,compilerOptions:l},d=ie(G),v=se(A,l,u,d,p),X=f??!!(l.checkJs||l.allowJs);return te(d,u,p,v),oe(v,u,p),d&&!E&&(console.warn("The `tsgo` option is experimental and may change in the future."),E=!0),{banner:e,build:t,cjsDefault:o,cwd:n,dtsInput:s,eager:g,emitDtsOnly:a,emitJs:X,entry:x,exclude:j,footer:k,include:M,incremental:L,newContext:F,oxc:v,parallel:J,resolve:R,resolver:z,sideEffects:S,sourcemap:y,tsconfig:h,tsconfigRaw:V,tsgo:d,tsMacro:p,vue:u}},"resolveOptions");export{ue as resolveOptions};
|
package/package.json
CHANGED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
var pe=Object.defineProperty;var D=(a,s)=>pe(a,"name",{value:s,configurable:!0});import{spawn as ue,fork as me}from"node:child_process";import{existsSync as I,readFileSync as fe}from"node:fs";import{mkdtemp as ge,readFile as X,rm as ye}from"node:fs/promises";import u from"node:path";import{parse as re}from"@babel/parser";import{createFilter as we}from"@rollup/pluginutils";import{createDebug as V}from"obug";import{transformSync as he,isolatedDeclarationSync as ve}from"oxc-transform";import{RE_DTS as w,RE_NODE_MODULES as W,RE_JS as M,filenameToDts as Y,RE_JSON as Z,RE_TS as ee,RE_VUE as G,resolveTemplateFunction as xe,replaceTemplateName as L,RE_DTS_MAP as te}from"../filename.js";import{resolve as $e}from"@visulima/path";import{createRequire as Ee}from"node:module";import{tmpdir as Se}from"node:os";var be=Object.defineProperty,oe=D((a,s)=>be(a,"name",{value:s,configurable:!0}),"o");const _e=V("rollup-plugin-dts:tsc-context"),se=oe(()=>({files:new Map,programs:[],projects:new Map}),"createContext"),Te=oe((a,s)=>{const d=$e(s).replaceAll("\\","/");_e(`invalidating context file: ${d}`),a.files.delete(d),a.programs=a.programs.filter(n=>!n.getSourceFiles().some(i=>i.fileName===d)),a.projects.clear()},"invalidateContextFile"),Me=se();var je=Object.defineProperty,U=D((a,s)=>je(a,"name",{value:s,configurable:!0}),"g");const j=V("rollup-plugin-dts:tsgo"),Ae=U(async(...a)=>{await new Promise((s,d)=>{const n=ue(...a);let i="";n.stderr?.on("data",c=>{i+=c.toString()}),n.on("close",(c,g)=>{if(c===0){s();return}const h=`tsgo ${c===null?`was terminated by signal ${String(g)}`:`exited with code ${String(c)}`}${i.trim()?`
|
|
2
|
-
${i.trim()}`:""}`;d(new Error(h))}),n.on("error",c=>{d(c)})})},"spawnAsync"),Oe=U(()=>{const a=Ee(import.meta.url),s=a.resolve("@typescript/native-preview/package.json"),d=u.dirname(s),n=a(u.join(d,"lib","getExePath.js")),i=typeof n=="function"?n:n.default;if(!i)throw new Error("Failed to resolve getExePath from @typescript/native-preview");return i()},"getTsgoPathFromNodeModules"),ke=U(async(a,s,d,n)=>{j("[tsgo] rootDir",a);let i;n?(i=n,j("[tsgo] using custom path",i)):(i=Oe(),j("[tsgo] using tsgo from node_modules",i));const c=await ge(u.join(Se(),"rollup-plugin-dts-"));j("[tsgo] tsgoDist",c);const g=["--noEmit","false","--declaration","--emitDeclarationOnly",...s?["-p",s]:[],"--outDir",c,"--rootDir",a,"--noCheck",...d?["--declarationMap"]:[]];return j("[tsgo] args %o",g),await Ae(i,g,{stdio:"inherit"}),c},"runTsgo");var Re=Object.defineProperty,A=D((a,s)=>Re(a,"name",{value:s,configurable:!0}),"S");const x=V("rollup-plugin-dts:generate"),De=import.meta.WORKER_URL??"./tsc/worker.js",He=A(({build:a,cwd:s,eager:d,emitDtsOnly:n,emitJs:i,entry:c,exclude:g,include:h,incremental:ne,newContext:z,oxc:F,parallel:K,sourcemap:N,tsconfig:O,tsconfigRaw:ie,tsgo:C,tsMacro:ae,vue:le})=>{const q=h||g?we(h,g):null,ce=c?.filter(o=>o[0]!=="!"),de=c?.filter(o=>o[0]==="!").map(o=>o.slice(1)),B=c?o=>{const e=o.split(u.sep).join("/");return ce.some(r=>u.posix.matchesGlob(e,r))&&!de.some(r=>u.posix.matchesGlob(e,r))}:void 0,$=new Map,k=new Set,H=new Map;let S,P,J,R,b;const Q=O?u.dirname(O):s;return{async buildEnd(){S?.kill(),!x.enabled&&b&&await ye(b,{force:!0,recursive:!0}).catch(()=>{}),b=void 0,z&&(R=void 0)},async buildStart(o){if(C?b=await ke(Q,O,N,C.path):F||(K?(S=me(new URL(De,import.meta.url),{stdio:"inherit"}),await new Promise((e,r)=>{S.once("spawn",()=>{e()}),S.once("error",t=>{r(new Error(`Failed to start the parallel tsc worker: ${t.message}`,{cause:t}))})}),P=(await import("birpc")).createBirpc({},{on:A(e=>S.on("message",e),"on"),post:A(e=>S.send(e),"post")})):(J=await import("../packem_chunks/index.js"),z&&(R=se()))),!Array.isArray(o.input))for(const[e,r]of Object.entries(o.input)){x("resolving input alias %s -> %s",e,r);let t=await this.resolve(r);r.startsWith("./")||(t||=await this.resolve(`./${r}`));const p=t?.id||r;x("resolved input alias %s -> %s",r,p),H.set(p,e)}},generateBundle(o,e){for(const r of Object.keys(e)){const t=e[r];if(t){if(t.type==="asset"&&te.test(r)&&typeof t.source=="string"){const p=JSON.parse(t.source);p.names=[],delete p.sourcesContent,t.source=JSON.stringify(p)}n&&t.type==="chunk"&&!w.test(r)&&!te.test(r)&&delete e[r]}}},load:{filter:{id:{exclude:[W],include:[w]}},async handler(o){if(!$.has(o))return;const{code:e,id:r}=$.get(o);let t,p;if(x("generate dts %s from %s",o,r),C){if(G.test(r))throw new Error("tsgo does not support Vue files.");const l=u.resolve(b,u.relative(Q,Y(r)));if(I(l)){if(t=await X(l,"utf8"),N){const y=`${l}.map`;if(I(y)){const m=JSON.parse(await X(y,"utf8"));if(Array.isArray(m.sources)){const E=u.dirname(y);m.sources=m.sources.map(f=>f==null?f:u.resolve(E,f))}p=m}}}else throw x("[tsgo]",l,"is missing"),new Error(`tsgo did not generate dts file for ${r}, please check your tsconfig.`)}else if(F&&!G.test(r)){const l=ve(r,e,F);if(l.errors.length>0){const[y]=l.errors,m=l.errors.length,E=m===1?"isolated declarations error":`${m} isolated declarations errors`,f=l.errors.map((v,_)=>{const T=v?.message??"Unknown error";return v?.codeframe?`${_+1}. ${T}
|
|
3
|
-
${v.codeframe}`:`${_+1}. ${T}`}).join(`
|
|
4
|
-
|
|
5
|
-
`);return this.error({frame:y?.codeframe||void 0,message:`${E} in ${r}:
|
|
6
|
-
|
|
7
|
-
${f}`})}t=l.code,l.map&&(l.map.sourcesContent=void 0,l.map.names=[],p=l.map)}else{const l=d?void 0:[...k],y={build:a,context:R,cwd:s,entries:l,id:r,incremental:ne,sourcemap:N,tsconfig:O,tsconfigRaw:ie,tsMacro:ae,vue:le};let m;if(K){if(!P)return this.error(new Error("Parallel tsc worker is not initialized"));m=await P.tscEmit(y)}else m=J.tscEmit(y);if(m.error)return this.error(m.error);if(t=m.code,p=m.map,t&&Z.test(r))if(t.includes("declare const _exports")){if(t.includes("declare const _exports: {")&&!t.includes(`
|
|
8
|
-
}[];`)){const E=Ne(t);let f=0;t+=E.map(v=>{const _=`_${v.replaceAll(/[^\w$]/g,"_")}${f++}`,T=JSON.stringify(v);return`declare let ${_}: typeof _exports[${T}]
|
|
9
|
-
export { ${_} as ${T} }`}).join(`
|
|
10
|
-
`)}}else{const E=Fe(t);t+=`
|
|
11
|
-
declare namespace __json_default_export {
|
|
12
|
-
export { ${Array.from(E.entries(),([f,v])=>f===v?f:`${v} as ${f}`).join(", ")} }
|
|
13
|
-
}
|
|
14
|
-
export { __json_default_export as default }`}}return{code:t||"",map:p}}},name:"rollup-plugin-dts:generate",outputOptions(o){return{...o,entryFileNames(e){const{entryFileNames:r}=o,t=xe(r||"[name].js",e);if(e.name.endsWith(".d")){if(w.test(t))return L(t,e.name.slice(0,-2));if(M.test(t))return t.replace(M,".$1ts")}else if(n){if(e.facadeModuleId&&w.test(e.facadeModuleId)){if(w.test(t))return L(t,e.name);if(M.test(t))return t.replace(M,".$1ts")}return L("[name].js",e.name)}return t}}},async resolveId(o,e){if($.has(o))return x("resolve dts id %s",o),{id:o};if(!e&&w.test(o)&&!W.test(o)){const r=u.isAbsolute(o)?o:u.resolve(s,o),t=r.replace(w,""),p=[r.replace(w,".$1ts"),`${t}.tsx`,`${t}.ts`,`${t}.mts`,`${t}.cts`];if(!$.has(r)){for(const l of p)if(I(l)){const y=fe(l,"utf8");$.set(r,{code:y,id:l,isEntry:!0}),k.add(l),x("populated dtsMap from source for cached re-resolution: %s (via %s)",r,l);break}}return $.has(r)?(x("resolve dts id %s (from cache re-resolution)",r),{id:r}):null}if(e&&ee.test(e)&&(o.startsWith("./")||o.startsWith("../"))&&!u.extname(o))for(const r of[".ts",".tsx",".mts",".cts"]){const t=await this.resolve(o+r,e,{skipSelf:!0});if(t)return t}return null},shouldTransformCachedModule({id:o}){return w.test(o)},transform:{handler(o,e){if(!(e.startsWith("\0")||w.test(e)||W.test(e)||q&&!q(e))){if(!M.test(e)||i){const r=!!this.getModuleInfo(e)?.isEntry,t=B?r&&B(u.relative(s,e)):r,p=Y(e);if($.set(p,{code:o,id:e,isEntry:t}),x("register dts source: %s",e),t){k.add(e);const l=H.get(e);this.emitFile({id:p,name:l?`${l}.d`:void 0,type:"chunk"})}else k.delete(e)}return n?Z.test(e)?"{}":"export { }":ee.test(e)||G.test(e)?he(e,o,{}).code:null}},order:"pre"},watchChange(o){J&&Te(R||Me,o)}}},"createGeneratePlugin"),Fe=A(a=>{const s=new Map,{program:d}=re(a,{errorRecovery:!0,plugins:[["typescript",{dts:!0}]],sourceType:"module"});for(const n of d.body)if(n.type==="ExportNamedDeclaration"){if(n.declaration)if(n.declaration.type==="VariableDeclaration")for(const i of n.declaration.declarations)i.id.type==="Identifier"&&s.set(i.id.name,i.id.name);else n.declaration.type==="TSModuleDeclaration"&&n.declaration.id.type==="Identifier"&&s.set(n.declaration.id.name,n.declaration.id.name);else if(n.specifiers.length>0)for(const i of n.specifiers)i.type==="ExportSpecifier"&&i.exported.type==="Identifier"&&s.set(i.exported.name,i.local.type==="Identifier"?i.local.name:i.exported.name)}return s},"collectJsonExportMap"),Ne=A(a=>{const s=[],{program:d}=re(a,{plugins:[["typescript",{dts:!0}]],sourceType:"module"}),[n]=d.body,i=n?.type==="VariableDeclaration"?n.declarations[0]:void 0,c=i?.id.type==="Identifier"?i.id.typeAnnotation:void 0,g=(c?.type==="TSTypeAnnotation"&&c.typeAnnotation.type==="TSTypeLiteral"?c.typeAnnotation:void 0)?.members;if(!Array.isArray(g))throw new TypeError("rollup-plugin-dts: unexpected JSON declaration shape — expected `declare const _exports: { ... }` with an object type literal. The emitted dts may have changed; cannot extract named exports.");for(const h of g)h.key.type==="Identifier"?s.push(h.key.name):h.key.type==="StringLiteral"&&s.push(h.key.value);return s},"collectJsonExports");export{He as c,Me as g};
|