@vizejs/vite-plugin 0.0.1-alpha.8 → 0.0.1-alpha.81

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/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@vizejs/vite-plugin",
3
- "version": "0.0.1-alpha.8",
3
+ "version": "0.0.1-alpha.81",
4
4
  "description": "High-performance native Vite plugin for Vue SFC compilation powered by Vize",
5
5
  "publishConfig": {
6
- "provenance": false,
6
+ "provenance": true,
7
7
  "access": "public"
8
8
  },
9
9
  "type": "module",
@@ -15,10 +15,6 @@
15
15
  "types": "./dist/index.d.ts"
16
16
  }
17
17
  },
18
- "scripts": {
19
- "build": "tsc",
20
- "dev": "tsc --watch"
21
- },
22
18
  "files": [
23
19
  "dist"
24
20
  ],
@@ -31,17 +27,31 @@
31
27
  "native",
32
28
  "fast"
33
29
  ],
34
- "license": "MIT",
35
- "dependencies": {
36
- "@vizejs/native": "workspace:*",
37
- "tinyglobby": "^0.2.0"
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "https://github.com/ubugeeei/vize",
33
+ "directory": "npm/vite-plugin-vize"
38
34
  },
35
+ "license": "MIT",
39
36
  "devDependencies": {
40
37
  "@types/node": "^22.0.0",
38
+ "tsdown": "^0.9.0",
41
39
  "typescript": "~5.6.0",
42
- "vite": "^7.3.1"
40
+ "vite": "^8.0.0-beta.0"
43
41
  },
44
42
  "peerDependencies": {
45
- "vite": "^5.0.0 || ^6.0.0 || ^7.0.0"
43
+ "vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-beta.0"
44
+ },
45
+ "dependencies": {
46
+ "tinyglobby": "^0.2.0",
47
+ "@vizejs/native": "0.0.1-alpha.81"
48
+ },
49
+ "scripts": {
50
+ "build": "tsdown",
51
+ "dev": "tsdown --watch",
52
+ "lint": "oxlint --deny-warnings --type-aware --tsconfig tsconfig.json",
53
+ "lint:fix": "oxlint --type-aware --tsconfig tsconfig.json --fix",
54
+ "fmt": "oxfmt --write src",
55
+ "fmt:check": "oxfmt src"
46
56
  }
