Giter Site home page Giter Site logo

Comments (8)

JobinJia avatar JobinJia commented on June 19, 2024 1

两次运行之间我均手动删除了 dist 文件夹的。

我借了一台 mac 笔记本进行了测试,两次打包结果是一样且正常的,无法复现你描述的情况:

{4202DD66-1173-76C3-7359-D34FAE3B5A65}

在vscode下可以,
因为我是用的webstorm ,就生成有问题...
...em
这是vscode
image
这是webstorm
image

from vite-plugin-dts.

qmhc avatar qmhc commented on June 19, 2024

我调整了 replaceFilePath 方法内的正则表达式:

image

const replaceFilePath = path => {
  return path.replace(/packages[\\/][a-zA-z]+([\\/])/, '$1')
}

分别在根目录下执行 node build.jsnode scripts/build.js,在 dist 下得到了一样的结果:

image

from vite-plugin-dts.

JobinJia avatar JobinJia commented on June 19, 2024

emm, 实在抱歉,因为我没有配置打包前删除原有的dist目录 。
所以需要手动删除dist之后,重新偿试打包,我这边还是没有达到预期的效果。
也许跟系统环境有关?(我的环境:macOS Big Sur 11.6.1 )

image

from vite-plugin-dts.

qmhc avatar qmhc commented on June 19, 2024

两次运行之间我均手动删除了 dist 文件夹的。

我借了一台 mac 笔记本进行了测试,两次打包结果是一样且正常的,无法复现你描述的情况:

{4202DD66-1173-76C3-7359-D34FAE3B5A65}

from vite-plugin-dts.

JobinJia avatar JobinJia commented on June 19, 2024

补充,在windows下的webstorm中。执行build.js一样会只生成index.d.ts。其它的还是不见。
但是如果使用node script/build.js 是能正常的生成完全的.d.ts.
所以, 暂时不确定到底是ws的node换环境的问题还是插件的兼容问题。
因为在ws中运行 script/build.js是执行的"C:\Program Files\nodejs\node.exe" E:\myself\vue3-library\build.js (windows下)

from vite-plugin-dts.

JobinJia avatar JobinJia commented on June 19, 2024

最新,经调试发现,在webstorm中运行时,有路径对不上,所以没有生成
执行根目录下的build.js
image
执行非根目录下的build
image
向上寻找对应的地方创建project对象时
image

对应vite-plugin-dts源码位置
image
image

是否可能因为创建ts-morph的实例时outDir路径写死的原因?

from vite-plugin-dts.

qmhc avatar qmhc commented on June 19, 2024

可能在 webstorm 执行 scripts/build.jscwd 被设置为 scripts 目录了,你可以尝试一下使用 root 选项将根目录显式地设置为项目根目录。

PS:如果是 cwd 被设置为 scripts 目录,我也不确定会不会影响到 typescript 的输出路径(ts-morpth 内部依然是使用 typescript 的方法的)

from vite-plugin-dts.

JobinJia avatar JobinJia commented on June 19, 2024

可能在 webstorm 执行 scripts/build.jscwd 被设置为 scripts 目录了,你可以尝试一下使用 root 选项将根目录显式地设置为项目根目录。

PS:如果是 cwd 被设置为 scripts 目录,我也不确定会不会影响到 typescript 的输出路径(ts-morpth 内部依然是使用 typescript 的方法的)

我也是这样想的,上面调试的时候已经显示的设置了root的路径。因为之前没有显示设置的时候,获取组件路径就是错的。修证过后,才验证才出现上面的我说的情况。

这个问题,我先关闭了。不去深究了。因为打包时,究终会在package.json里设置命令,使用 node script/build.js 去执行。
这样的结果反而是对的。 : (

from vite-plugin-dts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.