简体   繁体   English

如何使用Google Closure编译器构建一个文件?

[英]How do I use the Google Closure Compiler to build one file?

The question is a little more complicated than the title suggests, so allow me to elaborate. 这个问题比标题所暗示的要复杂一些,所以请允许我详细说明。 I have a project that is split into two repositories. 我有一个项目,该项目分为两个存储库。 The both use Google Closure for dependency management and compilation. 两者都使用Google Closure进行依赖项管理和编译。 I need to deliver a compiled version of project A to project B. Project B does advanced optimizations, so project A must be whitespace only. 我需要将项目A的编译版本交付给项目B。项目B进行了高级优化,因此项目A必须仅是空格。 The problem is that I can't find a way to satisfy all my requirements for compiled A, which are: 问题是我找不到满足我对已编译A的所有要求的方法,这些要求是:

  • It must be ordered by dependency 必须按依赖关系排序
  • There can be no goog base code, ie, var goog=goog||{}... 不能有goog基本代码,即var goog=goog||{}...
  • Similarly, there can be no goog.provides or goog.requires 同样,不能有goog.provides或goog.requires
  • It must be whitespace-only compiled 它必须是仅空白编译的

So far I've tried: 到目前为止,我已经尝试过:

  • Closurebuilder.py Closurebuilder.py
    • pros: can be whitespace only 优点:只能是空格
    • problem: Has base code; 问题:有基本代码; getting duplicate namespace issues 出现重复的名称空间问题
  • Compiler.jar 编译器
    • problem: whitespace-only mode keeps goog.provides and requires in 问题:仅空白模式保留goog.provides并要求
    • problem: any optimizations of project A break project B 问题:项目A的任何优化都会中断项目B

Has anyone made a similar setup work? 有人进行过类似的设置工作吗?

I solved it by getting the dependencies from closurebuilder.py and simply concatenating them together, in order, into one file. 我通过从closurebuilder.py获取依赖项并将其按顺序简单地串联在一起,从而解决了一个文件。 It gets shipped to a built repo, where B can pick it up via npm, and it gets run through a closure script (that adv. optimizes it and splits it into modules). 它被运送到一个内置的仓库中,B可以在其中通过npm将其拾起,并通过一个闭包脚本运行(该脚本会对其进行优化并将其拆分为模块)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用Google Closure编译器使巨大的javascript文件更加有效和可维护? - How do I use google closure compiler to make a gigantic javascript file more efficient and maintainable? 如何使用Google Closure编译器 - How to use Google Closure compiler 如何使用Google Closure编译器删除未使用的JavaScript代码? - How do I use Google Closure compiler to remove unused JavaScript code? 我如何将外部文件添加到Google闭包编译器以进行缩小,并防止将jQuery名称缩小 - how do i add extern file to google closure compiler for minification and prevent jquery names from being minified 如何为Google Closure Compiler启用日志记录? - How do I enable logging for Google Closure Compiler? 使用Google Closure Compiler Application在一个文件中压缩所有文件.js - Compress all file .js with Google Closure Compiler Application in one File 如何在 Visual Studio 2010 中集成 Google Closure Compiler 作为构建步骤 - How to integrate Google Closure Compiler as a build step in Visual Studio 2010 如何强制使用本机版本的 google-closure-compiler? - How do I force the native version of google-closure-compiler to be used? 忽略Google Closure中一个文件的编译器警告 - ignore compiler warning from one file in Google Closure 谷歌的Closure编译器,使输出文件在一行 - Google's Closure compiler, make the output file in one line
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM