@meituan-nocode/vite-plugin-nocode-compiler 0.2.2 → 0.2.3

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.cjs ADDED
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ componentCompiler: () => componentCompiler,
24
+ default: () => index_default
25
+ });
26
+ module.exports = __toCommonJS(index_exports);
27
+ var import_nocode_compiler_core = require("@meituan-nocode/nocode-compiler-core");
28
+ function componentCompiler(options = {}) {
29
+ options = {
30
+ enableLogging: false,
31
+ ...options
32
+ };
33
+ const vueCompiler = new import_nocode_compiler_core.VueCompiler(options);
34
+ const jsxCompiler = new import_nocode_compiler_core.JSXCompiler(options);
35
+ return {
36
+ name: "vite-plugin-nocode-compiler",
37
+ enforce: "pre",
38
+ async transform(code, id) {
39
+ if (id.includes("node_modules")) {
40
+ return code;
41
+ }
42
+ const [filePath, query] = id.split("?", 2);
43
+ const { useJSXCompiler, useVueCompiler } = (0, import_nocode_compiler_core.detectCompileScenario)({
44
+ filePath,
45
+ query
46
+ });
47
+ if (useJSXCompiler) {
48
+ return jsxCompiler.compile(code, filePath) || code;
49
+ }
50
+ if (useVueCompiler) {
51
+ return vueCompiler.compile(code, filePath) || code;
52
+ }
53
+ return code;
54
+ }
55
+ };
56
+ }
57
+ var index_default = componentCompiler;
58
+ // Annotate the CommonJS export names for ESM import in node:
59
+ 0 && (module.exports = {
60
+ componentCompiler
61
+ });
@@ -0,0 +1,15 @@
1
+ interface NocodeCompilerOptions {
2
+ enableLogging?: boolean;
3
+ rootPath?: string;
4
+ }
5
+ /**
6
+ * Vite插件
7
+ * 用于在构建过程中处理Vue和React组件,添加nocode相关的标记
8
+ */
9
+ declare function componentCompiler(options?: NocodeCompilerOptions): {
10
+ name: string;
11
+ enforce: "pre";
12
+ transform(code: string, id: string): Promise<string>;
13
+ };
14
+
15
+ export { type NocodeCompilerOptions, componentCompiler, componentCompiler as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meituan-nocode/vite-plugin-nocode-compiler",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "Vite plugin for nocode compiler",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -19,6 +19,6 @@
19
19
  "vite": "^5.4.0"
20
20
  },
21
21
  "dependencies": {
22
- "@meituan-nocode/nocode-compiler-core": "0.2.1"
22
+ "@meituan-nocode/nocode-compiler-core": "0.2.3"
23
23
  }
24
24
  }