Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/428.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Google闭包-在ES6模块类中导入遗留类_Javascript_Google Closure Compiler_Google Closure_Google Closure Library - Fatal编程技术网

Javascript Google闭包-在ES6模块类中导入遗留类

Javascript Google闭包-在ES6模块类中导入遗留类,javascript,google-closure-compiler,google-closure,google-closure-library,Javascript,Google Closure Compiler,Google Closure,Google Closure Library,我有一个使用ES5编写的代码库,我只想使用模块将部分代码更新到ES6。 这是我的代码: goog.module('farm.animal.Cow'); // Legacy class using es5 var Animal = goog.require('namespace.Animal'); class Cow extends Animal { constructor() { super(); } } exports = Cow; 这是遗留类 goog.provide

我有一个使用ES5编写的代码库,我只想使用模块将部分代码更新到ES6。 这是我的代码:

goog.module('farm.animal.Cow');

// Legacy class using es5
var Animal = goog.require('namespace.Animal');

class Cow extends Animal {
  constructor() {
    super();
  }
}

exports = Cow;
这是遗留类

goog.provide('namespace.Animal');

namespace.Animal = function() {

};
我试图遵循这两个项目的GitHub Wiki上的迁移建议:

但到目前为止运气不好。大多数情况下,我会遇到以下错误:

depstree.NamespaceNotFoundError: Namespace "namespace.Animal" never provided.

有人知道应该如何正确地迁移代码吗?我做错了什么?

没有人使用谷歌闭包,你也不应该。世界在前进,一些技术随着时间的推移而消亡,而另一些技术则继续存在。谷歌闭包仍然由谷歌自己使用和更新,但可能没有其他人。即使谷歌闭包在2019年可能不是一个明智的选择,如果你要编写新的代码,这并不意味着不存在用它编写的遗留代码库!这并不意味着这个问题是无效的。@evilReiko不正确,每一个Clojurescript应用程序都在幕后使用它。@evilReiko我理解流行的角度,但据我所知,没有什么比Google Closure提供的更复杂的优化了,所以虽然它不流行,但应该是,没有人使用谷歌闭包,你也不应该。世界在前进,一些技术随着时间的推移而消亡,而另一些技术则继续存在。谷歌闭包仍然由谷歌自己使用和更新,但可能没有其他人。即使谷歌闭包在2019年可能不是一个明智的选择,如果你要编写新的代码,这并不意味着不存在用它编写的遗留代码库!这并不意味着这个问题是无效的。@evilReiko不正确,每一个Clojurescript应用程序都在幕后使用它。@evilReiko我理解流行的角度,但据我所知,没有什么比Google Closure提供的更复杂的优化了,所以虽然它不流行,但它应该流行,或者需要一些同样好的东西。