展示HN:PineCone – 一个用于将PineScript拆分成多个文件的打包工具
我为 PineScript(TradingView 的脚本语言)构建了一个模块打包工具。
问题是:TradingView 不支持多文件项目。随着指标变得复杂,最终你会得到超过 1000 行的文件,这让维护变得非常痛苦。
Pinecone 允许你使用 import/export 指令将代码拆分到多个 .pine 文件中,然后将所有内容打包成一个兼容 TradingView 的脚本。
它自动处理命名空间,以防止模块之间的变量冲突,去重外部库的导入,并包含开发时的观察模式。
该工具是用 Python 构建的,使用 pynescript 库进行 AST 解析和操作。我不得不绕过一些上游解析器在通用类型语法上的错误,这对我来说是一个有趣的挑战。
GitHub: [https://github.com/claudianadalin/pinecone](https://github.com/claudianadalin/pinecone)
更多技术细节的博客文章: [https://www.claudianadalin.com/blog/building-pinecone](https://www.claudianadalin.com/blog/building-pinecone)
这是一个小众工具,但如果你曾经构建过复杂的 TradingView 指标,你就会知道这种痛苦。我非常希望能收到对这个方法的反馈。
查看原文
I built a module bundler for PineScript (TradingView's scripting language).<p>The problem: TradingView doesn't support multi-file projects. As indicators grow complex, you end up with 1000+ line files that are painful to maintain.<p>Pinecone lets you split code across multiple .pine files using import/export directives, then bundles everything into a single TradingView-compatible script.<p>It handles automatic namespacing to prevent variable collisions between modules, deduplicates external library imports, and includes watch mode for development.<p>Built with Python. Uses the pynescript library for AST parsing and manipulation. I had to work around some upstream parser bugs with generic type syntax, which was an interesting challenge.<p>GitHub: <a href="https://github.com/claudianadalin/pinecone" rel="nofollow">https://github.com/claudianadalin/pinecone</a><p>Blog post with more technical details: <a href="https://www.claudianadalin.com/blog/building-pinecone" rel="nofollow">https://www.claudianadalin.com/blog/building-pinecone</a><p>This is a niche tool, but if you've ever built complex TradingView indicators, you know the pain. Would love feedback on the approach.