@vixt/uni 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,6 +1,37 @@
1
1
  import * as vite from 'vite';
2
2
  import * as _vixt_core from '@vixt/core';
3
+ import { AppOptions, PluginOptions, VixtOptions } from '@vixt/core';
4
+ import Uni from '@dcloudio/vite-plugin-uni';
5
+ import Pages from '@uni-helper/vite-plugin-uni-pages';
6
+ import Components from '@uni-helper/vite-plugin-uni-components';
7
+ import AutoImport from 'unplugin-auto-import/vite';
8
+ import UnoCSS from 'unocss/vite';
9
+
10
+ declare const entryUni: _vixt_core.VixtModule<AppOptions>;
11
+
12
+ declare module '@vixt/core' {
13
+ interface VixtOptions {
14
+ uni?: PluginOptions<typeof Uni>;
15
+ /** https://github.com/uni-helper/vite-plugin-uni-pages */
16
+ pages?: PluginOptions<typeof Pages>;
17
+ /** https://github.com/uni-helper/vite-plugin-uni-layouts */
18
+ layouts?: any;
19
+ /** https://github.com/uni-helper/vite-plugin-uni-components */
20
+ components?: PluginOptions<typeof Components>;
21
+ /** https://github.com/antfu/unplugin-auto-import */
22
+ imports?: PluginOptions<typeof AutoImport>;
23
+ /** https://github.com/antfu/unocss */
24
+ unocss?: PluginOptions<typeof UnoCSS>;
25
+ }
26
+ }
27
+ declare const presetUni: _vixt_core.VixtModule<VixtOptions>;
28
+
29
+ /** 增加小程序中vueuse的运行所需 */
30
+ declare function vueusePolyfill(code: string, id: string): string;
31
+ /** 移除路径中的'../' */
32
+ declare function patchNormalizeNodeModules(): void;
33
+ declare const uniPatch: (options?: any) => vite.PluginOption;
3
34
 
4
35
  declare const _default: (options?: _vixt_core.VixtOptions | undefined) => vite.PluginOption;
5
36
 
6
- export { _default as default };
37
+ export { _default as default, entryUni, patchNormalizeNodeModules, presetUni, uniPatch, vueusePolyfill };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,37 @@
1
1
  import * as vite from 'vite';
2
2
  import * as _vixt_core from '@vixt/core';
3
+ import { AppOptions, PluginOptions, VixtOptions } from '@vixt/core';
4
+ import Uni from '@dcloudio/vite-plugin-uni';
5
+ import Pages from '@uni-helper/vite-plugin-uni-pages';
6
+ import Components from '@uni-helper/vite-plugin-uni-components';
7
+ import AutoImport from 'unplugin-auto-import/vite';
8
+ import UnoCSS from 'unocss/vite';
9
+
10
+ declare const entryUni: _vixt_core.VixtModule<AppOptions>;
11
+
12
+ declare module '@vixt/core' {
13
+ interface VixtOptions {
14
+ uni?: PluginOptions<typeof Uni>;
15
+ /** https://github.com/uni-helper/vite-plugin-uni-pages */
16
+ pages?: PluginOptions<typeof Pages>;
17
+ /** https://github.com/uni-helper/vite-plugin-uni-layouts */
18
+ layouts?: any;
19
+ /** https://github.com/uni-helper/vite-plugin-uni-components */
20
+ components?: PluginOptions<typeof Components>;
21
+ /** https://github.com/antfu/unplugin-auto-import */
22
+ imports?: PluginOptions<typeof AutoImport>;
23
+ /** https://github.com/antfu/unocss */
24
+ unocss?: PluginOptions<typeof UnoCSS>;
25
+ }
26
+ }
27
+ declare const presetUni: _vixt_core.VixtModule<VixtOptions>;
28
+
29
+ /** 增加小程序中vueuse的运行所需 */
30
+ declare function vueusePolyfill(code: string, id: string): string;
31
+ /** 移除路径中的'../' */
32
+ declare function patchNormalizeNodeModules(): void;
33
+ declare const uniPatch: (options?: any) => vite.PluginOption;
3
34
 
4
35
  declare const _default: (options?: _vixt_core.VixtOptions | undefined) => vite.PluginOption;
5
36
 
