我使用 rollupjs
作为新 ionic2@RC.0
版本的一部分。该项目使用 tsconfig.json
和 compilerOptions.module = "es2015"
而不是 "commonjs"
,这对我来说是全新的。
// typescript
import { AgmCoreModule } from 'angular2-google-maps/core';
我从汇总中收到此导入
错误
[17:40:45] typescript compiler finished in 8.08 s
[17:40:45] bundle dev started ...
[17:40:55] Error: Module .../node_modules/angular2-google-maps/core/index.js does not export AgmCoreModule (imported by .../.tmp/shared/shared.module.js)
at Module.trace (.../node_modules/rollup/dist/rollup.js:7677:29)
at ModuleScope.findDeclaration
...
导入文件如下所示
// index.d.ts
/**
* angular2-google-maps - Angular 2 components for Google Maps
* @version v0.14.0
* @link https://github.com/SebastianM/angular2-google-maps#readme
* @license MIT
*/
export * from './directives';
export * from './services';
export * from './map-types';
export { LatLngBounds, LatLng, LatLngLiteral, MapTypeStyle } from './services/google-maps-types';
export * from './core-module';
// index.js
/**
* angular2-google-maps - Angular 2 components for Google Maps
* @version v0.14.0
* @link https://github.com/SebastianM/angular2-google-maps#readme
* @license MIT
*/
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
// main modules
__export(require('./directives'));
__export(require('./services'));
// Google Maps types
// core module
__export(require('./core-module'));
//# sourceMappingURL=index.js.map
我可以将导入更改为
import { AgmCoreModule } from 'angular2-google-maps/core/core-modules';
和 rollup
不会提示,但 angular2
找不到从 angular2-google-maps/core
导入的指令
我该怎么办?
最佳答案
当 angular2-google-maps/core/index.ts
中的 export * from ...
声明使用 __export
编译为 JS 时code> 函数,Rollup 失去了跟踪导出的绑定(bind)的能力。如果您使用 esm/
(ECMAScript 模块)目录中提供的 ES6 版本的库,一切都应该可以工作。
import { AgmCoreModule } from 'angular2-google-maps/esm/core/index.js';
关于javascript - 使用 rollupjs、es2015 模块导入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39794656/