@meituan-nocode/vite-plugin-nocode-compiler 0.1.0-beta.23-z → 0.1.0-beta.24-z

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 CHANGED
@@ -25,14 +25,6 @@ __export(index_exports, {
25
25
  });
26
26
  module.exports = __toCommonJS(index_exports);
27
27
  var import_nocode_compiler_core = require("@meituan-nocode/nocode-compiler-core");
28
-
29
- // src/utils.ts
30
- var JsFileExtList = [".js", ".ts", ".mjs", ".mts", ".jsx", ".tsx"];
31
- function isJsTypeFile(file) {
32
- return JsFileExtList.some((ext) => file.endsWith(ext));
33
- }
34
-
35
- // src/index.ts
36
28
  function componentCompiler(options = {}) {
37
29
  options = {
38
30
  enableLogging: false,
@@ -47,31 +39,15 @@ function componentCompiler(options = {}) {
47
39
  if (id.includes("node_modules")) {
48
40
  return code;
49
41
  }
50
- const [_completePath, query] = id.split("?", 2);
51
- let filePath = _completePath;
52
- const params = new URLSearchParams(query);
53
- const isJsTypeFileResult = isJsTypeFile(filePath);
54
- const isVueFile = filePath.endsWith(".vue");
55
- const isHtmlFile = filePath.endsWith(".html");
56
- const type = params.get("type");
57
- const lang = params.get("lang");
58
- const isTemplateType = type === "template";
59
- const isScriptType = type === "script";
60
- const isJsxLang = lang === "tsx" || lang === "jsx";
61
- const isRawType = params.get("raw") !== null;
62
- if (isVueFile && isScriptType && isJsxLang) {
63
- return jsxCompiler.compile(code, filePath) || code;
64
- }
65
- if (isVueFile && isTemplateType) {
66
- return vueCompiler.compile(code, filePath) || code;
67
- }
68
- if (isHtmlFile && isTemplateType && params.has("vue")) {
69
- return vueCompiler.compile(code, filePath) || code;
70
- }
71
- if (isJsTypeFileResult && !isVueFile) {
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) {
72
48
  return jsxCompiler.compile(code, filePath) || code;
73
49
  }
74
- if (isVueFile && !type && !isRawType) {
50
+ if (useVueCompiler) {
75
51
  return vueCompiler.compile(code, filePath) || code;
76
52
  }
77
53
  return code;
package/dist/index.js CHANGED
@@ -1,13 +1,5 @@
1
1
  // src/index.ts
2
- import { JSXCompiler, VueCompiler } from "@meituan-nocode/nocode-compiler-core";
3
-
4
- // src/utils.ts
5
- var JsFileExtList = [".js", ".ts", ".mjs", ".mts", ".jsx", ".tsx"];
6
- function isJsTypeFile(file) {
7
- return JsFileExtList.some((ext) => file.endsWith(ext));
8
- }
9
-
10
- // src/index.ts
2
+ import { JSXCompiler, VueCompiler, detectCompileScenario } from "@meituan-nocode/nocode-compiler-core";
11
3
  function componentCompiler(options = {}) {
12
4
  options = {
13
5
  enableLogging: false,
@@ -22,31 +14,15 @@ function componentCompiler(options = {}) {
22
14
  if (id.includes("node_modules")) {
23
15
  return code;
24
16
  }
25
- const [_completePath, query] = id.split("?", 2);
26
- let filePath = _completePath;
27
- const params = new URLSearchParams(query);
28
- const isJsTypeFileResult = isJsTypeFile(filePath);
29
- const isVueFile = filePath.endsWith(".vue");
30
- const isHtmlFile = filePath.endsWith(".html");
31
- const type = params.get("type");
32
- const lang = params.get("lang");
33
- const isTemplateType = type === "template";
34
- const isScriptType = type === "script";
35
- const isJsxLang = lang === "tsx" || lang === "jsx";
36
- const isRawType = params.get("raw") !== null;
37
- if (isVueFile && isScriptType && isJsxLang) {
38
- return jsxCompiler.compile(code, filePath) || code;
39
- }
40
- if (isVueFile && isTemplateType) {
41
- return vueCompiler.compile(code, filePath) || code;
42
- }
43
- if (isHtmlFile && isTemplateType && params.has("vue")) {
44
- return vueCompiler.compile(code, filePath) || code;
45
- }
46
- if (isJsTypeFileResult && !isVueFile) {
17
+ const [filePath, query] = id.split("?", 2);
18
+ const { useJSXCompiler, useVueCompiler } = detectCompileScenario({
19
+ filePath,
20
+ query
21
+ });
22
+ if (useJSXCompiler) {
47
23
  return jsxCompiler.compile(code, filePath) || code;
48
24
  }
49
- if (isVueFile && !type && !isRawType) {
25
+ if (useVueCompiler) {
50
26
  return vueCompiler.compile(code, filePath) || code;
51
27
  }
52
28
  return code;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meituan-nocode/vite-plugin-nocode-compiler",
3
- "version": "0.1.0-beta.23-z",
3
+ "version": "0.1.0-beta.24-z",
4
4
  "description": "Vite plugin for nocode compiler",
5
5
  "type": "module",
6
6
  "exports": {
@@ -28,6 +28,6 @@
28
28
  "tsup": "8.5.0"
29
29
  },
30
30
  "dependencies": {
31
- "@meituan-nocode/nocode-compiler-core": "0.1.0-beta.23-z"
31
+ "@meituan-nocode/nocode-compiler-core": "0.1.0-beta.24-z"
32
32
  }
33
33
  }