@mercurjs/dashboard-sdk 2.3.2-canary.2 → 2.3.2-canary.4

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.
Files changed (3) hide show
  1. package/dist/vite.cjs +33 -13
  2. package/dist/vite.js +33 -13
  3. package/package.json +1 -1
package/dist/vite.cjs CHANGED
@@ -364,7 +364,7 @@ function generateRoutes({ srcDir, pluginExtensions }) {
364
364
  }
365
365
  }
366
366
  const pluginDeclarations = pluginExtensions.map(
367
- (ext, i) => `const __plugin${i} = (await import("${normalizePath(ext)}")).default`
367
+ (ext, i) => `import __plugin${i} from "${normalizePath(ext)}"`
368
368
  );
369
369
  const pluginSpreads = pluginExtensions.map(
370
370
  (_, i) => ` ...(__plugin${i}.routeModule?.routes ?? [])`
@@ -581,7 +581,7 @@ function generateMenuItems({ srcDir, pluginExtensions }) {
581
581
  }
582
582
  }
583
583
  const pluginDeclarations = pluginExtensions.map(
584
- (ext, i) => `const __plugin${i} = (await import("${normalizePath(ext)}")).default`
584
+ (ext, i) => `import __plugin${i} from "${normalizePath(ext)}"`
585
585
  );
