@soda-gql/builder 0.12.0 → 0.12.2

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.
@@ -1,4 +1,4 @@
1
- import "node:module";
1
+ import { createRequire } from "node:module";
2
2
  import { existsSync, readFileSync, realpathSync, statSync, unlinkSync } from "node:fs";
3
3
  import { readFile, stat } from "node:fs/promises";
4
4
  import { err, ok } from "neverthrow";
@@ -7,7 +7,6 @@ import { createHash } from "node:crypto";
7
7
  import { extname, join, normalize, resolve } from "node:path";
8
8
  import { Script, createContext } from "node:vm";
9
9
  import { CanonicalIdSchema, Effect, Effects, ParallelEffect, cachedFn, createAliasResolver, createAsyncScheduler, createCanonicalId, createCanonicalTracker, createSwcSpanConverter, createSyncScheduler, getPortableFS, getPortableHasher, isExternalSpecifier, isRelativeSpecifier, normalizePath, parseCanonicalId, resolveRelativeImportWithExistenceCheck, resolveRelativeImportWithReferences, validateCanonicalId } from "@soda-gql/common";
10
- import { parseSync, transformSync } from "@swc/core";
11
10
  import * as sandboxCore from "@soda-gql/core";
12
11
  import { Fragment, GqlDefine, GqlElement, Operation } from "@soda-gql/core";
13
12
  import * as sandboxCoreAdapter from "@soda-gql/core/adapter";
@@ -1249,9 +1248,20 @@ const createIntermediateRegistry = ({ analyses } = {}) => {
1249
1248
 
1250
1249
  //#endregion
1251
1250
  //#region packages/builder/src/intermediate-module/evaluation.ts
1251
+ let _transformSync;
1252
+ const getTransformSync = () => {
1253
+ if (!_transformSync) {
1254
+ if (typeof import.meta.url !== "string") {
1255
+ throw new Error("@swc/core cannot be resolved: import.meta.url is unavailable in CJS bundle context");
1256
+ }
1257
+ const localRequire = createRequire(import.meta.url);
1258
+ _transformSync = localRequire("@swc/core").transformSync;
1259
+ }
1260
+ return _transformSync;
1261
+ };
1252
1262
  const transpile = ({ filePath, sourceCode }) => {
1253
1263
  try {
1254
- const result = transformSync(sourceCode, {
1264
+ const result = getTransformSync()(sourceCode, {
1255
1265
  filename: `${filePath}.ts`,
1256
1266
  jsc: {
1257
1267
  parser: {
@@ -2348,13 +2358,19 @@ const collectClassPropertyDiagnostics$1 = (module$1, gqlIdentifiers) => {
2348
2358
  module$1.body.forEach(visit);
2349
2359
  return diagnostics;
2350
2360
  };
2351
- /**
2352
- * SWC adapter implementation.
2353
- * The analyze method parses and collects all data in one pass,
2354
- * ensuring the AST (Module) is released after analysis.
2355
- */
2361
+ let _parseSync;
2362
+ const getParseSync = () => {
2363
+ if (!_parseSync) {
2364
+ if (typeof import.meta.url !== "string") {
2365
+ throw new Error("@swc/core cannot be resolved: import.meta.url is unavailable in CJS bundle context");
2366
+ }
2367
+ const localRequire = createRequire(import.meta.url);
2368
+ _parseSync = localRequire("@swc/core").parseSync;
2369
+ }
2370
+ return _parseSync;
2371
+ };
2356
2372
  const swcAdapter = { analyze(input, helper) {
2357
- const program = parseSync(input.source, {
2373
+ const program = getParseSync()(input.source, {
2358
2374
  syntax: "typescript",
2359
2375
  tsx: input.filePath.endsWith(".tsx"),
2360
2376
  target: "es2022",
@@ -6239,4 +6255,4 @@ const createBuilderService = ({ config, entrypointsOverride }) => {
6239
6255
 
6240
6256
  //#endregion
6241
6257
  export { getSeverity as _, createGraphqlSystemIdentifyHelper as a, BuilderArtifactSchema as b, BuilderEffects as c, formatBuilderErrorForCLI as d, formatBuilderErrorStructured as f, diagnosticMessages as g, createStandardDiagnostic as h, extractModuleAdjacency as i, FileReadEffect as l, createDiagnostic as m, createBuilderSession as n, __clearGqlCache as o, builderErrors as p, collectAffectedFiles as r, executeSandbox as s, createBuilderService as t, FileStatEffect as u, loadArtifact as v, loadArtifactSync as y };
6242
- //# sourceMappingURL=service-CqUHXFUE.mjs.map
6258
+ //# sourceMappingURL=service-DXvoj0YF.mjs.map