Skip to content

Commit

Permalink
Removed uglify because of es6 issues when building. Added loaded prom…
Browse files Browse the repository at this point in the history
…ise to exports. You can now import { loaded } from the node_module and then do await loaded, to wait until the maps api has loaded.
  • Loading branch information
mattiasahlsen committed Aug 21, 2020
1 parent 8d6bbac commit ea746e2
Show file tree
Hide file tree
Showing 8 changed files with 9,989 additions and 10,077 deletions.
6 changes: 0 additions & 6 deletions config/webpack.production.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const path = require('path')
const VueLoaderPlugin = require('vue-loader/lib/plugin')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin')

const config = {
Expand All @@ -9,11 +8,6 @@ const config = {
],
optimization: {
minimizer: [
new UglifyJsPlugin({
cache: true,
parallel: true,
sourceMap: true
}),
new OptimizeCSSAssetsPlugin({})
]
},
Expand Down
Empty file modified dist/.babelrc
100755 → 100644
Empty file.
3,258 changes: 3,257 additions & 1 deletion dist/vue-google-maps.js
100755 → 100644

Large diffs are not rendered by default.

10,067 changes: 0 additions & 10,067 deletions package-lock.json

This file was deleted.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
},
"homepage": "https://github.com/xkjyeah/vue-google-maps#readme",
"dependencies": {
"marker-clusterer-plus": "^2.1.4"
"marker-clusterer-plus": "^2.1.4",
"terser-webpack-plugin": "^4.1.0"
},
"peerDependencies": {
"vue": "^2.6.10"
Expand Down
11 changes: 9 additions & 2 deletions src/factories/promise-lazy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import lazy from '../utils/lazy-value'

let resolveLoaded
let rejectLoaded
export const loaded = new Promise((resolve, reject) => {
resolveLoaded = resolve
rejectLoaded = reject
})

export default function (loadGmapApi, GmapApi) {
return function promiseLazyCreator (options) {
// Things to do once the API is loaded
Expand All @@ -21,7 +28,7 @@ export default function (loadGmapApi, GmapApi) {
} catch (err) {
reject(err)
}
}).then(onApiLoaded)
}).then(onApiLoaded).then(resolveLoaded).catch(rejectLoaded)
}
})
} else { // If library should not handle API, provide
Expand All @@ -33,7 +40,7 @@ export default function (loadGmapApi, GmapApi) {
return
}
window.vueGoogleMapsInit = resolve
}).then(onApiLoaded)
}).then(onApiLoaded).then(resolveLoaded).catch(rejectLoaded)

return lazy(() => promise)
}
Expand Down
2 changes: 2 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import MapElementMixin from './mixins/map-element'
import MapElementFactory from './factories/map-element'
import MountableMixin from './mixins/mountable'

export { loaded } from './factories/promise-lazy'

// HACK: Cluster should be loaded conditionally
// However in the web version, it's not possible to write
// `import 'vue2-google-maps/src/components/cluster'`, so we need to
Expand Down
6,719 changes: 6,719 additions & 0 deletions yarn.lock

Large diffs are not rendered by default.

0 comments on commit ea746e2

Please sign in to comment.