feat(l7) add roullup

This commit is contained in:
thinkinggis 2019-03-01 11:23:01 +08:00
parent 73a57e3f60
commit fd8670881a
6 changed files with 52 additions and 5 deletions

49
rollup.config.js Normal file
View File

@ -0,0 +1,49 @@
import fs from 'fs';
import sourcemaps from 'rollup-plugin-sourcemaps';
import { plugins } from './build/rollup_plugins';
const { BUILD, MINIFY } = process.env;
const minified = MINIFY === 'true';
const production = BUILD === 'production';
const outputFile = !production
? 'dist/l7-dev.js'
: minified
? 'dist/l7.js'
: 'dist/l7-unminified.js';
const config = [
{
input: [ 'src/index.js', 'src/worker/worker.js' ],
output: {
dir: 'rollup/build/l7',
format: 'amd',
sourcemap: 'inline',
indent: false,
chunkFileNames: 'shared.js'
},
experimentalCodeSplitting: true,
treeshake: production,
plugins: plugins()
},
{
input: 'rollup/mapboxgl.js',
output: {
name: 'mapboxgl',
file: outputFile,
format: 'umd',
sourcemap: production ? true : 'inline',
indent: false,
intro: fs.readFileSync(
require.resolve('./rollup/bundle_prelude.js'),
'utf8'
)
},
treeshake: false,
plugins: [
// Ingest the sourcemaps produced in the first step of the build.
// This is the only reason we use Rollup for this second pass
// sourcemaps()
]
}
];
export default config;

0
rollup/l7.js Normal file
View File

View File

@ -2,7 +2,7 @@ import Engine from './engine';
import { LAYER_MAP } from '../layer';
import Base from './base';
import LoadImage from './image';
import WorkerPool from './worker';
// import WorkerPool from './worker';
// import { MapProvider } from '../map/AMap';
import { getMap } from '../map/index';
import Global from '../global';
@ -22,7 +22,7 @@ export default class Scene extends Base {
_initEngine(mapContainer) {
this._engine = new Engine(mapContainer, this);
this._engine.run();
this.workerPool = new WorkerPool();
// this.workerPool = new WorkerPool();
compileBuiltinModules();
}
// 为pickup场景添加 object 对象

View File

@ -1,4 +1,3 @@
import Worker from '../worker/main.worker.js';
class WorkerPool {
constructor(workerCount) {
this.workerCount = workerCount || Math.max(Math.floor(window.navigator.hardwareConcurrency / 2), 1);

View File

@ -1,2 +0,0 @@

View File

@ -1,3 +1,4 @@
import Source from '../core//source';
this.addEventListener('message', e => {
const res = e.data;
// res = {