Skip to content

Commit

Permalink
fix(lib): simplify component import from lib
Browse files Browse the repository at this point in the history
simplify component import from lib
  • Loading branch information
yogakurniawan committed Jul 12, 2020
1 parent c1a5459 commit 83bb59e
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 71 deletions.
2 changes: 1 addition & 1 deletion build/rollup.config.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import analyze from 'rollup-plugin-analyzer';
const config = require('../package.json');

export default {
input: 'src/lib/index.js',
input: 'src/lib/plugin.js',
plugins: [
resolve({
mainFields: ['module', 'jsnext:main', 'main', 'browser'],
Expand Down
36 changes: 1 addition & 35 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,3 @@
import utils, { defaultOptions } from './utils';
import VueTelInputVuetify from './vue-tel-input-vuetify.vue';

export function install(Vue, customOptions = {}) {
if (install.installed) return;
if (!customOptions || !customOptions.vuetify) {
return;
}
const { vuetify: vuetifyFramework } = customOptions;
install.installed = true;
install.vuetify = vuetifyFramework;
utils.options = {
...defaultOptions,
...customOptions,
};
Vue.use(vuetifyFramework);
Vue.component('vue-tel-input-vuetify', VueTelInputVuetify);
}

export { VueTelInputVuetify };

const plugin = {
install,
};

// Auto-install
let GlobalVue = null;
if (typeof window !== 'undefined') {
GlobalVue = window.Vue;
} else if (typeof global !== 'undefined') {
GlobalVue = global.Vue;
}
if (GlobalVue) {
GlobalVue.use(plugin);
}

export default plugin;
export default VueTelInputVuetify;
37 changes: 37 additions & 0 deletions lib/plugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import utils, { defaultOptions } from './utils';
import VueTelInputVuetify from './vue-tel-input-vuetify.vue';

export function install(Vue, customOptions = {}) {
if (install.installed) return;
if (!customOptions || !customOptions.vuetify) {
return;
}
const { vuetify: vuetifyFramework } = customOptions;
install.installed = true;
install.vuetify = vuetifyFramework;
utils.options = {
...defaultOptions,
...customOptions,
};
Vue.use(vuetifyFramework);
Vue.component('vue-tel-input-vuetify', VueTelInputVuetify);
}

export { VueTelInputVuetify };

const plugin = {
install,
};

// Auto-install
let GlobalVue = null;
if (typeof window !== 'undefined') {
GlobalVue = window.Vue;
} else if (typeof global !== 'undefined') {
GlobalVue = global.Vue;
}
if (GlobalVue) {
GlobalVue.use(plugin);
}

export default plugin;
36 changes: 1 addition & 35 deletions src/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,3 @@
import utils, { defaultOptions } from './utils';
import VueTelInputVuetify from './vue-tel-input-vuetify.vue';

export function install(Vue, customOptions = {}) {
if (install.installed) return;
if (!customOptions || !customOptions.vuetify) {
return;
}
const { vuetify: vuetifyFramework } = customOptions;
install.installed = true;
install.vuetify = vuetifyFramework;
utils.options = {
...defaultOptions,
...customOptions,
};
Vue.use(vuetifyFramework);
Vue.component('vue-tel-input-vuetify', VueTelInputVuetify);
}

export { VueTelInputVuetify };

const plugin = {
install,
};

// Auto-install
let GlobalVue = null;
if (typeof window !== 'undefined') {
GlobalVue = window.Vue;
} else if (typeof global !== 'undefined') {
GlobalVue = global.Vue;
}
if (GlobalVue) {
GlobalVue.use(plugin);
}

export default plugin;
export default VueTelInputVuetify;
37 changes: 37 additions & 0 deletions src/lib/plugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import utils, { defaultOptions } from './utils';
import VueTelInputVuetify from './vue-tel-input-vuetify.vue';

export function install(Vue, customOptions = {}) {
if (install.installed) return;
if (!customOptions || !customOptions.vuetify) {
return;
}
const { vuetify: vuetifyFramework } = customOptions;
install.installed = true;
install.vuetify = vuetifyFramework;
utils.options = {
...defaultOptions,
...customOptions,
};
Vue.use(vuetifyFramework);
Vue.component('vue-tel-input-vuetify', VueTelInputVuetify);
}

export { VueTelInputVuetify };

const plugin = {
install,
};

// Auto-install
let GlobalVue = null;
if (typeof window !== 'undefined') {
GlobalVue = window.Vue;
} else if (typeof global !== 'undefined') {
GlobalVue = global.Vue;
}
if (GlobalVue) {
GlobalVue.use(plugin);
}

export default plugin;

0 comments on commit 83bb59e

Please sign in to comment.