{"record":{"id":"494ef87ab25e6c24","repo":"parcel-bundler/parcel","slug":"scope-hoisting-is-not-supported-with-ssg","errorCode":null,"errorMessage":"Scope hoisting is not supported with SSG","messagePattern":"Scope hoisting is not supported with SSG","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/packagers/react-static/src/ReactStaticPackager.js","lineNumber":116,"sourceCode":"      includeInline: false,\n      includeIsolated: false,\n    })) {\n      if (b.type === 'js') {\n        referencedBundles.push(b.getContentHash());\n      }\n    }\n\n    return {pages, referencedBundles};\n  },\n  async package({\n    bundle,\n    bundleGraph,\n    getInlineBundleContents,\n    config,\n    bundleConfig,\n  }) {\n    if (bundle.env.shouldScopeHoist) {\n      throw new Error('Scope hoisting is not supported with SSG');\n    }\n\n    let {load, loadModule} = await loadBundle(\n      bundle,\n      bundleGraph,\n      getInlineBundleContents,\n    );\n\n    let Component = load(nullthrows(bundle.getMainEntry()).id).default;\n    let {renderToReadableStream} = loadModule(\n      'react-server-dom-parcel/server.edge',\n      __filename,\n      'react-server',\n    );\n    let {prerender} = loadModule(\n      'react-dom/static.edge',\n      __filename,\n      'react-client',","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/parcel-bundler/parcel/blob/59484858a1a0bcbb71f74088956bb437a2db6505/packages/packagers/react-static/src/ReactStaticPackager.js#L98-L134","documentation":"Thrown by the react-static SSG packager when a bundle has `shouldScopeHoist` enabled. Static site generation loads the bundle into a module sandbox (via `loadBundle`) and renders it server-side; the scope-hoisting packaging format is incompatible with that loader, so the combination is rejected up front.","triggerScenarios":"Setting `scopeHoist: true` (or enabling scope hoisting via a target/CLI flag) on a build that uses the react-static packager (SSG target). Mixing the `--no-scope-hoist` default with an SSG target that someone re-enabled hoisting on.","commonSituations":"Copying a production web target's config (which enables scope hoisting) onto an SSG target; toggling scope hoisting globally without per-target overrides; upgrading and inheriting a hoist-enabled default for the SSG bundle.","solutions":["Disable scope hoisting for the SSG target: set `scopeHoist: false` (or omit/`--no-scope-hoist`) for that target.","Keep scope hoisting only on non-SSG (browser) targets via per-target configuration.","If you need smaller SSG output, use a different optimization (minification, tree-shaking) rather than scope hoisting."],"exampleFix":"// before — .parcelrc or target config\n{ \"targets\": { \"ssg\": { \"source\": \"src/ssg.js\", \"scopeHoist\": true } } }\n// after\n{ \"targets\": { \"ssg\": { \"source\": \"src/ssg.js\", \"scopeHoist\": false } } }","handlingStrategy":"validation","validationCode":"function assertSSGCompat(env) {\n  if (env.isSSG && env.shouldScopeHoist) {\n    throw new Error('SSG targets cannot enable scope hoisting');\n  }\n}","typeGuard":"function isSSGTarget(bundle) { return bundle?.target?.sourceType === 'react-static' || !!bundle?.env?.isSSG; }","tryCatchPattern":null,"preventionTips":["Keep `scopeHoist: false` on SSG/react-static targets.","Configure scope hoisting per-target, not globally.","Use minification/tree-shaking for SSG size wins instead of scope hoisting."],"tags":["parcel","ssg","react-static","scope-hoisting","config"],"backgroundTag":null,"analyzedSha":"59484858a1a0bcbb71f74088956bb437a2db6505","analyzedAt":"2026-08-13T04:06:35.925Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}