586
586
  const pluginSpreads = pluginExtensions.map(
587
587
  (_, i) => ` ...(__plugin${i}.menuItemModule?.menuItems ?? [])`
@@ -744,7 +744,7 @@ function generateWidgets({
744
744
  }) {
745
745
  const { imports, entries: widgetEntries } = collectWidgets(srcDir);
746
746
  const pluginDeclarations = pluginExtensions.map(
747
- (ext, i) => `const __plugin${i} = (await import("${normalizePath(ext)}")).default`
747
+ (ext, i) => `import __plugin${i} from "${normalizePath(ext)}"`
748
748
  );
749
749
  const pluginSpreads = pluginExtensions.map(
750
750
  (_, i) => ` ...(__plugin${i}.widgetModule?.widgets ?? [])`
@@ -928,19 +928,34 @@ function findNodeModulesRoot(configDir) {
928
928
  return import_path8.default.join(configDir, "node_modules");
929
929
  }
930
930
  function resolvePluginRoot(resolve, configDir, nodeModulesRoot) {
931
- try {
932
- if (resolve.startsWith(".")) {
931
+ if (resolve.startsWith(".")) {
932
+ try {
933
933
  const resolved = import_path8.default.resolve(configDir, resolve);
934
- if (import_fs7.default.existsSync(resolved)) {
935
- return import_fs7.default.realpathSync(resolved);
936
- }
934
+ return import_fs7.default.existsSync(resolved) ? import_fs7.default.realpathSync(resolved) : null;
935
+ } catch {
937
936
  return null;
938
937
  }
939
- const packagePath = import_path8.default.join(nodeModulesRoot, resolve);
940
- if (!import_fs7.default.existsSync(packagePath)) {
941
- return null;
938
+ }
939
+ const require2 = (0, import_module.createRequire)(import_path8.default.join(configDir, "noop.js"));
940
+ try {
941
+ return import_fs7.default.realpathSync(
942
+ import_path8.default.dirname(require2.resolve(`${resolve}/package.json`))
943
+ );
944
+ } catch {
945
+ }
946
+ try {
947
+ let dir = import_path8.default.dirname(require2.resolve(resolve));
948
+ while (dir !== import_path8.default.dirname(dir)) {
949
+ if (import_fs7.default.existsSync(import_path8.default.join(dir, "package.json"))) {
950
+ return import_fs7.default.realpathSync(dir);
951
+ }
952
+ dir = import_path8.default.dirname(dir);
942
953
  }
943
- return import_fs7.default.realpathSync(packagePath);
954
+ } catch {
955
+ }
956
+ try {
957
+ const packagePath = import_path8.default.join(nodeModulesRoot, resolve);
958
+ return import_fs7.default.existsSync(packagePath) ? import_fs7.default.realpathSync(packagePath) : null;
944
959
  } catch {
945
960
  return null;
946
961
  }
@@ -952,7 +967,12 @@ function resolvePluginExtensions(plugins, configDir, appType) {
952
967
  const resolve = typeof plugin === "string" ? plugin : plugin?.resolve;
953
968
  if (!resolve || typeof resolve !== "string") continue;
954
969
  const pluginRoot = resolvePluginRoot(resolve, configDir, nodeModulesRoot);
955
- if (!pluginRoot) continue;
970
+ if (!pluginRoot) {
971
+ console.warn(
972
+ `[@mercurjs/dashboard-sdk] Could not resolve plugin "${resolve}" from ${configDir}. Its ${appType} extensions will be missing from the build.`
973
+ );
974
+ continue;
975
+ }
956
976
  const extFile = import_path8.default.join(
957
977
  pluginRoot,
958
978
  ".medusa/server/src",
package/dist/vite.js CHANGED
@@ -344,7 +344,7 @@ function generateRoutes({ srcDir, pluginExtensions }) {
344
344
  }
345
345
  }
346
346
  const pluginDeclarations = pluginExtensions.map(
347
- (ext, i) => `const __plugin${i} = (await import("${normalizePath(ext)}")).default`
347
+ (ext, i) => `import __plugin${i} from "${normalizePath(ext)}"`
348
348
  );
349
349
  const pluginSpreads = pluginExtensions.map(
350
350
  (_, i) => ` ...(__plugin${i}.routeModule?.routes ?? [])`
@@ -561,7 +561,7 @@ function generateMenuItems({ srcDir, pluginExtensions }) {
561
561
  }
562
562
  }
563
563
  const pluginDeclarations = pluginExtensions.map(
564
- (ext, i) => `const __plugin${i} = (await import("${normalizePath(ext)}")).default`
564
+ (ext, i) => `import __plugin${i} from "${normalizePath(ext)}"`
565
565
  );
566
566
  const pluginSpreads = pluginExtensions.map(
567
567
  (_, i) => ` ...(__plugin${i}.menuItemModule?.menuItems ?? [])`
@@ -724,7 +724,7 @@ function generateWidgets({
724
724
  }) {
725
725
  const { imports, entries: widgetEntries } = collectWidgets(srcDir);
726
726
  const pluginDeclarations = pluginExtensions.map(
727
- (ext, i) => `const __plugin${i} = (await import("${normalizePath(ext)}")).default`
727
+ (ext, i) => `import __plugin${i} from "${normalizePath(ext)}"`
728
728
  );
729
729
  const pluginSpreads = pluginExtensions.map(
730
730
  (_, i) => ` ...(__plugin${i}.widgetModule?.widgets ?? [])`
@@ -908,19 +908,34 @@ function findNodeModulesRoot(configDir) {
908
908
  return path8.join(configDir, "node_modules");
909
909
  }
910
910
  function resolvePluginRoot(resolve, configDir, nodeModulesRoot) {
911
- try {
912
- if (resolve.startsWith(".")) {
911
+ if (resolve.startsWith(".")) {
912
+ try {
913
913
  const resolved = path8.resolve(configDir, resolve);
914
- if (fs7.existsSync(resolved)) {
915
- return fs7.realpathSync(resolved);
916
- }
914
+ return fs7.existsSync(resolved) ? fs7.realpathSync(resolved) : null;
915
+ } catch {
917
916
  return null;
918
917
  }
919
- const packagePath = path8.join(nodeModulesRoot, resolve);
920
- if (!fs7.existsSync(packagePath)) {
921
- return null;
918
+ }
919
+ const require2 = createRequire(path8.join(configDir, "noop.js"));
920
+ try {
921
+ return fs7.realpathSync(
922
+ path8.dirname(require2.resolve(`${resolve}/package.json`))
923
+ );
924
+ } catch {
925
+ }
926
+ try {
927
+ let dir = path8.dirname(require2.resolve(resolve));
928
+ while (dir !== path8.dirname(dir)) {
929
+ if (fs7.existsSync(path8.join(dir, "package.json"))) {
930
+ return fs7.realpathSync(dir);
931
+ }
932
+ dir = path8.dirname(dir);
922
933
  }
923
- return fs7.realpathSync(packagePath);
934
+ } catch {
935
+ }
936
+ try {
937
+ const packagePath = path8.join(nodeModulesRoot, resolve);
938
+ return fs7.existsSync(packagePath) ? fs7.realpathSync(packagePath) : null;
924
939
  } catch {
925
940
  return null;
926
941
  }
@@ -932,7 +947,12 @@ function resolvePluginExtensions(plugins, configDir, appType) {
932
947
  const resolve = typeof plugin === "string" ? plugin : plugin?.resolve;
933
948
  if (!resolve || typeof resolve !== "string") continue;
934
949
  const pluginRoot = resolvePluginRoot(resolve, configDir, nodeModulesRoot);
935
- if (!pluginRoot) continue;
950
+ if (!pluginRoot) {
951
+ console.warn(
952
+ `[@mercurjs/dashboard-sdk] Could not resolve plugin "${resolve}" from ${configDir}. Its ${appType} extensions will be missing from the build.`
953
+ );
954
+ continue;
955
+ }
936
956
  const extFile = path8.join(
937
957
  pluginRoot,
938
958
  ".medusa/server/src",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mercurjs/dashboard-sdk",
3
- "version": "2.3.2-canary.2",
3
+ "version": "2.3.2-canary.4",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/mercurjs/mercur",