From 528d62d329ba688d323db3452949853eb249f393 Mon Sep 17 00:00:00 2001 From: thinkinggis Date: Fri, 1 Mar 2019 11:23:01 +0800 Subject: [PATCH] feat(l7) add roullup --- rollup.config.js | 49 ++++++++++++++++++++++++ rollup/l7.js | 0 src/core/scene.js | 4 +- src/core/worker.js | 1 - src/worker/geojsonSourceWorker.js | 2 - src/worker/{main.worker.js => worker.js} | 1 + 6 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 rollup.config.js create mode 100644 rollup/l7.js delete mode 100644 src/worker/geojsonSourceWorker.js rename src/worker/{main.worker.js => worker.js} (92%) diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 0000000000..ae01cc922d --- /dev/null +++ b/rollup.config.js @@ -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; diff --git a/rollup/l7.js b/rollup/l7.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/core/scene.js b/src/core/scene.js index c86c5cf65c..0ab5e653f5 100644 --- a/src/core/scene.js +++ b/src/core/scene.js @@ -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 对象 diff --git a/src/core/worker.js b/src/core/worker.js index 91fcc4dd56..8d23b7e603 100644 --- a/src/core/worker.js +++ b/src/core/worker.js @@ -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); diff --git a/src/worker/geojsonSourceWorker.js b/src/worker/geojsonSourceWorker.js deleted file mode 100644 index 139597f9cb..0000000000 --- a/src/worker/geojsonSourceWorker.js +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/src/worker/main.worker.js b/src/worker/worker.js similarity index 92% rename from src/worker/main.worker.js rename to src/worker/worker.js index 1818813de2..cfa6aef6e3 100644 --- a/src/worker/main.worker.js +++ b/src/worker/worker.js @@ -1,3 +1,4 @@ +import Source from '../core//source'; this.addEventListener('message', e => { const res = e.data; // res = {