我使用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