@valbuild/server 0.13.3 → 0.13.11

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.
@@ -748,6 +748,7 @@ class ValModuleLoader {
748
748
  }
749
749
  return ts__default["default"].transpile(code, {
750
750
  ...this.compilerOptions,
751
+ jsx: ts__default["default"].JsxEmit.React,
751
752
  // allowJs: true,
752
753
  // rootDir: this.compilerOptions.rootDir,
753
754
  module: ts__default["default"].ModuleKind.ESNext,
@@ -759,10 +760,13 @@ class ValModuleLoader {
759
760
 
760
761
  resolveModulePath(containingFilePath, requestedModuleName) {
761
762
  var _this$host$realpath, _this$host;
762
- const sourceFileName = this.sourceFileHandler.resolveSourceModulePath(containingFilePath, requestedModuleName);
763
+ let sourceFileName = this.sourceFileHandler.resolveSourceModulePath(containingFilePath, requestedModuleName);
764
+ if (requestedModuleName === "@vercel/stega") {
765
+ sourceFileName = this.sourceFileHandler.resolveSourceModulePath(containingFilePath, "@vercel/stega").replace("stega/dist", "stega/dist/esm");
766
+ }
763
767
  const matches = this.findMatchingJsFile(sourceFileName);
764
768
  if (matches.match === false) {
765
- throw Error(`Could not find matching js file for module "${requestedModuleName}". Tried:\n${matches.tried.join("\n")}`);
769
+ throw Error(`Could not find matching js file for module "${requestedModuleName}" requested by: "${containingFilePath}". Tried:\n${matches.tried.join("\n")}`);
766
770
  }
767
771
  const filePath = matches.match;
768
772
  // resolve all symlinks (preconstruct for example symlinks the dist folder)
@@ -820,6 +824,24 @@ async function newValQuickJSRuntime(quickJSModule, moduleLoader, {
820
824
  runtime.setMemoryLimit(memoryLimit);
821
825
  runtime.setModuleLoader(modulePath => {
822
826
  try {
827
+ // Special cases for next package:
828
+ // TODO: this is not stable, find a better way to do this
829
+ if (modulePath === "./autoTagJSX") {
830
+ return {
831
+ value: ""
832
+ }; // ignore this module, it's only used in the browser
833
+ }
834
+
835
+ if (modulePath === "@valbuild/react") {
836
+ return {
837
+ value: "export const useVal = () => { throw Error(`Cannot use 'useVal' in this type of file`) }; export function ValProvider() { throw Error(`Cannot use 'ValProvider' in this type of file`) }; export function ValRichText() { throw Error(`Cannot use 'ValRichText' in this type of file`)};"
838
+ };
839
+ }
840
+ if (modulePath === "./ValRichText") {
841
+ return {
842
+ value: "export function ValRichText() { throw Error(`Cannot use 'ValRichText' in this type of file`)};"
843
+ };
844
+ }
823
845
  return {
824
846
  value: moduleLoader.getModule(modulePath)
825
847
  };
@@ -830,6 +852,21 @@ async function newValQuickJSRuntime(quickJSModule, moduleLoader, {
830
852
  }
831
853
  }, (baseModuleName, requestedName) => {
832
854
  try {
855
+ if (requestedName === "./autoTagJSX") {
856
+ return {
857
+ value: requestedName
858
+ };
859
+ }
860
+ if (requestedName === "@valbuild/react") {
861
+ return {
862
+ value: requestedName
863
+ };
864
+ }
865
+ if (requestedName === "./ValRichText") {
866
+ return {
867
+ value: requestedName
868
+ };
869
+ }
833
870
  const modulePath = moduleLoader.resolveModulePath(baseModuleName, requestedName);
834
871
  return {
835
872
  value: modulePath
@@ -748,6 +748,7 @@ class ValModuleLoader {
748
748
  }
749
749
  return ts__default["default"].transpile(code, {
750
750
  ...this.compilerOptions,
751
+ jsx: ts__default["default"].JsxEmit.React,
751
752
  // allowJs: true,
752
753
  // rootDir: this.compilerOptions.rootDir,
753
754
  module: ts__default["default"].ModuleKind.ESNext,
@@ -759,10 +760,13 @@ class ValModuleLoader {
759
760
 
760
761
  resolveModulePath(containingFilePath, requestedModuleName) {
761
762
  var _this$host$realpath, _this$host;
762
- const sourceFileName = this.sourceFileHandler.resolveSourceModulePath(containingFilePath, requestedModuleName);
763
+ let sourceFileName = this.sourceFileHandler.resolveSourceModulePath(containingFilePath, requestedModuleName);
764
+ if (requestedModuleName === "@vercel/stega") {
765
+ sourceFileName = this.sourceFileHandler.resolveSourceModulePath(containingFilePath, "@vercel/stega").replace("stega/dist", "stega/dist/esm");
766
+ }
763
767
  const matches = this.findMatchingJsFile(sourceFileName);
764
768
  if (matches.match === false) {
765
- throw Error(`Could not find matching js file for module "${requestedModuleName}". Tried:\n${matches.tried.join("\n")}`);
769
+ throw Error(`Could not find matching js file for module "${requestedModuleName}" requested by: "${containingFilePath}". Tried:\n${matches.tried.join("\n")}`);
766
770
  }
767
771
  const filePath = matches.match;
768
772
  // resolve all symlinks (preconstruct for example symlinks the dist folder)
@@ -820,6 +824,24 @@ async function newValQuickJSRuntime(quickJSModule, moduleLoader, {
820
824
  runtime.setMemoryLimit(memoryLimit);
821
825
  runtime.setModuleLoader(modulePath => {
822
826
  try {
827
+ // Special cases for next package:
828
+ // TODO: this is not stable, find a better way to do this
829
+ if (modulePath === "./autoTagJSX") {
830
+ return {
831
+ value: ""
832
+ }; // ignore this module, it's only used in the browser
833
+ }
834
+
835
+ if (modulePath === "@valbuild/react") {
836
+ return {
837
+ value: "export const useVal = () => { throw Error(`Cannot use 'useVal' in this type of file`) }; export function ValProvider() { throw Error(`Cannot use 'ValProvider' in this type of file`) }; export function ValRichText() { throw Error(`Cannot use 'ValRichText' in this type of file`)};"
838
+ };
839
+ }
840
+ if (modulePath === "./ValRichText") {
841
+ return {
842
+ value: "export function ValRichText() { throw Error(`Cannot use 'ValRichText' in this type of file`)};"
843
+ };
844
+ }
823
845
  return {
824
846
  value: moduleLoader.getModule(modulePath)
825
847
  };
@@ -830,6 +852,21 @@ async function newValQuickJSRuntime(quickJSModule, moduleLoader, {
830
852
  }
831
853
  }, (baseModuleName, requestedName) => {
832
854
  try {
855
+ if (requestedName === "./autoTagJSX") {
856
+ return {
857
+ value: requestedName
858
+ };
859
+ }
860
+ if (requestedName === "@valbuild/react") {
861
+ return {
862
+ value: requestedName
863
+ };
864
+ }
865
+ if (requestedName === "./ValRichText") {
866
+ return {
867
+ value: requestedName
868
+ };
869
+ }
833
870
  const modulePath = moduleLoader.resolveModulePath(baseModuleName, requestedName);
834
871
  return {
835
872
  value: modulePath
@@ -735,6 +735,7 @@ class ValModuleLoader {
735
735
  }
736
736
  return ts.transpile(code, {
737
737
  ...this.compilerOptions,
738
+ jsx: ts.JsxEmit.React,
738
739
  // allowJs: true,
739
740
  // rootDir: this.compilerOptions.rootDir,
740
741
  module: ts.ModuleKind.ESNext,
@@ -746,10 +747,13 @@ class ValModuleLoader {
746
747
 
747
748
  resolveModulePath(containingFilePath, requestedModuleName) {
748
749
  var _this$host$realpath, _this$host;
749
- const sourceFileName = this.sourceFileHandler.resolveSourceModulePath(containingFilePath, requestedModuleName);
750
+ let sourceFileName = this.sourceFileHandler.resolveSourceModulePath(containingFilePath, requestedModuleName);
751
+ if (requestedModuleName === "@vercel/stega") {
752
+ sourceFileName = this.sourceFileHandler.resolveSourceModulePath(containingFilePath, "@vercel/stega").replace("stega/dist", "stega/dist/esm");
753
+ }
750
754
  const matches = this.findMatchingJsFile(sourceFileName);
751
755
  if (matches.match === false) {
752
- throw Error(`Could not find matching js file for module "${requestedModuleName}". Tried:\n${matches.tried.join("\n")}`);
756
+ throw Error(`Could not find matching js file for module "${requestedModuleName}" requested by: "${containingFilePath}". Tried:\n${matches.tried.join("\n")}`);
753
757
  }
754
758
  const filePath = matches.match;
755
759
  // resolve all symlinks (preconstruct for example symlinks the dist folder)
@@ -807,6 +811,24 @@ async function newValQuickJSRuntime(quickJSModule, moduleLoader, {
807
811
  runtime.setMemoryLimit(memoryLimit);
808
812
  runtime.setModuleLoader(modulePath => {
809
813
  try {
814
+ // Special cases for next package:
815
+ // TODO: this is not stable, find a better way to do this
816
+ if (modulePath === "./autoTagJSX") {
817
+ return {
818
+ value: ""
819
+ }; // ignore this module, it's only used in the browser
820
+ }
821
+
822
+ if (modulePath === "@valbuild/react") {
823
+ return {
824
+ value: "export const useVal = () => { throw Error(`Cannot use 'useVal' in this type of file`) }; export function ValProvider() { throw Error(`Cannot use 'ValProvider' in this type of file`) }; export function ValRichText() { throw Error(`Cannot use 'ValRichText' in this type of file`)};"
825
+ };
826
+ }
827
+ if (modulePath === "./ValRichText") {
828
+ return {
829
+ value: "export function ValRichText() { throw Error(`Cannot use 'ValRichText' in this type of file`)};"
830
+ };
831
+ }
810
832
  return {
811
833
  value: moduleLoader.getModule(modulePath)
812
834
  };
@@ -817,6 +839,21 @@ async function newValQuickJSRuntime(quickJSModule, moduleLoader, {
817
839
  }
818
840
  }, (baseModuleName, requestedName) => {
819
841
  try {
842
+ if (requestedName === "./autoTagJSX") {
843
+ return {
844
+ value: requestedName
845
+ };
846
+ }
847
+ if (requestedName === "@valbuild/react") {
848
+ return {
849
+ value: requestedName
850
+ };
851
+ }
852
+ if (requestedName === "./ValRichText") {
853
+ return {
854
+ value: requestedName
855
+ };
856
+ }
820
857
  const modulePath = moduleLoader.resolveModulePath(baseModuleName, requestedName);
821
858
  return {
822
859
  value: modulePath
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "./package.json": "./package.json"
13
13
  },
14
14
  "types": "dist/valbuild-server.cjs.d.ts",
15
- "version": "0.13.3",
15
+ "version": "0.13.11",
16
16
  "scripts": {
17
17
  "typecheck": "tsc --noEmit",
18
18
  "test": "jest",
@@ -25,8 +25,8 @@
25
25
  "concurrently": "^7.6.0"
26
26
  },
27
27
  "dependencies": {
28
- "@valbuild/core": "~0.13.3",
29
- "@valbuild/ui": "~0.13.3",
28
+ "@valbuild/core": "~0.13.4",
29
+ "@valbuild/ui": "~0.13.4",
30
30
  "express": "^4.18.2",
31
31
  "quickjs-emscripten": "^0.21.1",
32
32
  "ts-morph": "^17.0.1",
@@ -56,6 +56,7 @@ export class ValModuleLoader {
56
56
  }
57
57
  return ts.transpile(code, {
58
58
  ...this.compilerOptions,
59
+ jsx: ts.JsxEmit.React,
59
60
  // allowJs: true,
60
61
  // rootDir: this.compilerOptions.rootDir,
61
62
  module: ts.ModuleKind.ESNext,
@@ -69,14 +70,20 @@ export class ValModuleLoader {
69
70
  containingFilePath: string,
70
71
  requestedModuleName: string
71
72
  ): string {
72
- const sourceFileName = this.sourceFileHandler.resolveSourceModulePath(
73
+ let sourceFileName = this.sourceFileHandler.resolveSourceModulePath(
73
74
  containingFilePath,
74
75
  requestedModuleName
75
76
  );
77
+
78
+ if (requestedModuleName === "@vercel/stega") {
79
+ sourceFileName = this.sourceFileHandler
80
+ .resolveSourceModulePath(containingFilePath, "@vercel/stega")
81
+ .replace("stega/dist", "stega/dist/esm");
82
+ }
76
83
  const matches = this.findMatchingJsFile(sourceFileName);
77
84
  if (matches.match === false) {
78
85
  throw Error(
79
- `Could not find matching js file for module "${requestedModuleName}". Tried:\n${matches.tried.join(
86
+ `Could not find matching js file for module "${requestedModuleName}" requested by: "${containingFilePath}". Tried:\n${matches.tried.join(
80
87
  "\n"
81
88
  )}`
82
89
  );
@@ -20,6 +20,24 @@ export async function newValQuickJSRuntime(
20
20
  runtime.setModuleLoader(
21
21
  (modulePath) => {
22
22
  try {
23
+ // Special cases for next package:
24
+ // TODO: this is not stable, find a better way to do this
25
+ if (modulePath === "./autoTagJSX") {
26
+ return { value: "" }; // ignore this module, it's only used in the browser
27
+ }
28
+ if (modulePath === "@valbuild/react") {
29
+ return {
30
+ value:
31
+ "export const useVal = () => { throw Error(`Cannot use 'useVal' in this type of file`) }; export function ValProvider() { throw Error(`Cannot use 'ValProvider' in this type of file`) }; export function ValRichText() { throw Error(`Cannot use 'ValRichText' in this type of file`)};",
32
+ };
33
+ }
34
+
35
+ if (modulePath === "./ValRichText") {
36
+ return {
37
+ value:
38
+ "export function ValRichText() { throw Error(`Cannot use 'ValRichText' in this type of file`)};",
39
+ };
40
+ }
23
41
  return { value: moduleLoader.getModule(modulePath) };
24
42
  } catch (e) {
25
43
  return {
@@ -29,6 +47,15 @@ export async function newValQuickJSRuntime(
29
47
  },
30
48
  (baseModuleName, requestedName): JSModuleNormalizeResult => {
31
49
  try {
50
+ if (requestedName === "./autoTagJSX") {
51
+ return { value: requestedName };
52
+ }
53
+ if (requestedName === "@valbuild/react") {
54
+ return { value: requestedName };
55
+ }
56
+ if (requestedName === "./ValRichText") {
57
+ return { value: requestedName };
58
+ }
32
59
  const modulePath = moduleLoader.resolveModulePath(
33
60
  baseModuleName,
34
61
  requestedName