├── packages ├── vite-html-plugin │ ├── .gitignore │ ├── tsconfig.json │ ├── CHANGELOG.md │ ├── vite.config.ts │ ├── package.json │ ├── README.md │ └── src │ │ └── index.ts ├── vite-plugin-utils │ ├── index.ts │ ├── README.md │ ├── tsconfig.json │ ├── package.json │ ├── constant │ │ └── index.ts │ ├── sort-plugin │ │ ├── index.ts │ │ └── index.txt │ └── function │ │ └── index.ts ├── vite-plugin-fast-external │ ├── index.d.ts │ ├── presets │ │ ├── redux-v5.js │ │ ├── vuex-v3.js │ │ ├── vuex-v4.js │ │ ├── vue-v2.js │ │ ├── react-dom-v17.js │ │ ├── react-dom-v18.js │ │ ├── pinia-v2.js │ │ ├── react-router-v5.js │ │ ├── react-router-dom-v5.js │ │ ├── vue-router-v4.js │ │ ├── react-v17.js │ │ ├── react-router-v6.js │ │ ├── react-v18.js │ │ ├── react-router-dom-v6.js │ │ ├── index.d.ts │ │ ├── vue-composition-api.js │ │ ├── antd-v4.js │ │ ├── ant-design-vue-v1.js │ │ ├── element-ui.js │ │ ├── vue-v3.js │ │ ├── index.js │ │ ├── element-plus.js │ │ └── ant-design-vue-v3.js │ ├── package.json │ ├── index.js │ ├── README.zh-CN.md │ └── README.md ├── viters │ └── package.json ├── vite-utils │ └── package.json ├── create-viters │ └── package.json └── vite-plugin-angular │ └── package.json ├── pnpm-workspace.yaml ├── playground ├── vite-html-plugin │ ├── src │ │ ├── bar.js │ │ └── foo.js │ ├── public │ │ ├── foo.html │ │ └── bar.ejs.html │ ├── package.json │ └── vite.config.js └── vite-plugin-fast-external │ ├── public │ └── favicon.ico │ ├── package.json │ ├── index.html │ ├── main.js │ ├── react.html │ └── vite.config.js ├── package.json ├── LICENSE ├── README.md ├── .gitignore ├── README1.md ├── svg-gif.svg ├── README2.md ├── symbol.txt └── pnpm-lock.yaml /packages/vite-html-plugin/.gitignore: -------------------------------------------------------------------------------- 1 | /index.js 2 | /index.cjs 3 | /index.mjs -------------------------------------------------------------------------------- /pnpm-workspace.yaml: -------------------------------------------------------------------------------- 1 | packages: 2 | - 'packages/*' 3 | - 'playground/**' 4 | -------------------------------------------------------------------------------- /playground/vite-html-plugin/src/bar.js: -------------------------------------------------------------------------------- 1 | 2 | window.app.innerHTML = `
<%= JSON.stringify(user) %>10 | 11 | 12 | -------------------------------------------------------------------------------- /packages/vite-plugin-fast-external/index.d.ts: -------------------------------------------------------------------------------- 1 | import { Plugin } from 'vite'; 2 | 3 | export default external; 4 | declare const external: VitePluginFastExternal; 5 | 6 | export interface VitePluginFastExternal { 7 | (entries: Record
8 | import angular from '@angular/core'
9 |
10 | ${JSON.stringify(angular)}
11 |
12 | // ----------------------------------------
13 | import { createApp } from 'vue'
14 |
15 | ${createApp}
16 |
17 | // ----------------------------------------
18 |
19 | import { createApp } from 'pinia'
20 |
21 | ${createPinia}
22 |
23 | // ----------------------------------------
24 |
25 | import { createWebHashHistory } from 'vue-router'
26 |
27 | ${createWebHashHistory}
28 |
29 |
30 | `
31 |
--------------------------------------------------------------------------------
/packages/vite-plugin-fast-external/presets/vue-router-v4.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @type {import('.').LibMeta}
3 | */
4 | module.exports = {
5 | name: 'VueRouter',
6 | members: [
7 | 'NavigationFailureType',
8 | 'RouterLink',
9 | 'RouterView',
10 | 'START_LOCATION',
11 | 'createMemoryHistory',
12 | 'createRouter',
13 | 'createRouterMatcher',
14 | 'createWebHashHistory',
15 | 'createWebHistory',
16 | 'isNavigationFailure',
17 | 'matchedRouteKey',
18 | 'onBeforeRouteLeave',
19 | 'onBeforeRouteUpdate',
20 | 'parseQuery',
21 | 'routeLocationKey',
22 | 'routerKey',
23 | 'routerViewLocationKey',
24 | 'stringifyQuery',
25 | 'useLink',
26 | 'useRoute',
27 | 'useRouter',
28 | 'viewDepthKey',
29 | ],
30 | };
--------------------------------------------------------------------------------
/playground/vite-html-plugin/vite.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 | import html from 'vite-html-plugin'
3 |
4 | export default defineConfig({
5 | plugins: [
6 | html([
7 | {
8 | // Equivalent to
9 | // { 'foo.html': 'public/foo.html' }
10 | template: 'public/foo.html',
11 | inject: '/src/foo.js',
12 | },
13 | {
14 | template: {
15 | // Alias
16 | 'bar.html': 'public/bar.ejs.html',
17 | },
18 | inject: '/src/bar.js',
19 | transformIndexHtml: () => ({
20 | templateData: {
21 | // `ejs` template data
22 | user: {
23 | name: 'Kevin',
24 | age: '25',
25 | },
26 | },
27 | }),
28 | },
29 | ]),
30 | ],
31 | })
32 |
--------------------------------------------------------------------------------
/packages/vite-plugin-fast-external/presets/react-v17.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @type {import('.').LibMeta}
3 | */
4 | module.exports = {
5 | name: 'React',
6 | members: [
7 | 'Fragment',
8 | 'StrictMode',
9 | 'Profiler',
10 | 'Suspense',
11 | 'Children',
12 | 'Component',
13 | 'PureComponent',
14 | '__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED',
15 | 'cloneElement',
16 | 'createContext',
17 | 'createElement',
18 | 'createFactory',
19 | 'createRef',
20 | 'forwardRef',
21 | 'isValidElement',
22 | 'lazy',
23 | 'memo',
24 | 'useCallback',
25 | 'useContext',
26 | 'useDebugValue',
27 | 'useEffect',
28 | 'useImperativeHandle',
29 | 'useLayoutEffect',
30 | 'useMemo',
31 | 'useReducer',
32 | 'useRef',
33 | 'useState',
34 | 'version',
35 | ],
36 | };
--------------------------------------------------------------------------------
/packages/vite-html-plugin/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 | import { builtinModules } from 'module'
3 | import pkg from './package.json'
4 |
5 | export default defineConfig({
6 | build: {
7 | minify: false,
8 | emptyOutDir: false,
9 | outDir: '',
10 | target: 'node14',
11 | lib: {
12 | entry: 'src/index.ts',
13 | formats: ['cjs', 'es'],
14 | fileName: format => format === 'cjs' ? '[name].cjs' : '[name].js',
15 | },
16 | rollupOptions: {
17 | external: [
18 | 'electron',
19 | 'esbuild',
20 | 'vite',
21 | ...builtinModules,
22 | ...builtinModules.map(m => `node:${m}`),
23 | // @ts-ignore
24 | ...Object.keys(pkg.dependencies || {}),
25 | ],
26 | output: {
27 | exports: 'named',
28 | },
29 | },
30 | },
31 | })
32 |
--------------------------------------------------------------------------------
/packages/vite-plugin-fast-external/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vite-plugin-fast-external",
3 | "version": "2.5.1",
4 | "description": "Out of the box, built in Vue, React, Antd, Element and others",
5 | "main": "index.js",
6 | "repository": {
7 | "type": "git",
8 | "url": "git+https://github.com/caoxiemeihao/vite-plugins.git",
9 | "directory": "packages/vite-plugin-fast-external"
10 | },
11 | "readme": "https://github.com/caoxiemeihao/vite-plugins/tree/main/packages/vite-plugin-fast-external#readme",
12 | "author": "草鞋没号 <308487730@qq.com>",
13 | "license": "MIT",
14 | "scripts": {},
15 | "devDependencies": {
16 | "vite": "^3.x.x"
17 | },
18 | "keywords": [
19 | "vite",
20 | "plugin",
21 | "external",
22 | "vue",
23 | "react",
24 | "antd",
25 | "element",
26 | "composition-api"
27 | ]
28 | }
29 |
--------------------------------------------------------------------------------
/packages/vite-plugin-utils/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vite-plugin-utils",
3 | "description": "A collection of opinionated Vite plugin utils",
4 | "version": "0.2.1",
5 | "main": "dist/index.js",
6 | "repository": {
7 | "type": "git",
8 | "url": "git+https://github.com/caoxiemeihao/vite-plugins.git",
9 | "directory": "packages/utils"
10 | },
11 | "author": "草鞋没号 <308487730@qq.com>",
12 | "license": "MIT",
13 | "scripts": {
14 | "dev": "rm -rf dist && tsc --watch",
15 | "build": "rm -rf dist && tsc",
16 | "prepublishOnly": "npm run build"
17 | },
18 | "dependencies": {
19 | "acorn-walk": "^8.2.0",
20 | "fast-glob": "^3.2.11"
21 | },
22 | "devDependencies": {
23 | "vite": "^3.x.x"
24 | },
25 | "keywords": [
26 | "vite",
27 | "plugin",
28 | "utils"
29 | ],
30 | "files": [
31 | "dist"
32 | ]
33 | }
34 |
--------------------------------------------------------------------------------
/packages/vite-plugin-fast-external/presets/react-router-v6.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @type {import('.').LibMeta}
3 | */
4 | module.exports = {
5 | name: 'ReactRouter',
6 | members: [
7 | 'NavigationType',
8 | 'createPath',
9 | 'parsePath',
10 | 'MemoryRouter',
11 | 'Navigate',
12 | 'Outlet',
13 | 'Route',
14 | 'Router',
15 | 'Routes',
16 | 'UNSAFE_LocationContext',
17 | 'UNSAFE_NavigationContext',
18 | 'UNSAFE_RouteContext',
19 | 'createRoutesFromChildren',
20 | 'generatePath',
21 | 'matchPath',
22 | 'matchRoutes',
23 | 'renderMatches',
24 | 'resolvePath',
25 | 'useHref',
26 | 'useInRouterContext',
27 | 'useLocation',
28 | 'useMatch',
29 | 'useNavigate',
30 | 'useNavigationType',
31 | 'useOutlet',
32 | 'useOutletContext',
33 | 'useParams',
34 | 'useResolvedPath',
35 | 'useRoutes',
36 | ],
37 | };
38 |
--------------------------------------------------------------------------------
/packages/vite-plugin-fast-external/presets/react-v18.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @type {import('.').LibMeta}
3 | */
4 | module.exports = {
5 | name: 'React',
6 | members: [
7 | 'Children',
8 | 'Component',
9 | 'Fragment',
10 | 'Profiler',
11 | 'PureComponent',
12 | 'StrictMode',
13 | 'Suspense',
14 | '__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED',
15 | 'cloneElement',
16 | 'createContext',
17 | 'createElement',
18 | 'createFactory',
19 | 'createRef',
20 | 'forwardRef',
21 | 'isValidElement',
22 | 'lazy',
23 | 'memo',
24 | 'startTransition',
25 | 'unstable_act',
26 | 'useCallback',
27 | 'useContext',
28 | 'useDebugValue',
29 | 'useDeferredValue',
30 | 'useEffect',
31 | 'useId',
32 | 'useImperativeHandle',
33 | 'useInsertionEffect',
34 | 'useLayoutEffect',
35 | 'useMemo',
36 | 'useReducer',
37 | 'useRef',
38 | 'useState',
39 | 'useSyncExternalStore',
40 | 'useTransition',
41 | 'version',
42 | ],
43 | };
--------------------------------------------------------------------------------
/playground/vite-plugin-fast-external/react.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | | Name | 8 |Description | 9 |Npm | 10 | 11 | 12 |
|---|---|---|
| 14 | vite-plugin-fast-external 15 | | 16 |Without lexical transform, support custom external code | 17 |
18 |
19 | |
22 |
| 25 | vite-html-plugin 26 | | 27 |Enhance html template | 28 |
29 |
30 | |
33 |
| 36 | vite-plugin-utils 37 | | 38 |A collection of opinionated Vite plugin utils | 39 |
40 |
41 | |
44 |
| Name | 8 |Description | 9 |Npm | 10 | 11 | 12 |
|---|---|---|
| 14 | vite-plugin-resolve 15 | | 16 |
17 | Custom resolve code for vite
18 | 19 | Migrated 👉 vite-plugin/vite-plugin-resolve 20 | |
21 |
22 |
23 | |
29 |
| 32 | vite-plugin-commonjs 33 | | 34 |
35 | A pure JavaScript implementation of vite-plugin-commonjs
36 | 37 | Migrated 👉 vite-plugin/vite-plugin-commonjs 38 | |
39 |
40 |
41 | |
47 |
| 50 | vite-plugin-dynamic-import 51 | | 52 |
53 | Enhance the builtin dynamic import plugin of Vite
54 | 55 | Migrated 👉 vite-plugin/vite-plugin-dynamic-import 56 | |
57 |
58 |
59 | |
65 |
| 68 | vite-plugin-optimizer 69 | | 70 |
71 | Manually Pre-Bundling of Vite
72 | 73 | Migrated 👉 vite-plugin/vite-plugin-optimizer 74 | |
75 |
76 |
77 | |
83 |
| 86 | vite-plugin-esmodule 87 | | 88 |
89 | Build ES module to CommonJs module for Node.js
90 | 91 | Migrated 👉 vite-plugin/vite-plugin-esmodule 92 | |
93 |
94 |
95 | |
101 |
| 104 | vite-plugin-fast-external 105 | | 106 |Without lexical transform, support custom external code | 107 |
108 |
109 | |
115 |
| 118 | vite-plugin-lang-jsx 119 | | 120 |
121 | Automatically add lang="jsx" attribute for when using vite-plugin-vue2
122 | 123 | Migrated 👉 vite-plugin/vite-plugin-lang-jsx 124 | |
125 |
126 |
127 | |
133 |