47
- }
57
+ }
@@ -1,6 +0,0 @@
1
- import type { CompileSfcFn, CompiledModule } from './types.js';
2
- export declare function loadNative(): CompileSfcFn;
3
- export declare function compileFile(filePath: string, cache: Map<string, CompiledModule>, options: {
4
- sourceMap: boolean;
5
- ssr: boolean;
6
- }, source?: string): CompiledModule;
package/dist/compiler.js DELETED
@@ -1,46 +0,0 @@
1
- import fs from 'node:fs';
2
- import { createRequire } from 'node:module';
3
- import { generateScopeId } from './utils.js';
4
- const require = createRequire(import.meta.url);
5
- let compileSfc = null;
6
- export function loadNative() {
7
- if (compileSfc)
8
- return compileSfc;
9
- try {
10
- const native = require('@vizejs/native');
11
- compileSfc = native.compileSfc;
12
- return compileSfc;
13
- }
14
- catch (e) {
15
- throw new Error(`Failed to load @vizejs/native. Make sure it's installed and built:\n${e}`);
16
- }
17
- }
18
- export function compileFile(filePath, cache, options, source) {
19
- const compile = loadNative();
20
- const content = source ?? fs.readFileSync(filePath, 'utf-8');
21
- const scopeId = generateScopeId(filePath);
22
- const hasScoped = /<style[^>]*\bscoped\b/.test(content);
23
- const result = compile(content, {
24
- filename: filePath,
25
- sourceMap: options.sourceMap,
26
- ssr: options.ssr,
27
- scopeId: hasScoped ? `data-v-${scopeId}` : undefined,
28
- });
29
- if (result.errors.length > 0) {
30
- const errorMsg = result.errors.join('\n');
31
- console.error(`[vize] Compilation error in ${filePath}:\n${errorMsg}`);
32
- }
33
- if (result.warnings.length > 0) {
34
- result.warnings.forEach((warning) => {
35
- console.warn(`[vize] Warning in ${filePath}: ${warning}`);
36
- });
37
- }
38
- const compiled = {
39
- code: result.code,
40
- css: result.css,
41
- scopeId,
42
- hasScoped,
43
- };
44
- cache.set(filePath, compiled);
45
- return compiled;
46
- }
package/dist/types.d.ts DELETED
@@ -1,66 +0,0 @@
1
- export interface SfcCompileOptionsNapi {
2
- filename?: string;
3
- sourceMap?: boolean;
4
- ssr?: boolean;
5
- scopeId?: string;
6
- }
7
- export interface SfcCompileResultNapi {
8
- code: string;
9
- css?: string;
10
- errors: string[];
11
- warnings: string[];
12
- }
13
- export type CompileSfcFn = (source: string, options?: SfcCompileOptionsNapi) => SfcCompileResultNapi;
14
- export interface VizeOptions {
15
- /**
16
- * Files to include in compilation
17
- * @default /\.vue$/
18
- */
19
- include?: string | RegExp | (string | RegExp)[];
20
- /**
21
- * Files to exclude from compilation
22
- * @default /node_modules/
23
- */
24
- exclude?: string | RegExp | (string | RegExp)[];
25
- /**
26
- * Force production mode
27
- * @default auto-detected from Vite config
28
- */
29
- isProduction?: boolean;
30
- /**
31
- * Enable SSR mode
32
- * @default false
33
- */
34
- ssr?: boolean;
35
- /**
36
- * Enable source map generation
37
- * @default true in development, false in production
38
- */
39
- sourceMap?: boolean;
40
- /**
41
- * Enable Vapor mode compilation
42
- * @default false
43
- */
44
- vapor?: boolean;
45
- /**
46
- * Root directory to scan for .vue files
47
- * @default Vite's root
48
- */
49
- root?: string;
50
- /**
51
- * Glob patterns to scan for .vue files during pre-compilation
52
- * @default ['**\/*.vue']
53
- */
54
- scanPatterns?: string[];
55
- /**
56
- * Glob patterns to ignore during pre-compilation
57
- * @default ['node_modules/**', 'dist/**', '.git/**']
58
- */
59
- ignorePatterns?: string[];
60
- }
61
- export interface CompiledModule {
62
- code: string;
63
- css?: string;
64
- scopeId: string;
65
- hasScoped: boolean;
66
- }
package/dist/types.js DELETED
@@ -1 +0,0 @@
1
- export {};
package/dist/utils.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import type { CompiledModule } from './types.js';
2
- export declare function generateScopeId(filename: string): string;
3
- export declare function createFilter(include?: string | RegExp | (string | RegExp)[], exclude?: string | RegExp | (string | RegExp)[]): (id: string) => boolean;
4
- export declare function generateOutput(compiled: CompiledModule, isProduction: boolean, isDev: boolean): string;
package/dist/utils.js DELETED
@@ -1,71 +0,0 @@
1
- import { createHash } from 'node:crypto';
2
- export function generateScopeId(filename) {
3
- const hash = createHash('sha256').update(filename).digest('hex');
4
- return hash.slice(0, 8);
5
- }
6
- export function createFilter(include, exclude) {
7
- const includePatterns = include
8
- ? Array.isArray(include)
9
- ? include
10
- : [include]
11
- : [/\.vue$/];
12
- const excludePatterns = exclude
13
- ? Array.isArray(exclude)
14
- ? exclude
15
- : [exclude]
16
- : [/node_modules/];
17
- return (id) => {
18
- const matchInclude = includePatterns.some((pattern) => typeof pattern === 'string' ? id.includes(pattern) : pattern.test(id));
19
- const matchExclude = excludePatterns.some((pattern) => typeof pattern === 'string' ? id.includes(pattern) : pattern.test(id));
20
- return matchInclude && !matchExclude;
21
- };
22
- }
23
- export function generateOutput(compiled, isProduction, isDev) {
24
- let output = compiled.code;
25
- // Rewrite "export default" to named variable for HMR
26
- const hasExportDefault = output.includes('export default');
27
- if (hasExportDefault) {
28
- output = output.replace('export default', 'const _sfc_main =');
29
- output += '\nexport default _sfc_main;';
30
- }
31
- // Inject CSS
32
- if (compiled.css) {
33
- const cssCode = JSON.stringify(compiled.css);
34
- const cssId = JSON.stringify(`vize-style-${compiled.scopeId}`);
35
- output = `
36
- const __vize_css__ = ${cssCode};
37
- const __vize_css_id__ = ${cssId};
38
- (function() {
39
- if (typeof document !== 'undefined') {
40
- let style = document.getElementById(__vize_css_id__);
41
- if (!style) {
42
- style = document.createElement('style');
43
- style.id = __vize_css_id__;
44
- style.textContent = __vize_css__;
45
- document.head.appendChild(style);
46
- } else {
47
- style.textContent = __vize_css__;
48
- }
49
- }
50
- })();
51
- ${output}`;
52
- }
53
- // Add HMR support in development
54
- if (!isProduction && isDev && hasExportDefault) {
55
- output += `
56
- if (import.meta.hot) {
57
- _sfc_main.__hmrId = ${JSON.stringify(compiled.scopeId)};
58
- import.meta.hot.accept((mod) => {
59
- if (!mod) return;
60
- const { default: updated } = mod;
61
- if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
62
- __VUE_HMR_RUNTIME__.reload(_sfc_main.__hmrId, updated);
63
- }
64
- });
65
- if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
66
- __VUE_HMR_RUNTIME__.createRecord(_sfc_main.__hmrId, _sfc_main);
67
- }
68
- }`;
69
- }
70
- return output;
71
- }