6
- export { _default as default };
37
+ export { _default as default, entryUni, patchNormalizeNodeModules, presetUni, uniPatch, vueusePolyfill };
package/dist/index.mjs CHANGED
@@ -8,6 +8,7 @@ import Layouts from '@uni-helper/vite-plugin-uni-layouts';
8
8
  import Components from '@uni-helper/vite-plugin-uni-components';
9
9
  import AutoImport from 'unplugin-auto-import/vite';
10
10
  import UnoCSS from 'unocss/vite';
11
+ import { resolvePathSync } from 'mlly';
11
12
 
12
13
  function resolveLayersPlugins(layers, from) {
13
14
  const { plugins = [] } = resolveLayersDirs(layers);
@@ -23,11 +24,11 @@ function generateMainTs(options, vixt) {
23
24
  const code = `/** Generated by Vixt */
24
25
  // @ts-nocheck
25
26
  import { createSSRApp } from 'vue'
26
- import * as Pinia from 'pinia'
27
+ import * as Pinia from 'pinia'
27
28
  import { createUnistorage } from 'pinia-plugin-unistorage'
28
29
  import { pages } from 'virtual:uni-pages'
29
- import App from '@/App.vue'
30
30
 
31
+ import App from '@/App.vue'
31
32
  ${cssTemplate}
32
33
 
33
34
  export function createApp() {
@@ -46,8 +47,8 @@ export function createApp() {
46
47
  fs.outputFileSync(path.resolve(rootDir, buildDir, "main.ts"), code);
47
48
  return code;
48
49
  }
49
- const name$1 = "vixt:entry";
50
- const entry = defineVixtModule({
50
+ const name$1 = "vixt:entry-uni";
51
+ const entryUni = defineVixtModule({
51
52
  meta: { name: name$1, configKey: "app" },
52
53
  defaults: {
53
54
  css: ["virtual:uno.css"]
@@ -55,7 +56,7 @@ const entry = defineVixtModule({
55
56
  setup(options, vixt) {
56
57
  generateMainTs(options, vixt);
57
58
  return {
58
- name: "vixt:entry",
59
+ name: "vixt:entry-uni",
59
60
  enforce: "pre",
60
61
  transform(code, id) {
61
62
  const { buildDir, rootDir } = vixt.options;
@@ -118,7 +119,18 @@ export const TransitionGroup = {}
118
119
  `;
119
120
  return code;
120
121
  }
122
+ const matched = `str = normalizePath(str).replace(NODE_MODULES_REGEX, 'node-modules');`;
123
+ const replaced = `str = normalizePath(str).replace(NODE_MODULES_REGEX, 'node-modules').replace(/\\.\\.\\//g, '');`;
124
+ function patchNormalizeNodeModules() {
125
+ const codePath = resolvePathSync("@dcloudio/uni-cli-shared/dist/utils.js");
126
+ let code = fs.readFileSync(codePath, "utf8");
127
+ if (code.includes(matched)) {
128
+ code = code.replace(matched, replaced);
129
+ fs.writeFileSync(codePath, code);
130
+ }
131
+ }
121
132
  const uniPatch = defineVitePlugin(() => {
133
+ patchNormalizeNodeModules();
122
134
  return {
123
135
  name: "vixt:uni-patch",
124
136
  transform(code, id) {
@@ -129,7 +141,7 @@ const uniPatch = defineVitePlugin(() => {
129
141
  });
130
142
 
131
143
  const defaults = {
132
- modules: [entry, presetUni],
144
+ modules: [entryUni, presetUni],
133
145
  app: {
134
146
  head: {
135
147
  link: [{ rel: "icon", href: "/static/favicon.ico" }]
@@ -144,4 +156,4 @@ const defaults = {
144
156
  };
145
157
  const index = createVixtPlugin({ defaults });
146
158
 
147
- export { index as default };
159
+ export { index as default, entryUni, patchNormalizeNodeModules, presetUni, uniPatch, vueusePolyfill };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vixt/uni",
3
3
  "type": "module",
4
- "version": "0.0.6",
4
+ "version": "0.0.7",
5
5
  "author": "SoulLyoko<https://github.com/SoulLyoko>",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/SoulLyoko/vixt#readme",
@@ -31,7 +31,7 @@
31
31
  "unocss": "^0.61.0",
32
32
  "unplugin-auto-import": "^0.17.6",
33
33
  "vue": "^3.4.31",
34
- "@vixt/core": "0.0.6"
34
+ "@vixt/core": "0.0.7"
35
35
  },
36
36
  "scripts": {
37
37
  "build": "unbuild"