-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix typescript issues, treeshaking adjustments, update deps (vue3 final)
- Loading branch information
Michael Dodge
committed
Oct 15, 2020
1 parent
ce2e17f
commit 4714291
Showing
15 changed files
with
105 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
<% if (version === 3) { -%> | ||
import { defineComponent, Plugin } from 'vue'; | ||
import { DefineComponent, Plugin } from 'vue'; | ||
|
||
<% } else { -%> | ||
import Vue, { PluginFunction, VueConstructor } from 'vue'; | ||
|
||
<% } -%> | ||
|
||
declare const <%-componentNamePascal%>: { install: <% if (version === 3) { %>Plugin['install']<% } else { %>PluginFunction<any><% } %> }; | ||
declare const <%-componentNamePascal%>: <% if (version === 3) { %>Exclude<Plugin['install'], undefined><% } else { %>PluginFunction<any><% } %>; | ||
export default <%-componentNamePascal%>; | ||
|
||
export const <%-componentNamePascal%>Sample: <% if (version === 3) { %>ReturnType<typeof defineComponent><% } else { %>VueConstructor<Vue><% } %>; | ||
export const <%-componentNamePascal%>Sample: <% if (version === 3) { %>DefineComponent<% } else { %>VueConstructor<Vue><% } %>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
declare module '*.vue' { | ||
<% if (version === 3) { -%> | ||
import { defineComponent } from 'vue'; | ||
import { DefineComponent } from 'vue'; | ||
|
||
const Component: ReturnType<typeof defineComponent> | ||
const Component: DefineComponent; | ||
export default Component; | ||
<% } else { -%> | ||
import Vue from 'vue'; | ||
export default Vue | ||
export default Vue; | ||
<% } -%> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
<% if (ts && version === 3) { -%> | ||
import { defineComponent, Plugin } from 'vue'; | ||
|
||
<% } -%> | ||
// iife/cjs usage extends esm default export - so import it all | ||
// import * as components from '@/lib-components/index'; | ||
import plugin, * as components from '@/entry.esm'; | ||
|
||
// Attach named exports directly to component. IIFE/CJS will | ||
// only expose one global var, with named exports exposed as properties of | ||
// that global var (eg. VivintIcon.iconList) | ||
<% if (ts && version === 3) { -%> | ||
type PluginObject = Plugin & { [key: string]: ReturnType<typeof defineComponent>; }; | ||
// Attach named exports directly to plugin. IIFE/CJS will | ||
// only expose one global var, with component exports exposed as properties of | ||
// that global var (eg. plugin.component) | ||
<% if (ts) { -%> | ||
type NamedExports = Exclude<typeof components, 'default'>; | ||
type ExtendedPlugin = typeof plugin & NamedExports; | ||
<% } -%> | ||
Object.entries(components).forEach(([componentName, component]) => { | ||
<% if (ts && version === 3) { -%> | ||
if (componentName !== 'default') (plugin as PluginObject)[componentName] = component as any as ReturnType<typeof defineComponent>; | ||
if (componentName !== 'default') { | ||
<% if (ts) { -%> | ||
const key = componentName as Exclude<keyof NamedExports, 'default'>; | ||
const val = component as Exclude<ExtendedPlugin, typeof plugin>; | ||
(plugin as ExtendedPlugin)[key] = val; | ||
<% } else { -%> | ||
if (componentName !== 'default') plugin[componentName] = component; | ||
plugin[componentName] = component; | ||
<% } -%> | ||
} | ||
}); | ||
|
||
export default plugin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
declare module '*.vue' { | ||
<% if (version === 3) { -%> | ||
import { defineComponent } from 'vue'; | ||
import { DefineComponent } from 'vue'; | ||
|
||
const Component: ReturnType<typeof defineComponent> | ||
const Component: DefineComponent; | ||
export default Component; | ||
<% } else { -%> | ||
import Vue from 'vue'; | ||
export default Vue | ||
export default Vue; | ||
<% } -%> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,8 @@ | ||
<% if (version === 3) { -%> | ||
import { defineComponent, Plugin } from 'vue'; | ||
|
||
type InstallableComponent = ReturnType<typeof defineComponent> & { install: Plugin['install'] }; | ||
import { DefineComponent, Plugin } from 'vue'; | ||
<% } else { -%> | ||
import Vue, { PluginFunction, VueConstructor } from 'vue'; | ||
|
||
export interface InstallableComponent extends VueConstructor<Vue> { | ||
install: PluginFunction<any>; | ||
} | ||
<% } -%> | ||
|
||
declare const <%-componentNamePascal%>: InstallableComponent; | ||
declare const <%-componentNamePascal%>: <% if (version === 3) { %>DefineComponent & { install: Exclude<Plugin['install'], undefined> }<% } else { %>VueConstructor<Vue> & { install: PluginFunction<any>; }<% } %>; | ||
export default <%-componentNamePascal%>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.