@superblocksteam/sdk 2.0.3 → 2.0.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.
@@ -22,11 +22,7 @@ import { getLogger } from "../dev-utils/dev-logger.mjs";
22
22
  import { createDevServer } from "../dev-utils/dev-server.mjs";
23
23
  import tracer from "../dev-utils/dev-tracer.js";
24
24
  import { SuperblocksSdk } from "../sdk.js";
25
- import {
26
- checkVersionsAndUpgrade,
27
- getCurrentCliVersion,
28
- getCurrentLibraryVersionWithoutPM,
29
- } from "./automatic-upgrades.js";
25
+ import { checkVersionsAndUpgrade } from "./automatic-upgrades.js";
30
26
  import type { DevLogger } from "../dev-utils/dev-logger.mjs";
31
27
  import type { ApplicationConfig } from "../types/common.js";
32
28
  import type { DraftInterface } from "@superblocksteam/vite-plugin-file-sync/draft-interface";
@@ -103,15 +99,9 @@ export async function dev(options: {
103
99
  skipSync?: boolean;
104
100
 
105
101
  applicationConfig?: ApplicationConfig;
106
-
107
- /* For debugging purposes to get location of the cli */
108
- superblocksPath?: string;
109
102
  /* For redirecting output, like when running outside of the CLI */
110
103
  logger?: (message: string) => void;
111
104
 
112
- /* For a child process when restarting the dev server for automatic upgrades */
113
- skipAutoUpgrade?: boolean;
114
-
115
105
  /* To cancel the dev server */
116
106
  signal?: AbortSignal;
117
107
  }) {
@@ -125,15 +115,8 @@ export async function dev(options: {
125
115
  uploadFirst,
126
116
  skipSync,
127
117
  applicationConfig,
128
- skipAutoUpgrade,
129
118
  } = options;
130
119
 
131
- const cliVersion = await getCurrentCliVersion();
132
- const libraryVersion = await getCurrentLibraryVersionWithoutPM();
133
- logger.info(
134
- `Running command: ${options.superblocksPath} dev${options.uploadFirst ? " --upload-first" : ""}${options.downloadFirst ? " --download-first" : ""} with baseUrl: ${applicationConfig?.superblocksBaseUrl}, cliVersion: ${cliVersion}, libraryVersion: ${libraryVersion?.alias} ${libraryVersion?.version}`,
135
- );
136
-
137
120
  // Add check for node_modules
138
121
  if (!fs.existsSync(path.join(cwd, "node_modules"))) {
139
122
  throw new Error(
@@ -192,8 +175,7 @@ export async function dev(options: {
192
175
  // TODO(code-mode): package naming is preventing upgrade in ephemeral environments
193
176
  if (
194
177
  !process.env.PACKAGE_SUFFIX ||
195
- process.env.PACKAGE_SUFFIX === "" ||
196
- !skipAutoUpgrade
178
+ process.env.PACKAGE_SUFFIX === ""
197
179
  ) {
198
180
  await checkVersionsAndUpgrade(lockService, applicationConfig);
199
181
  }
@@ -14,18 +14,13 @@ import type { Span } from "@opentelemetry/api";
14
14
  const ATTR_DEPLOYMENT_ENVIRONMENT = "deployment.environment";
15
15
  // NOTE: @joeyagreco - this can be used to determine if we are using mock-csb, staging-csb, prod-csb, etc
16
16
  const ATTR_SUPERBLOCKS_BASE_URL = "superblocks.base_url";
17
- const ATTR_SUPERBLOCKS_CLI_TOKEN = "superblocks.cli_token";
18
17
  let superblocksTracesUrl = undefined;
19
18
  let superblocksHostname = "unknown";
20
- let token = "unknown";
21
19
  try {
22
20
  const tokenWithUrl = await getLocalTokenWithUrl();
23
21
  const superblocksBaseUrl = new URL(tokenWithUrl.superblocksBaseUrl);
24
22
  superblocksTracesUrl = superblocksBaseUrl.origin + "/api/v1/traces";
25
23
  superblocksHostname = superblocksBaseUrl.hostname;
26
- if ("token" in tokenWithUrl) {
27
- token = tokenWithUrl.token.substring(0, 8);
28
- }
29
24
  } catch (e) {
30
25
  console.error("[tracing init] could not determine superblocks base url", e);
31
26
  }
@@ -37,7 +32,6 @@ const sdk = new NodeSDK({
37
32
  [ATTR_SERVICE_NAME]: "sdk-dev-server",
38
33
  [ATTR_DEPLOYMENT_ENVIRONMENT]: process.env.SUPERBLOCKS_CLI_ENV,
39
34
  [ATTR_SUPERBLOCKS_BASE_URL]: superblocksHostname,
40
- [ATTR_SUPERBLOCKS_CLI_TOKEN]: token,
41
35
  }),
42
36
  ),
43
37
  traceExporter: new OTLPTraceExporter({
@@ -693,6 +693,9 @@ export async function superblocksCdnPlugin(
693
693
  {
694
694
  name: "vite-plugin-superblocks-cdn",
695
695
 
696
+ // run before Vite's module resolution
697
+ enforce: "pre",
698
+
696
699
  /**
697
700
  * Configure Vite to properly handle CDN modules
698
701
  * - Exclude CDN modules from optimization
@@ -756,8 +759,6 @@ export async function superblocksCdnPlugin(
756
759
 
757
760
  cdnDependencyChunks.set(dep, resolved);
758
761
  }
759
-
760
- debug("dependencies of CDN modules", cdnDependencyChunks);
761
762
  },
762
763
 
763
764
  resolveId(id, importer) {
@@ -785,8 +786,6 @@ export async function superblocksCdnPlugin(
785
786
  * These modules will be loaded from CDN at runtime, so we return empty content
786
787
  */
787
788
  async load(id: string) {
788
- debug("loading module", id);
789
-
790
789
  if (id.startsWith("cdn:")) {
791
790
  debug(`Providing empty module for CDN import: ${id}`);
792
791
  return "";
@@ -817,13 +816,9 @@ export async function superblocksCdnPlugin(
817
816
  }
818
817
  }
819
818
  }
820
-
821
- debug({ moduleToChunkMap, importToChunkMap });
822
819
  },
823
820
 
824
821
  async transformIndexHtml(html, { server }) {
825
- debug("transforming index.html");
826
-
827
822
  const isDevMode = !!server;
828
823
 
829
824
  // Create the base import map with explicit ordering for proper resolution
@@ -882,6 +877,7 @@ export async function superblocksCdnPlugin(
882
877
 
883
878
  // Get the asset URL as it would be served to the browser
884
879
  // For Vite to correctly resolve this module in the browser
880
+
885
881
  if (resolvedChunkUrl.startsWith("/")) {
886
882
  // For paths starting with /, they're already root-relative
887
883
  // Make sure we don't duplicate the base path
@@ -916,8 +912,6 @@ export async function superblocksCdnPlugin(
916
912
  debug(`Resolved %s to %s`, moduleName, dependencyChunkUrl);
917
913
  // Store in the import map scope
918
914
  importMap.scopes[baseUrl][moduleName] = dependencyChunkUrl;
919
- // Also add to main imports for external dependencies
920
- importMap.imports[moduleName] = dependencyChunkUrl;
921
915
  }
922
916
  }
923
917
  }
package/src/index.ts CHANGED
@@ -114,8 +114,6 @@ export {
114
114
  type ModeFlag,
115
115
  } from "./version-control.mjs";
116
116
 
117
- export { AUTO_UPGRADE_EXIT_CODE } from "./cli-replacement/automatic-upgrades.js";
118
-
119
117
  export { createDevServer } from "./dev-utils/dev-server.mjs";
120
118
 
121
119
  export { dev } from "./cli-replacement/dev.mjs";