Skip to content

Commit

Permalink
fix: replace treeShake with globalImports (#239)
Browse files Browse the repository at this point in the history
* fix inconsistency by replacing treeShake with globalImports

treeShake has been renamed to globalImports everywhere except for plugin.js This is fixes with this pull request

* Update plugin.ts

* Update plugin.js

The Vuetify module will always now import Vuetify from vuetify/lib which will provide natural tree shaking with Webpack.

* Update plugin.ts

* Update plugin.ts

* Update plugin.js
  • Loading branch information
husayt authored and kevinmarrec committed Jan 17, 2020
1 parent a6fb8b8 commit 48e6bef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ export default function setupPlugin (this: ModuleThis, options: Options) {
src: path.resolve(__dirname, '../templates', 'plugin.js'),
options: {
defaultIconPreset: options.defaultAssets && options.defaultAssets.icons,
preset: options.preset,
treeShake: true
globalImports: options.globalImports,
preset: options.preset
}
})
}
14 changes: 7 additions & 7 deletions templates/plugin.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Vue from 'vue'
import Vuetify from '<%= options.treeShake ? 'vuetify/lib' : 'vuetify' %>'
import Vuetify from 'vuetify/lib'
<% if (options.preset) { %>
import { preset } from '<%= options.preset %>'
<% } %>
Expand All @@ -10,11 +10,11 @@ const libImports = [
{ key: 'transitions', location: 'vuetify/lib'},
{ key: 'directives', location: 'vuetify/lib/directives'}
]
if (options.treeShake) {
if (options.globalImports) {
for (const lib of libImports) {
if (options.treeShake[lib.key] && options.treeShake[lib.key].length > 0) {
if (options.globalImports[lib.key] && options.globalImports[lib.key].length > 0) {
%>
import { <%= options.treeShake[lib.key].join(', ') %> } from '<%= lib.location %>'
import { <%= options.globalImports[lib.key].join(', ') %> } from '<%= lib.location %>'
<%
}
}
Expand All @@ -24,9 +24,9 @@ import { <%= options.treeShake[lib.key].join(', ') %> } from '<%= lib.location %
import options from './options'

Vue.use(Vuetify, {
<% if (options.treeShake) { %>
<%= libImports.filter(lib => options.treeShake[lib.key] && options.treeShake[lib.key].length > 0)
.map(lib => ` ${lib.key}: { ${options.treeShake[lib.key].join(', ')} }`)
<% if (options.globalImports) { %>
<%= libImports.filter(lib => options.globalImports[lib.key] && options.globalImports[lib.key].length > 0)
.map(lib => ` ${lib.key}: { ${options.globalImports[lib.key].join(', ')} }`)
.join(',\n') %>
<% } %>
})
Expand Down

0 comments on commit 48e6bef

Please sign in to comment.