首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >'latLng‘不是由’node_modules/ leaflet /dist/leaflet src.js‘导出的,在leaflet上汇总生成失败

'latLng‘不是由’node_modules/ leaflet /dist/leaflet src.js‘导出的,在leaflet上汇总生成失败
EN

Stack Overflow用户
提问于 2017-06-02 19:52:20
回答 0查看 606关注 0票数 0

我使用的是Minko.Also的angular-seed,使用的是@asymmetrik/angular2-leaflet.The。正常的产品构建可以在运行npm run build.prod.rollup.aot的well.When上工作,它会失败并返回错误。

代码语言:javascript
复制
dist/tmp/app/home/demo/leaflet-d3/ping/ping-demo.component.js (23:21) 'tile
Layer' is not exported by 'node_modules/leaflet/dist/leaflet-src.js'
dist/tmp/app/home/demo/leaflet-d3/ping/ping-demo.component.js (41:22) 'latL
ng' is not exported by 'node_modules/leaflet/dist/leaflet-src.js'
dist/tmp/app/home/demo/leaflet-d3/ping/ping-demo.component.js (68:31) 'circ
le' is not exported by 'node_modules/leaflet/dist/leaflet-src.js'
node_modules/@asymmetrik/angular2-leaflet/dist/leaflet/core/leaflet.directive.js (6:32)
'latLng' is not exported by 'node_modules/leaflet/dist/leaflet-src.js'
node_modules/@asymmetrik/angular2-leaflet/dist/leaflet/core/leaflet.directive.js (20:21)
 'map' is not exported by 'node_modules/leaflet/dist/leaflet-src.js'
node_modules/@asymmetrik/angular2-leaflet/dist/leaflet/layers/control/leaflet-control-la
yers.wrapper.js (13:31) 'control' is not exported by 'node_modules/leaflet/dist/leaflet-
src.js'

project.config.ts汇总命名导入

代码语言:javascript
复制
this.ROLLUP_NAMED_EXPORTS = [
      ...this.ROLLUP_NAMED_EXPORTS,
      {'node_modules/leaflet/dist/leaflet.js': [  'leaflet' ]},

    ];

附加套餐

代码语言:javascript
复制
let additionalPackages: ExtendPackages[] = [
      {
        name: 'leaflet',
        path: 'node_modules/leaflet/dist/leaflet.js'
      },
      {
        name: '@asymmetrik/angular2-leaflet',
        path: 'node_modules/@asymmetrik/angular2-leaflet/dist/bundles/angular2-leaflet.js'
      }
     ];

汇总配置(build.bundles.app.rollup.aot.ts)

代码语言:javascript
复制
import Config from '../../config';
import { writeFile } from 'fs';
import { join } from 'path';

const nodeResolve = require('rollup-plugin-node-resolve');
const commonjs = require('rollup-plugin-commonjs');
const includePaths = require('rollup-plugin-includepaths');
const rollup = require('rollup');

const alias = require('rollup-plugin-alias');


const config = {
  entry: join(Config.TMP_DIR, Config.BOOTSTRAP_FACTORY_PROD_MODULE),
  sourceMap: true,
  treeshake: true,
  moduleName: 'main',
  plugins: [
    includePaths({
      include: {},
      paths: [join(Config.TMP_DIR, 'app')],
      external: [],
      extensions: ['.js', '.json', '.html', '.ts']
    }),
    alias({
            jszip: join(__dirname, '../../../node_modules/jszip/dist/jszip.min.js')
        }),
    nodeResolve({
      jsnext: true, main: true, module: true
    }),
    commonjs({ //See project.config.ts to extend
      include: Config.ROLLUP_INCLUDE_DIR,
      namedExports: Config.getRollupNamedExports()
    })
  ]
};
export = (done: any) => {
  rollup.rollup(config)
    .then((bundle: any) => {
      const result = bundle.generate({
        format: 'iife'
      });
      const path = join(Config.TMP_DIR, 'bundle.js');
      writeFile(path, result.code, (error: any) => {
        if (error) {
          console.error(error);
          process.exit(0);
        }
        done();
      });
    })
    .catch((error: any) => {
      console.error(error);
      process.exit(0);
    });
};
EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44328282

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档