我使用rollupjs
作为新[email protected]
版本的一部分。该项目使用tsconfig.json
与compilerOptions.module = "es2015"
而不是"commonjs"
,这对我来说是全新的。导入rollupjs,es2015模块
// typescript
import { AgmCoreModule } from 'angular2-google-maps/core';
我从汇总得到这个import
错误
[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
导入的指令我该怎么办?
你是如何导入指令的?在我的NgModule注释中简单地添加“AgmCoreModule.forRoot()”到导入[]中(我还需要导入'angular2-google-maps/core/core-modules'tho) – Jamby
这就是我所做的,但我为'shared.modules.ts'和'app.modules.ts'添加'[AgmCoreModule.forRoot()]'' – michael
当然可以。它在angular2-google-maps的入门 – Jamby