@format.dev/compile 0.0.0 → 0.1.0
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.
- package/README.md +30 -20
- package/bin/format-compile +3 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/defineProperty.mjs +14 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/toPrimitive.mjs +16 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/toPropertyKey.mjs +11 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/typeof.mjs +12 -0
- package/dist/_virtual/rolldown_runtime.mjs +46 -0
- package/dist/node_modules/.pnpm/@babel_parser@7.29.8/node_modules/@babel/parser/lib/index.mjs +12606 -0
- package/dist/node_modules/.pnpm/@babel_parser@7.29.8/node_modules/@babel/parser/lib/index.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@vue_compiler-core@3.5.41/node_modules/@vue/compiler-core/dist/compiler-core.cjs.mjs +4866 -0
- package/dist/node_modules/.pnpm/@vue_compiler-core@3.5.41/node_modules/@vue/compiler-core/dist/compiler-core.cjs.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@vue_compiler-core@3.5.41/node_modules/@vue/compiler-core/index.mjs +13 -0
- package/dist/node_modules/.pnpm/@vue_compiler-core@3.5.41/node_modules/@vue/compiler-core/index.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@vue_compiler-dom@3.5.41/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.mjs +663 -0
- package/dist/node_modules/.pnpm/@vue_compiler-dom@3.5.41/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@vue_compiler-dom@3.5.41/node_modules/@vue/compiler-dom/index.mjs +13 -0
- package/dist/node_modules/.pnpm/@vue_compiler-dom@3.5.41/node_modules/@vue/compiler-dom/index.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@vue_compiler-ssr@3.5.41/node_modules/@vue/compiler-ssr/dist/compiler-ssr.cjs.mjs +846 -0
- package/dist/node_modules/.pnpm/@vue_compiler-ssr@3.5.41/node_modules/@vue/compiler-ssr/dist/compiler-ssr.cjs.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@vue_reactivity@3.5.41/node_modules/@vue/reactivity/dist/reactivity.cjs.mjs +1600 -0
- package/dist/node_modules/.pnpm/@vue_reactivity@3.5.41/node_modules/@vue/reactivity/dist/reactivity.cjs.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@vue_reactivity@3.5.41/node_modules/@vue/reactivity/index.mjs +13 -0
- package/dist/node_modules/.pnpm/@vue_reactivity@3.5.41/node_modules/@vue/reactivity/index.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@vue_runtime-core@3.5.41/node_modules/@vue/runtime-core/dist/runtime-core.cjs.mjs +5619 -0
- package/dist/node_modules/.pnpm/@vue_runtime-core@3.5.41/node_modules/@vue/runtime-core/dist/runtime-core.cjs.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@vue_runtime-core@3.5.41/node_modules/@vue/runtime-core/index.mjs +13 -0
- package/dist/node_modules/.pnpm/@vue_runtime-core@3.5.41/node_modules/@vue/runtime-core/index.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@vue_runtime-dom@3.5.41/node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.mjs +1479 -0
- package/dist/node_modules/.pnpm/@vue_runtime-dom@3.5.41/node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@vue_runtime-dom@3.5.41/node_modules/@vue/runtime-dom/index.mjs +13 -0
- package/dist/node_modules/.pnpm/@vue_runtime-dom@3.5.41/node_modules/@vue/runtime-dom/index.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@vue_server-renderer@3.5.41/node_modules/@vue/server-renderer/dist/server-renderer.cjs.mjs +510 -0
- package/dist/node_modules/.pnpm/@vue_server-renderer@3.5.41/node_modules/@vue/server-renderer/dist/server-renderer.cjs.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@vue_server-renderer@3.5.41/node_modules/@vue/server-renderer/index.mjs +13 -0
- package/dist/node_modules/.pnpm/@vue_server-renderer@3.5.41/node_modules/@vue/server-renderer/index.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@vue_shared@3.5.41/node_modules/@vue/shared/dist/shared.cjs.mjs +499 -0
- package/dist/node_modules/.pnpm/@vue_shared@3.5.41/node_modules/@vue/shared/dist/shared.cjs.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@vue_shared@3.5.41/node_modules/@vue/shared/index.mjs +13 -0
- package/dist/node_modules/.pnpm/@vue_shared@3.5.41/node_modules/@vue/shared/index.mjs.map +1 -0
- package/dist/node_modules/.pnpm/entities@7.0.1/node_modules/entities/dist/commonjs/decode-codepoint.mjs +79 -0
- package/dist/node_modules/.pnpm/entities@7.0.1/node_modules/entities/dist/commonjs/decode-codepoint.mjs.map +1 -0
- package/dist/node_modules/.pnpm/entities@7.0.1/node_modules/entities/dist/commonjs/decode.mjs +471 -0
- package/dist/node_modules/.pnpm/entities@7.0.1/node_modules/entities/dist/commonjs/decode.mjs.map +1 -0
- package/dist/node_modules/.pnpm/entities@7.0.1/node_modules/entities/dist/commonjs/generated/decode-data-html.mjs +16 -0
- package/dist/node_modules/.pnpm/entities@7.0.1/node_modules/entities/dist/commonjs/generated/decode-data-html.mjs.map +1 -0
- package/dist/node_modules/.pnpm/entities@7.0.1/node_modules/entities/dist/commonjs/generated/decode-data-xml.mjs +16 -0
- package/dist/node_modules/.pnpm/entities@7.0.1/node_modules/entities/dist/commonjs/generated/decode-data-xml.mjs.map +1 -0
- package/dist/node_modules/.pnpm/entities@7.0.1/node_modules/entities/dist/commonjs/internal/bin-trie-flags.mjs +30 -0
- package/dist/node_modules/.pnpm/entities@7.0.1/node_modules/entities/dist/commonjs/internal/bin-trie-flags.mjs.map +1 -0
- package/dist/node_modules/.pnpm/entities@7.0.1/node_modules/entities/dist/commonjs/internal/decode-shared.mjs +24 -0
- package/dist/node_modules/.pnpm/entities@7.0.1/node_modules/entities/dist/commonjs/internal/decode-shared.mjs.map +1 -0
- package/dist/node_modules/.pnpm/estree-walker@2.0.2/node_modules/estree-walker/dist/umd/estree-walker.mjs +253 -0
- package/dist/node_modules/.pnpm/estree-walker@2.0.2/node_modules/estree-walker/dist/umd/estree-walker.mjs.map +1 -0
- package/dist/node_modules/.pnpm/react-dom@19.2.8_react@19.2.8/node_modules/react-dom/cjs/react-dom-server-legacy.node.development.mjs +5246 -0
- package/dist/node_modules/.pnpm/react-dom@19.2.8_react@19.2.8/node_modules/react-dom/cjs/react-dom-server-legacy.node.development.mjs.map +1 -0
- package/dist/node_modules/.pnpm/react-dom@19.2.8_react@19.2.8/node_modules/react-dom/cjs/react-dom-server.node.development.mjs +5616 -0
- package/dist/node_modules/.pnpm/react-dom@19.2.8_react@19.2.8/node_modules/react-dom/cjs/react-dom-server.node.development.mjs.map +1 -0
- package/dist/node_modules/.pnpm/react-dom@19.2.8_react@19.2.8/node_modules/react-dom/cjs/react-dom.development.mjs +183 -0
- package/dist/node_modules/.pnpm/react-dom@19.2.8_react@19.2.8/node_modules/react-dom/cjs/react-dom.development.mjs.map +1 -0
- package/dist/node_modules/.pnpm/react-dom@19.2.8_react@19.2.8/node_modules/react-dom/index.mjs +13 -0
- package/dist/node_modules/.pnpm/react-dom@19.2.8_react@19.2.8/node_modules/react-dom/index.mjs.map +1 -0
- package/dist/node_modules/.pnpm/react-dom@19.2.8_react@19.2.8/node_modules/react-dom/server.node.mjs +21 -0
- package/dist/node_modules/.pnpm/react-dom@19.2.8_react@19.2.8/node_modules/react-dom/server.node.mjs.map +1 -0
- package/dist/node_modules/.pnpm/react@19.2.8/node_modules/react/cjs/react.development.mjs +766 -0
- package/dist/node_modules/.pnpm/react@19.2.8/node_modules/react/cjs/react.development.mjs.map +1 -0
- package/dist/node_modules/.pnpm/react@19.2.8/node_modules/react/index.mjs +13 -0
- package/dist/node_modules/.pnpm/react@19.2.8/node_modules/react/index.mjs.map +1 -0
- package/dist/node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/array-set.mjs +100 -0
- package/dist/node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/array-set.mjs.map +1 -0
- package/dist/node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/base64-vlq.mjs +73 -0
- package/dist/node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/base64-vlq.mjs.map +1 -0
- package/dist/node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/base64.mjs +41 -0
- package/dist/node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/base64.mjs.map +1 -0
- package/dist/node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/binary-search.mjs +68 -0
- package/dist/node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/binary-search.mjs.map +1 -0
- package/dist/node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/mapping-list.mjs +77 -0
- package/dist/node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/mapping-list.mjs.map +1 -0
- package/dist/node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/quick-sort.mjs +89 -0
- package/dist/node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/quick-sort.mjs.map +1 -0
- package/dist/node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/source-map-consumer.mjs +788 -0
- package/dist/node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/source-map-consumer.mjs.map +1 -0
- package/dist/node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/source-map-generator.mjs +295 -0
- package/dist/node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/source-map-generator.mjs.map +1 -0
- package/dist/node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/source-node.mjs +293 -0
- package/dist/node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/source-node.mjs.map +1 -0
- package/dist/node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/util.mjs +352 -0
- package/dist/node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/util.mjs.map +1 -0
- package/dist/node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/source-map.mjs +17 -0
- package/dist/node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/source-map.mjs.map +1 -0
- package/dist/node_modules/.pnpm/vue@3.5.41_typescript@5.9.3/node_modules/vue/dist/vue.cjs.mjs +67 -0
- package/dist/node_modules/.pnpm/vue@3.5.41_typescript@5.9.3/node_modules/vue/dist/vue.cjs.mjs.map +1 -0
- package/dist/node_modules/.pnpm/vue@3.5.41_typescript@5.9.3/node_modules/vue/index.mjs +13 -0
- package/dist/node_modules/.pnpm/vue@3.5.41_typescript@5.9.3/node_modules/vue/index.mjs.map +1 -0
- package/dist/node_modules/.pnpm/vue@3.5.41_typescript@5.9.3/node_modules/vue/index2.mjs +10 -0
- package/dist/node_modules/.pnpm/vue@3.5.41_typescript@5.9.3/node_modules/vue/index2.mjs.map +1 -0
- package/dist/node_modules/.pnpm/vue@3.5.41_typescript@5.9.3/node_modules/vue/server-renderer/index.mjs +10 -0
- package/dist/node_modules/.pnpm/vue@3.5.41_typescript@5.9.3/node_modules/vue/server-renderer/index.mjs.map +1 -0
- package/dist/server/cli/bin.d.mts +1 -0
- package/dist/server/cli/bin.mjs +8 -0
- package/dist/server/cli/bin.mjs.map +1 -0
- package/dist/server/cli/cli-spec.mjs +150 -0
- package/dist/server/cli/cli-spec.mjs.map +1 -0
- package/dist/server/cli/index.d.mts +16 -0
- package/dist/server/cli/index.d.mts.map +1 -0
- package/dist/server/cli/index.mjs +64 -0
- package/dist/server/cli/index.mjs.map +1 -0
- package/dist/server/compile/adaptors/html-partials.d.mts +24 -0
- package/dist/server/compile/adaptors/html-partials.d.mts.map +1 -0
- package/dist/server/compile/adaptors/html-partials.mjs +50 -0
- package/dist/server/compile/adaptors/html-partials.mjs.map +1 -0
- package/dist/server/compile/adaptors/html.d.mts +15 -0
- package/dist/server/compile/adaptors/html.d.mts.map +1 -0
- package/dist/server/compile/adaptors/html.mjs +39 -0
- package/dist/server/compile/adaptors/html.mjs.map +1 -0
- package/dist/server/compile/adaptors/node-require.d.mts +6 -0
- package/dist/server/compile/adaptors/node-require.d.mts.map +1 -0
- package/dist/server/compile/adaptors/node-require.mjs +35 -0
- package/dist/server/compile/adaptors/node-require.mjs.map +1 -0
- package/dist/server/compile/adaptors/react-browser.d.mts +20 -0
- package/dist/server/compile/adaptors/react-browser.d.mts.map +1 -0
- package/dist/server/compile/adaptors/react-browser.mjs +19 -0
- package/dist/server/compile/adaptors/react-browser.mjs.map +1 -0
- package/dist/server/compile/adaptors/react-node.d.mts +17 -0
- package/dist/server/compile/adaptors/react-node.d.mts.map +1 -0
- package/dist/server/compile/adaptors/react-node.mjs +50 -0
- package/dist/server/compile/adaptors/react-node.mjs.map +1 -0
- package/dist/server/compile/adaptors/types.d.mts +14 -0
- package/dist/server/compile/adaptors/types.d.mts.map +1 -0
- package/dist/server/compile/adaptors/types.mjs +1 -0
- package/dist/server/compile/adaptors/vue-browser.d.mts +16 -0
- package/dist/server/compile/adaptors/vue-browser.d.mts.map +1 -0
- package/dist/server/compile/adaptors/vue-browser.mjs +16 -0
- package/dist/server/compile/adaptors/vue-browser.mjs.map +1 -0
- package/dist/server/compile/adaptors/vue-node.d.mts +17 -0
- package/dist/server/compile/adaptors/vue-node.d.mts.map +1 -0
- package/dist/server/compile/adaptors/vue-node.mjs +50 -0
- package/dist/server/compile/adaptors/vue-node.mjs.map +1 -0
- package/dist/server/compile/build-entry-module.d.mts +20 -0
- package/dist/server/compile/build-entry-module.d.mts.map +1 -0
- package/dist/server/compile/build-entry-module.mjs +56 -0
- package/dist/server/compile/build-entry-module.mjs.map +1 -0
- package/dist/server/compile/bundle-name.d.mts +5 -0
- package/dist/server/compile/bundle-name.d.mts.map +1 -0
- package/dist/server/compile/bundle-name.mjs +13 -0
- package/dist/server/compile/bundle-name.mjs.map +1 -0
- package/dist/server/compile/compile-cache.d.mts +23 -0
- package/dist/server/compile/compile-cache.d.mts.map +1 -0
- package/dist/server/compile/compile-cache.mjs +102 -0
- package/dist/server/compile/compile-cache.mjs.map +1 -0
- package/dist/server/compile/compile.d.mts +100 -0
- package/dist/server/compile/compile.d.mts.map +1 -0
- package/dist/server/compile/compile.mjs +735 -0
- package/dist/server/compile/compile.mjs.map +1 -0
- package/dist/server/compile/constants.d.mts +11 -0
- package/dist/server/compile/constants.d.mts.map +1 -0
- package/dist/server/compile/constants.mjs +12 -0
- package/dist/server/compile/constants.mjs.map +1 -0
- package/dist/server/compile/create-renderer.d.mts +16 -0
- package/dist/server/compile/create-renderer.d.mts.map +1 -0
- package/dist/server/compile/create-renderer.mjs +59 -0
- package/dist/server/compile/create-renderer.mjs.map +1 -0
- package/dist/server/compile/decode-style-entities.d.mts +12 -0
- package/dist/server/compile/decode-style-entities.d.mts.map +1 -0
- package/dist/server/compile/decode-style-entities.mjs +32 -0
- package/dist/server/compile/decode-style-entities.mjs.map +1 -0
- package/dist/server/compile/defaults.d.mts +18 -0
- package/dist/server/compile/defaults.d.mts.map +1 -0
- package/dist/server/compile/defaults.mjs +128 -0
- package/dist/server/compile/defaults.mjs.map +1 -0
- package/dist/server/compile/dependency-closure.d.mts +10 -0
- package/dist/server/compile/dependency-closure.d.mts.map +1 -0
- package/dist/server/compile/dependency-closure.mjs +79 -0
- package/dist/server/compile/dependency-closure.mjs.map +1 -0
- package/dist/server/compile/document-assets.d.mts +103 -0
- package/dist/server/compile/document-assets.d.mts.map +1 -0
- package/dist/server/compile/document-assets.mjs +184 -0
- package/dist/server/compile/document-assets.mjs.map +1 -0
- package/dist/server/compile/finalize-document-html.d.mts +53 -0
- package/dist/server/compile/finalize-document-html.d.mts.map +1 -0
- package/dist/server/compile/finalize-document-html.mjs +132 -0
- package/dist/server/compile/finalize-document-html.mjs.map +1 -0
- package/dist/server/compile/generated/adaptorHtml.mjs +6 -0
- package/dist/server/compile/generated/adaptorHtml.mjs.map +1 -0
- package/dist/server/compile/generated/adaptorReactBrowser.mjs +6 -0
- package/dist/server/compile/generated/adaptorReactBrowser.mjs.map +1 -0
- package/dist/server/compile/generated/adaptorReactNode.mjs +6 -0
- package/dist/server/compile/generated/adaptorReactNode.mjs.map +1 -0
- package/dist/server/compile/generated/adaptorVueBrowser.mjs +6 -0
- package/dist/server/compile/generated/adaptorVueBrowser.mjs.map +1 -0
- package/dist/server/compile/generated/adaptorVueNode.mjs +6 -0
- package/dist/server/compile/generated/adaptorVueNode.mjs.map +1 -0
- package/dist/server/compile/generated/createRenderer.mjs +6 -0
- package/dist/server/compile/generated/createRenderer.mjs.map +1 -0
- package/dist/server/compile/generated/decodeStyleEntities.mjs +6 -0
- package/dist/server/compile/generated/decodeStyleEntities.mjs.map +1 -0
- package/dist/server/compile/generated/sanitizeHtml.mjs +6 -0
- package/dist/server/compile/generated/sanitizeHtml.mjs.map +1 -0
- package/dist/server/compile/generated/validate.mjs +6 -0
- package/dist/server/compile/generated/validate.mjs.map +1 -0
- package/dist/server/compile/generated/virtualStyles.mjs +6 -0
- package/dist/server/compile/generated/virtualStyles.mjs.map +1 -0
- package/dist/server/compile/get-renderer.d.mts +18 -0
- package/dist/server/compile/get-renderer.d.mts.map +1 -0
- package/dist/server/compile/get-renderer.mjs +31 -0
- package/dist/server/compile/get-renderer.mjs.map +1 -0
- package/dist/server/compile/index.d.mts +2 -0
- package/dist/server/compile/index.mjs +3 -0
- package/dist/server/compile/make-config.d.mts +39 -0
- package/dist/server/compile/make-config.d.mts.map +1 -0
- package/dist/server/compile/make-config.mjs +272 -0
- package/dist/server/compile/make-config.mjs.map +1 -0
- package/dist/server/compile/package-json.d.mts +5 -0
- package/dist/server/compile/package-json.d.mts.map +1 -0
- package/dist/server/compile/package-json.mjs +33 -0
- package/dist/server/compile/package-json.mjs.map +1 -0
- package/dist/server/compile/producer-agreement.d.mts +82 -0
- package/dist/server/compile/producer-agreement.d.mts.map +1 -0
- package/dist/server/compile/producer-agreement.mjs +143 -0
- package/dist/server/compile/producer-agreement.mjs.map +1 -0
- package/dist/server/compile/producer-release.d.mts +19 -0
- package/dist/server/compile/producer-release.d.mts.map +1 -0
- package/dist/server/compile/producer-release.mjs +27 -0
- package/dist/server/compile/producer-release.mjs.map +1 -0
- package/dist/server/compile/render-error.d.mts +37 -0
- package/dist/server/compile/render-error.d.mts.map +1 -0
- package/dist/server/compile/render-error.mjs +55 -0
- package/dist/server/compile/render-error.mjs.map +1 -0
- package/dist/server/compile/sanitize/shared.d.mts +19 -0
- package/dist/server/compile/sanitize/shared.d.mts.map +1 -0
- package/dist/server/compile/sanitize/shared.mjs +131 -0
- package/dist/server/compile/sanitize/shared.mjs.map +1 -0
- package/dist/server/compile/sanitize-html.d.mts +5 -0
- package/dist/server/compile/sanitize-html.d.mts.map +1 -0
- package/dist/server/compile/sanitize-html.mjs +65 -0
- package/dist/server/compile/sanitize-html.mjs.map +1 -0
- package/dist/server/compile/structured-log.d.mts +22 -0
- package/dist/server/compile/structured-log.d.mts.map +1 -0
- package/dist/server/compile/structured-log.mjs +31 -0
- package/dist/server/compile/structured-log.mjs.map +1 -0
- package/dist/server/compile/virtual-styles.d.mts +5 -0
- package/dist/server/compile/virtual-styles.d.mts.map +1 -0
- package/dist/server/compile/virtual-styles.mjs +19 -0
- package/dist/server/compile/virtual-styles.mjs.map +1 -0
- package/dist/server/compile/wrapper-source.d.mts +55 -0
- package/dist/server/compile/wrapper-source.d.mts.map +1 -0
- package/dist/server/compile/wrapper-source.mjs +187 -0
- package/dist/server/compile/wrapper-source.mjs.map +1 -0
- package/dist/server/constants.d.mts +17 -0
- package/dist/server/constants.d.mts.map +1 -0
- package/dist/server/constants.mjs +41 -0
- package/dist/server/constants.mjs.map +1 -0
- package/dist/server/errors.d.mts +21 -0
- package/dist/server/errors.d.mts.map +1 -0
- package/dist/server/errors.mjs +24 -0
- package/dist/server/errors.mjs.map +1 -0
- package/dist/server/index.d.mts +4 -0
- package/dist/server/index.mjs +4 -0
- package/dist/server/integrations/nextjs/generate-entry.d.mts +19 -0
- package/dist/server/integrations/nextjs/generate-entry.d.mts.map +1 -0
- package/dist/server/integrations/nextjs/generate-entry.mjs +246 -0
- package/dist/server/integrations/nextjs/generate-entry.mjs.map +1 -0
- package/dist/server/integrations/nextjs/index.d.mts +8 -0
- package/dist/server/integrations/nextjs/index.d.mts.map +1 -0
- package/dist/server/integrations/nextjs/index.mjs +90 -0
- package/dist/server/integrations/nextjs/index.mjs.map +1 -0
- package/dist/server/integrations/nextjs/watcher.d.mts +9 -0
- package/dist/server/integrations/nextjs/watcher.d.mts.map +1 -0
- package/dist/server/integrations/nextjs/watcher.mjs +45 -0
- package/dist/server/integrations/nextjs/watcher.mjs.map +1 -0
- package/dist/server/integrations/unplugin/esbuild.d.mts +2 -0
- package/dist/server/integrations/unplugin/esbuild.mjs +3 -0
- package/dist/server/integrations/unplugin/index.d.mts +69 -0
- package/dist/server/integrations/unplugin/index.d.mts.map +1 -0
- package/dist/server/integrations/unplugin/index.mjs +539 -0
- package/dist/server/integrations/unplugin/index.mjs.map +1 -0
- package/dist/server/integrations/unplugin/rollup.d.mts +2 -0
- package/dist/server/integrations/unplugin/rollup.mjs +3 -0
- package/dist/server/integrations/unplugin/utils.d.mts +12 -0
- package/dist/server/integrations/unplugin/utils.d.mts.map +1 -0
- package/dist/server/integrations/unplugin/utils.mjs +46 -0
- package/dist/server/integrations/unplugin/utils.mjs.map +1 -0
- package/dist/server/integrations/unplugin/vite.d.mts +2 -0
- package/dist/server/integrations/unplugin/vite.mjs +3 -0
- package/dist/server/integrations/unplugin/webpack.d.mts +2 -0
- package/dist/server/integrations/unplugin/webpack.mjs +3 -0
- package/dist/server/project/documents.d.mts +21 -0
- package/dist/server/project/documents.d.mts.map +1 -0
- package/dist/server/project/documents.mjs +114 -0
- package/dist/server/project/documents.mjs.map +1 -0
- package/dist/server/project/format-env-types.d.mts +19 -0
- package/dist/server/project/format-env-types.d.mts.map +1 -0
- package/dist/server/project/format-env-types.mjs +64 -0
- package/dist/server/project/format-env-types.mjs.map +1 -0
- package/dist/server/project/paths.d.mts +21 -0
- package/dist/server/project/paths.d.mts.map +1 -0
- package/dist/server/project/paths.mjs +31 -0
- package/dist/server/project/paths.mjs.map +1 -0
- package/dist/server/project/user-project-dir.d.mts +7 -0
- package/dist/server/project/user-project-dir.d.mts.map +1 -0
- package/dist/server/project/user-project-dir.mjs +16 -0
- package/dist/server/project/user-project-dir.mjs.map +1 -0
- package/dist/server/render-worker/client.d.mts +83 -0
- package/dist/server/render-worker/client.d.mts.map +1 -0
- package/dist/server/render-worker/client.mjs +359 -0
- package/dist/server/render-worker/client.mjs.map +1 -0
- package/dist/server/render-worker/document-css.d.mts +27 -0
- package/dist/server/render-worker/document-css.d.mts.map +1 -0
- package/dist/server/render-worker/document-css.mjs +37 -0
- package/dist/server/render-worker/document-css.mjs.map +1 -0
- package/dist/server/render-worker/env.d.mts +11 -0
- package/dist/server/render-worker/env.d.mts.map +1 -0
- package/dist/server/render-worker/env.mjs +26 -0
- package/dist/server/render-worker/env.mjs.map +1 -0
- package/dist/server/render-worker/error.d.mts +17 -0
- package/dist/server/render-worker/error.d.mts.map +1 -0
- package/dist/server/render-worker/error.mjs +40 -0
- package/dist/server/render-worker/error.mjs.map +1 -0
- package/dist/server/render-worker/host.d.mts +1 -0
- package/dist/server/render-worker/host.mjs +181 -0
- package/dist/server/render-worker/host.mjs.map +1 -0
- package/dist/server/render-worker/index.d.mts +4 -0
- package/dist/server/render-worker/index.mjs +4 -0
- package/dist/server/render-worker/sandbox.d.mts +25 -0
- package/dist/server/render-worker/sandbox.d.mts.map +1 -0
- package/dist/server/render-worker/sandbox.mjs +60 -0
- package/dist/server/render-worker/sandbox.mjs.map +1 -0
- package/dist/server/render-worker/types.d.mts +59 -0
- package/dist/server/render-worker/types.d.mts.map +1 -0
- package/dist/server/render-worker/types.mjs +1 -0
- package/dist/server/runtime-state.d.mts +12 -0
- package/dist/server/runtime-state.d.mts.map +1 -0
- package/dist/server/runtime-state.mjs +24 -0
- package/dist/server/runtime-state.mjs.map +1 -0
- package/dist/server/utils/check-dir.d.mts +12 -0
- package/dist/server/utils/check-dir.d.mts.map +1 -0
- package/dist/server/utils/check-dir.mjs +30 -0
- package/dist/server/utils/check-dir.mjs.map +1 -0
- package/dist/server/utils/dependencies.d.mts +11 -0
- package/dist/server/utils/dependencies.d.mts.map +1 -0
- package/dist/server/utils/dependencies.mjs +34 -0
- package/dist/server/utils/dependencies.mjs.map +1 -0
- package/dist/server/utils/env-var.d.mts +6 -0
- package/dist/server/utils/env-var.d.mts.map +1 -0
- package/dist/server/utils/env-var.mjs +28 -0
- package/dist/server/utils/env-var.mjs.map +1 -0
- package/dist/server/utils/format-for-log.d.mts +5 -0
- package/dist/server/utils/format-for-log.d.mts.map +1 -0
- package/dist/server/utils/format-for-log.mjs +17 -0
- package/dist/server/utils/format-for-log.mjs.map +1 -0
- package/dist/server/utils/index.d.mts +8 -0
- package/dist/server/utils/index.mjs +9 -0
- package/dist/server/utils/load-config.d.mts +13 -0
- package/dist/server/utils/load-config.d.mts.map +1 -0
- package/dist/server/utils/load-config.mjs +65 -0
- package/dist/server/utils/load-config.mjs.map +1 -0
- package/dist/server/utils/log.d.mts +36 -0
- package/dist/server/utils/log.d.mts.map +1 -0
- package/dist/server/utils/log.mjs +125 -0
- package/dist/server/utils/log.mjs.map +1 -0
- package/dist/server/utils/read-file.d.mts +5 -0
- package/dist/server/utils/read-file.d.mts.map +1 -0
- package/dist/server/utils/read-file.mjs +14 -0
- package/dist/server/utils/read-file.mjs.map +1 -0
- package/dist/server/utils/resolve-path-with-extensions.d.mts +21 -0
- package/dist/server/utils/resolve-path-with-extensions.d.mts.map +1 -0
- package/dist/server/utils/resolve-path-with-extensions.mjs +39 -0
- package/dist/server/utils/resolve-path-with-extensions.mjs.map +1 -0
- package/dist/server/utils/schema.d.mts +7 -0
- package/dist/server/utils/schema.d.mts.map +1 -0
- package/dist/server/utils/schema.mjs +21 -0
- package/dist/server/utils/schema.mjs.map +1 -0
- package/dist/server/utils/standard-schema-validate.d.mts +13 -0
- package/dist/server/utils/standard-schema-validate.d.mts.map +1 -0
- package/dist/server/utils/standard-schema-validate.mjs +21 -0
- package/dist/server/utils/standard-schema-validate.mjs.map +1 -0
- package/dist/server/utils/suggest-similar.d.mts +9 -0
- package/dist/server/utils/suggest-similar.d.mts.map +1 -0
- package/dist/server/utils/suggest-similar.mjs +39 -0
- package/dist/server/utils/suggest-similar.mjs.map +1 -0
- package/dist/server/utils/warn-lockstep.d.mts +13 -0
- package/dist/server/utils/warn-lockstep.d.mts.map +1 -0
- package/dist/server/utils/warn-lockstep.mjs +23 -0
- package/dist/server/utils/warn-lockstep.mjs.map +1 -0
- package/dist/server/vite/create-config.d.mts +35 -0
- package/dist/server/vite/create-config.d.mts.map +1 -0
- package/dist/server/vite/create-config.mjs +64 -0
- package/dist/server/vite/create-config.mjs.map +1 -0
- package/dist/server/vite/plugins/collect-css.d.mts +8 -0
- package/dist/server/vite/plugins/collect-css.d.mts.map +1 -0
- package/dist/server/vite/plugins/collect-css.mjs +21 -0
- package/dist/server/vite/plugins/collect-css.mjs.map +1 -0
- package/dist/server/vite/plugins/get-styles.d.mts +14 -0
- package/dist/server/vite/plugins/get-styles.d.mts.map +1 -0
- package/dist/server/vite/plugins/get-styles.mjs +88 -0
- package/dist/server/vite/plugins/get-styles.mjs.map +1 -0
- package/dist/server/vite/plugins/html-loader.d.mts +18 -0
- package/dist/server/vite/plugins/html-loader.d.mts.map +1 -0
- package/dist/server/vite/plugins/html-loader.mjs +88 -0
- package/dist/server/vite/plugins/html-loader.mjs.map +1 -0
- package/dist/server/vite/plugins/postcss/import-url.d.mts +14 -0
- package/dist/server/vite/plugins/postcss/import-url.d.mts.map +1 -0
- package/dist/server/vite/plugins/postcss/import-url.mjs +163 -0
- package/dist/server/vite/plugins/postcss/import-url.mjs.map +1 -0
- package/dist/server/vite/plugins/styles-pre-processor.d.mts +7 -0
- package/dist/server/vite/plugins/styles-pre-processor.d.mts.map +1 -0
- package/dist/server/vite/plugins/styles-pre-processor.mjs +64 -0
- package/dist/server/vite/plugins/styles-pre-processor.mjs.map +1 -0
- package/dist/server/vite/plugins/utils.d.mts +9 -0
- package/dist/server/vite/plugins/utils.d.mts.map +1 -0
- package/dist/server/vite/plugins/utils.mjs +14 -0
- package/dist/server/vite/plugins/utils.mjs.map +1 -0
- package/dist/shared/constants.d.mts +11 -0
- package/dist/shared/constants.d.mts.map +1 -0
- package/dist/shared/constants.mjs +12 -0
- package/dist/shared/constants.mjs.map +1 -0
- package/dist/shared/env.d.mts +6 -0
- package/dist/shared/env.d.mts.map +1 -0
- package/dist/shared/env.mjs +11 -0
- package/dist/shared/env.mjs.map +1 -0
- package/dist/shared/http.d.mts +15 -0
- package/dist/shared/http.d.mts.map +1 -0
- package/dist/shared/http.mjs +54 -0
- package/dist/shared/http.mjs.map +1 -0
- package/dist/shared/types/document.d.mts +17 -0
- package/dist/shared/types/document.d.mts.map +1 -0
- package/dist/shared/types/document.mjs +1 -0
- package/dist/shared/types/index.d.mts +7 -0
- package/dist/shared/types/index.mjs +4 -0
- package/dist/shared/types/log.d.mts +10 -0
- package/dist/shared/types/log.d.mts.map +1 -0
- package/dist/shared/types/log.mjs +12 -0
- package/dist/shared/types/log.mjs.map +1 -0
- package/dist/shared/types/public/cli.d.mts +33 -0
- package/dist/shared/types/public/cli.d.mts.map +1 -0
- package/dist/shared/types/public/cli.mjs +1 -0
- package/dist/shared/types/public/compile.d.mts +45 -0
- package/dist/shared/types/public/compile.d.mts.map +1 -0
- package/dist/shared/types/public/compile.mjs +29 -0
- package/dist/shared/types/public/compile.mjs.map +1 -0
- package/dist/shared/types/public/config.d.mts +94 -0
- package/dist/shared/types/public/config.d.mts.map +1 -0
- package/dist/shared/types/public/config.mjs +20 -0
- package/dist/shared/types/public/config.mjs.map +1 -0
- package/dist/shared/types/public/index.d.mts +6 -0
- package/dist/shared/types/public/index.mjs +4 -0
- package/dist/shared/types/public/nextjs.d.mts +111 -0
- package/dist/shared/types/public/nextjs.d.mts.map +1 -0
- package/dist/shared/types/public/nextjs.mjs +1 -0
- package/dist/shared/types/public/renderer.d.mts +2 -0
- package/dist/shared/types/public/renderer.mjs +1 -0
- package/dist/shared/types/public/unplugin.d.mts +65 -0
- package/dist/shared/types/public/unplugin.d.mts.map +1 -0
- package/dist/shared/types/public/unplugin.mjs +1 -0
- package/dist/shared/types/server.d.mts +5 -0
- package/dist/shared/types/server.d.mts.map +1 -0
- package/dist/shared/types/server.mjs +1 -0
- package/dist/shared/types/state.d.mts +15 -0
- package/dist/shared/types/state.d.mts.map +1 -0
- package/dist/shared/types/state.mjs +1 -0
- package/dist/shared/types/system.d.mts +18 -0
- package/dist/shared/types/system.d.mts.map +1 -0
- package/dist/shared/types/system.mjs +1 -0
- package/package.json +146 -34
- package/types/next.d.ts +6 -0
- package/index.d.ts +0 -2
- package/index.js +0 -3
|
@@ -0,0 +1,735 @@
|
|
|
1
|
+
import { LogLevel as LogLevel$1 } from "../../shared/types/log.mjs";
|
|
2
|
+
import { getUserProjectDir } from "../project/user-project-dir.mjs";
|
|
3
|
+
import { DEFAULT_OUT_DIR_NAME, getDocumentsDir, getRootDir, getSharedAssetsDir } from "../project/paths.mjs";
|
|
4
|
+
import { NO_CONFIG_FILE_MESSAGE } from "../constants.mjs";
|
|
5
|
+
import { CompileError } from "../errors.mjs";
|
|
6
|
+
import { BUNDLE_ENTRY_POINT_FILE_NAME, CHUNKS_DIR_NAME, SHARED_ASSETS_OUT_DIR_NAME } from "./constants.mjs";
|
|
7
|
+
import { getLogLevel, logger, setLogLevel, withPrefixedConsole } from "../utils/log.mjs";
|
|
8
|
+
import { parseLogLevelFromEnv } from "../utils/env-var.mjs";
|
|
9
|
+
import { loadConfig } from "../utils/load-config.mjs";
|
|
10
|
+
import { checkDir } from "../utils/check-dir.mjs";
|
|
11
|
+
import "../utils/index.mjs";
|
|
12
|
+
import { getStyles } from "../vite/plugins/get-styles.mjs";
|
|
13
|
+
import { compileState } from "../runtime-state.mjs";
|
|
14
|
+
import { stylesPreProcessor } from "../vite/plugins/styles-pre-processor.mjs";
|
|
15
|
+
import { htmlLoader } from "../vite/plugins/html-loader.mjs";
|
|
16
|
+
import { createConfig } from "../vite/create-config.mjs";
|
|
17
|
+
import { emitPackageJson } from "./package-json.mjs";
|
|
18
|
+
import { getSchemaPath } from "../utils/schema.mjs";
|
|
19
|
+
import { DEFAULT_VARIANT, NO_DOCUMENTS_MESSAGE } from "../../shared/constants.mjs";
|
|
20
|
+
import { RenderWorker } from "../render-worker/client.mjs";
|
|
21
|
+
import "../render-worker/index.mjs";
|
|
22
|
+
import { normalizeCompileOptions } from "./defaults.mjs";
|
|
23
|
+
import { buildCacheKeyOptions, cachedOutputsExist, computeCacheHash, readCachedHash, writeCacheHash } from "./compile-cache.mjs";
|
|
24
|
+
import { DocumentRenderError } from "./render-error.mjs";
|
|
25
|
+
import { createStructuredOutput } from "./structured-log.mjs";
|
|
26
|
+
import { bakeWrapperAssetConstants } from "./wrapper-source.mjs";
|
|
27
|
+
import { engineTarget } from "./producer-release.mjs";
|
|
28
|
+
import { basePackageName } from "./dependency-closure.mjs";
|
|
29
|
+
import { makeViteBuildConfig } from "./make-config.mjs";
|
|
30
|
+
import { warnOnLockstepDrift } from "../utils/warn-lockstep.mjs";
|
|
31
|
+
import { assertProducersAgree } from "./producer-agreement.mjs";
|
|
32
|
+
import { buildDocumentDynamicAssets, buildDocumentStaticAssets, materialiseSharedDynamicAssets, resolveDocumentAssetSources } from "./document-assets.mjs";
|
|
33
|
+
import { getDocumentDataDir, getDocumentDataFile, getDocuments, getUserDocumentIndex } from "../project/documents.mjs";
|
|
34
|
+
import { builtinModules, createRequire } from "node:module";
|
|
35
|
+
import { dirname, resolve } from "node:path";
|
|
36
|
+
import { pathToFileURL } from "node:url";
|
|
37
|
+
import { access, mkdir, readFile, readdir, rm, writeFile } from "node:fs/promises";
|
|
38
|
+
import { build, mergeConfig } from "vite";
|
|
39
|
+
import { AssetMismatchError, findBrokenRemoteAssets, mergeRemoteAssets, scanRemoteRefs } from "@format.dev/zip";
|
|
40
|
+
import pluralize from "pluralize";
|
|
41
|
+
import { atlas } from "gradient-string";
|
|
42
|
+
import { buildDocumentExportMap } from "@format.dev/cli/scaffold";
|
|
43
|
+
|
|
44
|
+
//#region src/server/compile/compile.ts
|
|
45
|
+
function getDefaultOutDir(config) {
|
|
46
|
+
return resolve(getRootDir(config), DEFAULT_OUT_DIR_NAME);
|
|
47
|
+
}
|
|
48
|
+
function getBundleOutDir(config, outDirOverride) {
|
|
49
|
+
return outDirOverride != null ? resolve(outDirOverride) : getDefaultOutDir(config);
|
|
50
|
+
}
|
|
51
|
+
const assetsFileName = "assets.zip";
|
|
52
|
+
function getDocumentOutDir(outDir, documentName) {
|
|
53
|
+
return resolve(outDir, documentName);
|
|
54
|
+
}
|
|
55
|
+
function getDocumentEntryPath(outDir, documentName) {
|
|
56
|
+
return resolve(getDocumentOutDir(outDir, documentName), BUNDLE_ENTRY_POINT_FILE_NAME);
|
|
57
|
+
}
|
|
58
|
+
function getDocumentAssetsPath(outDir, documentName) {
|
|
59
|
+
return resolve(getDocumentOutDir(outDir, documentName), assetsFileName);
|
|
60
|
+
}
|
|
61
|
+
const INDEX_HTML_FILE_NAME = "index.html";
|
|
62
|
+
const MANIFEST_FILE_NAME = "manifest.json";
|
|
63
|
+
function getHtmlVariantPath(outDir, documentName, variant) {
|
|
64
|
+
return resolve(getDocumentOutDir(outDir, documentName), variant, INDEX_HTML_FILE_NAME);
|
|
65
|
+
}
|
|
66
|
+
const REMOTE_ASSETS_DOCS_URL = "https://format.dev/docs/authoring/assets#remote-assets";
|
|
67
|
+
/**
|
|
68
|
+
* Post-render remote-reference pass (static mode). PDF generation never
|
|
69
|
+
* fetches remote references at render time, so anything the rendered HTML
|
|
70
|
+
* points at over http(s) must either be fetched into the document's zip now
|
|
71
|
+
* (`remoteAssets` on) or flagged — without it, the reference is missing from
|
|
72
|
+
* every generated PDF.
|
|
73
|
+
*/
|
|
74
|
+
async function processRemoteAssetRefs(args) {
|
|
75
|
+
const { html, documentName, outDir, remoteAssets, remoteFetch, quiet } = args;
|
|
76
|
+
const remoteRefs = scanRemoteRefs(html);
|
|
77
|
+
if (remoteRefs.length === 0) return;
|
|
78
|
+
if (!remoteAssets) {
|
|
79
|
+
const list = remoteRefs.map((url) => ` • ${url}`).join("\n");
|
|
80
|
+
logger.warn(`Document "${documentName}" references remote assets that will be missing from generated PDFs — remote references are never fetched at render time:\n${list}\nCompile with --remote-assets to fetch and bundle them, or reference local files instead. ${REMOTE_ASSETS_DOCS_URL}`);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const assetsPath = getDocumentAssetsPath(outDir, documentName);
|
|
84
|
+
const existing = await readFile(assetsPath).catch(() => void 0);
|
|
85
|
+
const merged = await mergeRemoteAssets({
|
|
86
|
+
html,
|
|
87
|
+
zip: existing,
|
|
88
|
+
options: remoteFetch ? { remoteAssets: { fetch: remoteFetch } } : void 0
|
|
89
|
+
});
|
|
90
|
+
if (merged && merged !== existing) {
|
|
91
|
+
await mkdir(getDocumentOutDir(outDir, documentName), { recursive: true });
|
|
92
|
+
await writeFile(assetsPath, merged);
|
|
93
|
+
const message = `Bundled remote assets referenced by "${documentName}" into its assets.zip`;
|
|
94
|
+
if (quiet) logger.debug(message);
|
|
95
|
+
else logger.info(message);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Every real source file the bundler read, taken from the build's own module
|
|
100
|
+
* graph. Virtual ids and dependencies are dropped: a `virtual:` id is not a
|
|
101
|
+
* file to stat, and `node_modules` changes only on an install, which the
|
|
102
|
+
* bundler's own cache invalidation already covers.
|
|
103
|
+
*/
|
|
104
|
+
function collectModuleIds(buildOutput) {
|
|
105
|
+
const outputs = Array.isArray(buildOutput) ? buildOutput : [buildOutput];
|
|
106
|
+
const ids = /* @__PURE__ */ new Set();
|
|
107
|
+
for (const result of outputs) {
|
|
108
|
+
const chunks = result?.output ?? [];
|
|
109
|
+
for (const chunk of chunks) for (const id of chunk.moduleIds ?? []) if (isRealSourceFile(id)) ids.add(id);
|
|
110
|
+
}
|
|
111
|
+
return [...ids];
|
|
112
|
+
}
|
|
113
|
+
function isRealSourceFile(id) {
|
|
114
|
+
if (!id.startsWith("/") && !/^[A-Za-z]:[\\/]/.test(id)) return false;
|
|
115
|
+
if (id.includes("\0") || id.includes("node_modules")) return false;
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Render one compiled document variant on an already-running strict worker.
|
|
120
|
+
* Shared by the build-time smoke render and {@link renderCompiledDocument},
|
|
121
|
+
* so both report a failure the same way.
|
|
122
|
+
*/
|
|
123
|
+
async function renderVariantWithWorker(args) {
|
|
124
|
+
const { renderWorker, outDir, documentName, variant, config, assetMode, probeRemoteOnMismatch, remoteFetch } = args;
|
|
125
|
+
const data = await getDocumentDataFile(documentName, variant, config);
|
|
126
|
+
try {
|
|
127
|
+
return await renderWorker.compileRender({
|
|
128
|
+
bundlePath: getDocumentEntryPath(outDir, documentName),
|
|
129
|
+
documentName,
|
|
130
|
+
data: data || {},
|
|
131
|
+
cwd: getDocumentOutDir(outDir, documentName)
|
|
132
|
+
});
|
|
133
|
+
} catch (error) {
|
|
134
|
+
logger.error(`Compiled bundle failed to render document "${documentName}" (variant "${variant}")`, error);
|
|
135
|
+
const errData = error && typeof error === "object" && "data" in error ? error.data : void 0;
|
|
136
|
+
if (errData !== void 0) logger.error("Error data", errData);
|
|
137
|
+
const mismatch = error;
|
|
138
|
+
throw new DocumentRenderError({
|
|
139
|
+
documentName,
|
|
140
|
+
variant,
|
|
141
|
+
cause: Array.isArray(mismatch.missing) && Array.isArray(mismatch.remoteRefs) && probeRemoteOnMismatch ? await enrichWithBrokenRemotes({
|
|
142
|
+
documentName,
|
|
143
|
+
assetMode,
|
|
144
|
+
mismatch,
|
|
145
|
+
error,
|
|
146
|
+
remoteFetch
|
|
147
|
+
}) : error
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
async function enrichWithBrokenRemotes(args) {
|
|
152
|
+
const { documentName, assetMode, mismatch, error, remoteFetch } = args;
|
|
153
|
+
const brokenRemote = await findBrokenRemoteAssets({
|
|
154
|
+
urls: mismatch.remoteRefs,
|
|
155
|
+
fetch: remoteFetch
|
|
156
|
+
});
|
|
157
|
+
if (brokenRemote.length === 0) return error;
|
|
158
|
+
return new AssetMismatchError({
|
|
159
|
+
documentName,
|
|
160
|
+
mode: assetMode,
|
|
161
|
+
missing: mismatch.missing,
|
|
162
|
+
known: Array.isArray(mismatch.known) ? mismatch.known : [],
|
|
163
|
+
brokenRemote
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Render one variant of an already-compiled document and bundle the remote
|
|
168
|
+
* references its HTML carries, without rebuilding the bundle.
|
|
169
|
+
*
|
|
170
|
+
* `compileBundle` runs this same render inline against its own long-lived
|
|
171
|
+
* worker, one per build. This entry point owns a worker of its own, for callers
|
|
172
|
+
* holding a bundle from an earlier compile — Studio renders each variant this
|
|
173
|
+
* way rather than recompiling per download.
|
|
174
|
+
*/
|
|
175
|
+
async function renderCompiledDocument(args) {
|
|
176
|
+
const { outDir, documentName, variant, config, remoteAssets = false, remoteFetch } = args;
|
|
177
|
+
const renderWorker = new RenderWorker({
|
|
178
|
+
log: (msg) => logger.debug(msg),
|
|
179
|
+
warn: (msg) => logger.warn(msg),
|
|
180
|
+
allowedReadPaths: [outDir],
|
|
181
|
+
sandbox: "strict"
|
|
182
|
+
});
|
|
183
|
+
try {
|
|
184
|
+
const html = await renderVariantWithWorker({
|
|
185
|
+
renderWorker,
|
|
186
|
+
outDir,
|
|
187
|
+
documentName,
|
|
188
|
+
variant,
|
|
189
|
+
config,
|
|
190
|
+
assetMode: "static",
|
|
191
|
+
probeRemoteOnMismatch: remoteAssets,
|
|
192
|
+
remoteFetch
|
|
193
|
+
});
|
|
194
|
+
await processRemoteAssetRefs({
|
|
195
|
+
html,
|
|
196
|
+
documentName,
|
|
197
|
+
outDir,
|
|
198
|
+
remoteAssets,
|
|
199
|
+
remoteFetch
|
|
200
|
+
});
|
|
201
|
+
return html;
|
|
202
|
+
} finally {
|
|
203
|
+
await renderWorker.dispose();
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
async function collectExternals(outDir, documentNames) {
|
|
207
|
+
const externals = /* @__PURE__ */ new Set();
|
|
208
|
+
const importRe = /(?:import|from)\s+["']([^./][^"']*)["']/g;
|
|
209
|
+
const isNodeBuiltin = (specifier) => specifier.startsWith("node:") || builtinModules.includes(specifier);
|
|
210
|
+
const scanFile = async (filePath) => {
|
|
211
|
+
try {
|
|
212
|
+
const content = await readFile(filePath, "utf-8");
|
|
213
|
+
let match;
|
|
214
|
+
while ((match = importRe.exec(content)) !== null) {
|
|
215
|
+
const pkg = basePackageName(match[1]);
|
|
216
|
+
if (!isNodeBuiltin(pkg)) externals.add(pkg);
|
|
217
|
+
}
|
|
218
|
+
} catch {}
|
|
219
|
+
};
|
|
220
|
+
for (const name of documentNames) await scanFile(resolve(outDir, name, BUNDLE_ENTRY_POINT_FILE_NAME));
|
|
221
|
+
const chunksDir = resolve(outDir, "chunks");
|
|
222
|
+
const chunkFiles = await readdir(chunksDir).catch(() => []);
|
|
223
|
+
for (const file of chunkFiles) if (file.endsWith(".js")) await scanFile(resolve(chunksDir, file));
|
|
224
|
+
return [...externals].sort();
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* HTML output ships only HTML, each document's `assets.zip`, and the manifest.
|
|
228
|
+
* Remove the JS renderer artefacts left by the node build we rendered from: the
|
|
229
|
+
* per-document wrappers, the bundle index, `package.json`, `externals.json`, the
|
|
230
|
+
* shared chunks, and the root stylesheets (their CSS is already inlined into the
|
|
231
|
+
* rendered HTML).
|
|
232
|
+
*/
|
|
233
|
+
async function stripJsArtefacts(outDir, documents) {
|
|
234
|
+
const removals = documents.map((document) => rm(getDocumentEntryPath(outDir, document.name), { force: true }));
|
|
235
|
+
removals.push(rm(resolve(outDir, BUNDLE_ENTRY_POINT_FILE_NAME), { force: true }), rm(resolve(outDir, "package.json"), { force: true }), rm(resolve(outDir, "externals.json"), { force: true }), rm(resolve(outDir, CHUNKS_DIR_NAME), {
|
|
236
|
+
recursive: true,
|
|
237
|
+
force: true
|
|
238
|
+
}));
|
|
239
|
+
const rootEntries = await readdir(outDir, { withFileTypes: true }).catch(() => []);
|
|
240
|
+
for (const entry of rootEntries) if (entry.isFile() && entry.name.endsWith(".css")) removals.push(rm(resolve(outDir, entry.name), { force: true }));
|
|
241
|
+
await Promise.all(removals);
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Finalise HTML output: drop the JS artefacts and write the manifest grouping
|
|
245
|
+
* each document's variants with the single shared zip they render from.
|
|
246
|
+
*/
|
|
247
|
+
async function writeHtmlOutput(args) {
|
|
248
|
+
const { outDir, buildDocuments, htmlVariantEntries } = args;
|
|
249
|
+
await stripJsArtefacts(outDir, buildDocuments);
|
|
250
|
+
const documents = [];
|
|
251
|
+
for (const document of buildDocuments) {
|
|
252
|
+
const variants = htmlVariantEntries.get(document.name) ?? [];
|
|
253
|
+
const hasAssets = await access(getDocumentAssetsPath(outDir, document.name)).then(() => true, () => false);
|
|
254
|
+
documents.push({
|
|
255
|
+
document: document.name,
|
|
256
|
+
...hasAssets ? { assets: `${document.name}/${assetsFileName}` } : {},
|
|
257
|
+
variants
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
const manifest = {
|
|
261
|
+
output: "html",
|
|
262
|
+
engine: engineTarget,
|
|
263
|
+
documents
|
|
264
|
+
};
|
|
265
|
+
await writeFile(resolve(outDir, MANIFEST_FILE_NAME), JSON.stringify(manifest, null, " "), "utf-8");
|
|
266
|
+
}
|
|
267
|
+
let cssInJsVmPrewarm = null;
|
|
268
|
+
/**
|
|
269
|
+
* Pre-warm the module wyw-in-js loads when it evaluates CSS-in-JS.
|
|
270
|
+
*
|
|
271
|
+
* wyw-in-js extracts styles by running each component in a happy-dom VM, and
|
|
272
|
+
* happy-dom loads Node's built-in `node:vm` the first time it builds a window.
|
|
273
|
+
* Rolldown transforms modules in parallel, so two CSS-in-JS files can trigger
|
|
274
|
+
* that load at the same instant — one `require()` then catches `node:vm`
|
|
275
|
+
* mid-`import()` and Node throws "Cannot require() ES Module node:vm because it
|
|
276
|
+
* is not yet fully loaded". Loading the graph once here, sequentially, fills the
|
|
277
|
+
* module cache so the concurrent loads read from it instead of racing the
|
|
278
|
+
* loader. `node:vm` is the module that actually races and is always resolvable;
|
|
279
|
+
* happy-dom is what drags it in, so we warm that too when it resolves through
|
|
280
|
+
* wyw-in-js. Cached so repeat builds in one process pay the cost only once.
|
|
281
|
+
*/
|
|
282
|
+
function prewarmCssInJsVm() {
|
|
283
|
+
if (!cssInJsVmPrewarm) cssInJsVmPrewarm = warmCssInJsVm();
|
|
284
|
+
return cssInJsVmPrewarm;
|
|
285
|
+
}
|
|
286
|
+
async function warmCssInJsVm() {
|
|
287
|
+
await import("node:vm");
|
|
288
|
+
try {
|
|
289
|
+
await import(pathToFileURL(createRequire(createRequire(createRequire(import.meta.url).resolve("@wyw-in-js/vite")).resolve("@wyw-in-js/transform")).resolve("happy-dom")).href);
|
|
290
|
+
} catch {}
|
|
291
|
+
}
|
|
292
|
+
async function compileBundle(args) {
|
|
293
|
+
const { documentNames, config, options, logLevel, source } = args;
|
|
294
|
+
const { outDir: outDirOverride } = options;
|
|
295
|
+
const isBrowserTarget = options.target === "browser";
|
|
296
|
+
const isWorkerTarget = options.target === "worker";
|
|
297
|
+
const assetMode = options.assets;
|
|
298
|
+
const isHtmlOutput = options.output === "html";
|
|
299
|
+
const isCli = source === "cli";
|
|
300
|
+
const isUnplugin = source === "unplugin";
|
|
301
|
+
logger.debug("Compile bundle context", {
|
|
302
|
+
source,
|
|
303
|
+
target: options.target,
|
|
304
|
+
userBundler: options.userBundler
|
|
305
|
+
});
|
|
306
|
+
const outDir = getBundleOutDir(config, outDirOverride);
|
|
307
|
+
const rootDir = getRootDir(config);
|
|
308
|
+
if (resolve(outDir) === resolve(rootDir)) throw new CompileError("outDir cannot be the same directory as rootDir. Please choose a different output directory before bundling.");
|
|
309
|
+
if (options.clean) await rm(outDir, {
|
|
310
|
+
recursive: true,
|
|
311
|
+
force: true
|
|
312
|
+
});
|
|
313
|
+
await mkdir(outDir, { recursive: true });
|
|
314
|
+
const startTime = performance.now();
|
|
315
|
+
const shouldMinify = isUnplugin ? false : logLevel !== LogLevel$1.DEBUG;
|
|
316
|
+
const exportNames = buildDocumentExportMap(documentNames);
|
|
317
|
+
const buildDocuments = [];
|
|
318
|
+
for (const documentName$1 of documentNames) {
|
|
319
|
+
const entryFilePath = await getUserDocumentIndex({
|
|
320
|
+
documentName: documentName$1,
|
|
321
|
+
config
|
|
322
|
+
});
|
|
323
|
+
try {
|
|
324
|
+
await access(entryFilePath);
|
|
325
|
+
} catch {
|
|
326
|
+
throw new Error(`Entry file not found at ${entryFilePath}`);
|
|
327
|
+
}
|
|
328
|
+
const schemaPath = await getSchemaPath(getDocumentDataDir(documentName$1, config));
|
|
329
|
+
if (options.validateSchema && !schemaPath) throw new Error(`Schema file not found. Either use --no-validate-schema to disable schema validation or ensure you are using a valid schema file.`);
|
|
330
|
+
buildDocuments.push({
|
|
331
|
+
name: documentName$1,
|
|
332
|
+
entryFilePath,
|
|
333
|
+
schemaPath: schemaPath ?? void 0,
|
|
334
|
+
exportName: exportNames.get(documentName$1)
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
const { baseViteConfig, frameworkPlugins, stylePlugins } = createConfig();
|
|
338
|
+
const makePlugins = () => [
|
|
339
|
+
htmlLoader(),
|
|
340
|
+
stylesPreProcessor(options.inlineRemoteCss),
|
|
341
|
+
...frameworkPlugins,
|
|
342
|
+
...stylePlugins,
|
|
343
|
+
getStyles()
|
|
344
|
+
];
|
|
345
|
+
const format = options.cjs ? "cjs" : "es";
|
|
346
|
+
const commonConfig = {
|
|
347
|
+
documents: buildDocuments,
|
|
348
|
+
compiledFileName: BUNDLE_ENTRY_POINT_FILE_NAME,
|
|
349
|
+
shouldMinify,
|
|
350
|
+
format,
|
|
351
|
+
logger,
|
|
352
|
+
emittedAssetsDir: SHARED_ASSETS_OUT_DIR_NAME,
|
|
353
|
+
assetMode,
|
|
354
|
+
config,
|
|
355
|
+
options,
|
|
356
|
+
source
|
|
357
|
+
};
|
|
358
|
+
const buildTarget = isBrowserTarget ? "browser" : isWorkerTarget ? "worker" : "node";
|
|
359
|
+
const buildConfig = makeViteBuildConfig({
|
|
360
|
+
...commonConfig,
|
|
361
|
+
plugins: makePlugins(),
|
|
362
|
+
target: buildTarget,
|
|
363
|
+
outDir
|
|
364
|
+
});
|
|
365
|
+
await prewarmCssInJsVm();
|
|
366
|
+
const findDocumentForBuildError = (error) => {
|
|
367
|
+
const errorShape = error;
|
|
368
|
+
const candidates = [
|
|
369
|
+
errorShape?.id,
|
|
370
|
+
errorShape?.loc?.file,
|
|
371
|
+
errorShape?.message
|
|
372
|
+
].filter((value) => typeof value === "string");
|
|
373
|
+
return buildDocuments.find((document) => candidates.some((candidate) => candidate.includes(dirname(document.entryFilePath))))?.name;
|
|
374
|
+
};
|
|
375
|
+
try {
|
|
376
|
+
const buildOutput = await build(mergeConfig(baseViteConfig, buildConfig));
|
|
377
|
+
for (const id of collectModuleIds(buildOutput)) args.capturedInputs?.add(id);
|
|
378
|
+
} catch (error) {
|
|
379
|
+
const failingDocument = findDocumentForBuildError(error);
|
|
380
|
+
const documentLabel = failingDocument ? ` while building document "${failingDocument}"` : "";
|
|
381
|
+
logger.error(`Vite/Rollup Build Error${documentLabel}:`, error);
|
|
382
|
+
throw error;
|
|
383
|
+
}
|
|
384
|
+
await emitPackageJson(outDir, options.bundleName, format, options.version);
|
|
385
|
+
const writeBundleIndex = async (targetOutDir, bundleFormat) => {
|
|
386
|
+
const exportNames$1 = buildDocuments.map((doc) => doc.exportName);
|
|
387
|
+
if (bundleFormat === "cjs") {
|
|
388
|
+
const output$1 = [
|
|
389
|
+
...buildDocuments.map((doc) => {
|
|
390
|
+
const relPath = `./${doc.name}/${BUNDLE_ENTRY_POINT_FILE_NAME}`.replace(/\\/g, "/");
|
|
391
|
+
return `const { ${doc.exportName} } = require(${JSON.stringify(relPath)});`;
|
|
392
|
+
}),
|
|
393
|
+
"",
|
|
394
|
+
`module.exports = { ${exportNames$1.join(", ")} };`,
|
|
395
|
+
""
|
|
396
|
+
].join("\n");
|
|
397
|
+
await writeFile(resolve(targetOutDir, BUNDLE_ENTRY_POINT_FILE_NAME), output$1, "utf8");
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
const output = [
|
|
401
|
+
...buildDocuments.map((doc) => {
|
|
402
|
+
const relPath = `./${doc.name}/${BUNDLE_ENTRY_POINT_FILE_NAME}`.replace(/\\/g, "/");
|
|
403
|
+
return `import { ${doc.exportName} } from ${JSON.stringify(relPath)};`;
|
|
404
|
+
}),
|
|
405
|
+
"",
|
|
406
|
+
`export { ${exportNames$1.join(", ")} };`,
|
|
407
|
+
`export default { ${exportNames$1.join(", ")} };`,
|
|
408
|
+
""
|
|
409
|
+
].join("\n");
|
|
410
|
+
await writeFile(resolve(targetOutDir, BUNDLE_ENTRY_POINT_FILE_NAME), output, "utf8");
|
|
411
|
+
};
|
|
412
|
+
await writeBundleIndex(outDir, format);
|
|
413
|
+
const stagingRoot = resolve(outDir, "__assets_staging");
|
|
414
|
+
const documentAssetState = /* @__PURE__ */ new Map();
|
|
415
|
+
const sharedDynamicUrlMap = assetMode === "dynamic" ? await materialiseSharedDynamicAssets({
|
|
416
|
+
config,
|
|
417
|
+
outDir,
|
|
418
|
+
sharedAssetsOutDirName: SHARED_ASSETS_OUT_DIR_NAME
|
|
419
|
+
}) : {};
|
|
420
|
+
const materialiseDocumentAssets = async (document) => {
|
|
421
|
+
if (assetMode === "none") return {
|
|
422
|
+
known: [],
|
|
423
|
+
urlMap: null
|
|
424
|
+
};
|
|
425
|
+
const sources = await resolveDocumentAssetSources({
|
|
426
|
+
entryFilePath: document.entryFilePath,
|
|
427
|
+
config,
|
|
428
|
+
outDir,
|
|
429
|
+
sharedAssetsOutDirName: SHARED_ASSETS_OUT_DIR_NAME
|
|
430
|
+
});
|
|
431
|
+
if (assetMode === "static") {
|
|
432
|
+
const staticAssets = await buildDocumentStaticAssets(sources, resolve(stagingRoot, document.name));
|
|
433
|
+
if (staticAssets.zip) {
|
|
434
|
+
await mkdir(getDocumentOutDir(outDir, document.name), { recursive: true });
|
|
435
|
+
await writeFile(getDocumentAssetsPath(outDir, document.name), staticAssets.zip);
|
|
436
|
+
}
|
|
437
|
+
return {
|
|
438
|
+
known: staticAssets.known,
|
|
439
|
+
urlMap: null
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
const dynamicAssets = await buildDocumentDynamicAssets({
|
|
443
|
+
documentAssetsDir: sources.documentAssetsDir,
|
|
444
|
+
documentOutDir: getDocumentOutDir(outDir, document.name),
|
|
445
|
+
sharedUrlMap: sharedDynamicUrlMap
|
|
446
|
+
});
|
|
447
|
+
return {
|
|
448
|
+
known: dynamicAssets.known,
|
|
449
|
+
urlMap: dynamicAssets.urlMap
|
|
450
|
+
};
|
|
451
|
+
};
|
|
452
|
+
try {
|
|
453
|
+
await Promise.all(buildDocuments.map(async (document) => {
|
|
454
|
+
documentAssetState.set(document.name, await materialiseDocumentAssets(document));
|
|
455
|
+
}));
|
|
456
|
+
} finally {
|
|
457
|
+
await rm(stagingRoot, {
|
|
458
|
+
recursive: true,
|
|
459
|
+
force: true
|
|
460
|
+
}).catch(() => {});
|
|
461
|
+
}
|
|
462
|
+
await Promise.all(buildDocuments.map(async (document) => {
|
|
463
|
+
const assetState = documentAssetState.get(document.name);
|
|
464
|
+
if (!assetState) return;
|
|
465
|
+
args.capturedAssetState?.set(document.name, assetState);
|
|
466
|
+
await bakeWrapperAssetConstants({
|
|
467
|
+
entryPath: getDocumentEntryPath(outDir, document.name),
|
|
468
|
+
known: assetState.known,
|
|
469
|
+
urlMap: assetState.urlMap
|
|
470
|
+
});
|
|
471
|
+
}));
|
|
472
|
+
if (assetMode === "none") {
|
|
473
|
+
const emittedCount = (await readdir(resolve(outDir, SHARED_ASSETS_OUT_DIR_NAME), {
|
|
474
|
+
recursive: true,
|
|
475
|
+
withFileTypes: true
|
|
476
|
+
}).catch(() => [])).filter((entry) => entry.isFile()).length;
|
|
477
|
+
if (emittedCount > 0) logger.warn(`⚠ --assets none, but the bundle imported ${emittedCount} ${pluralize("asset", emittedCount)} (e.g. \`import logo from './logo.png'\`). Imported assets are content-hashed and managed by the build, so they can't be resolved by name and won't ship in this mode. Reference assets by path (e.g. \`<img src="logo.png">\`) to supply them yourself, or use --assets static or dynamic to bundle them.`);
|
|
478
|
+
}
|
|
479
|
+
if (assetMode === "static" || assetMode === "none") await rm(resolve(outDir, SHARED_ASSETS_OUT_DIR_NAME), {
|
|
480
|
+
recursive: true,
|
|
481
|
+
force: true
|
|
482
|
+
}).catch(() => {});
|
|
483
|
+
const canProcessRemoteRefs = assetMode === "static" && options.target === "node" && (isCli || isHtmlOutput);
|
|
484
|
+
if (options.remoteAssets && !canProcessRemoteRefs && assetMode === "static" && options.target === "node") logger.warn("remoteAssets was set but cannot be honoured here: fetching remote assets requires a CLI compile, where the document renders at build time. Skipping remote asset fetching.");
|
|
485
|
+
const htmlVariantEntries = /* @__PURE__ */ new Map();
|
|
486
|
+
if (options.target === "node" && (isCli || isHtmlOutput)) {
|
|
487
|
+
const renderWorker = new RenderWorker({
|
|
488
|
+
log: (msg) => logger.debug(msg),
|
|
489
|
+
warn: (msg) => logger.warn(msg),
|
|
490
|
+
allowedReadPaths: [outDir],
|
|
491
|
+
sandbox: "strict"
|
|
492
|
+
});
|
|
493
|
+
const smokeVariant = args.smokeVariant ?? DEFAULT_VARIANT;
|
|
494
|
+
try {
|
|
495
|
+
for (const document of buildDocuments) {
|
|
496
|
+
const variants = isHtmlOutput ? args.htmlVariantMatrix?.get(document.name) ?? [] : [smokeVariant];
|
|
497
|
+
for (const variant of variants) {
|
|
498
|
+
const html = await renderVariantWithWorker({
|
|
499
|
+
renderWorker,
|
|
500
|
+
outDir,
|
|
501
|
+
documentName: document.name,
|
|
502
|
+
variant,
|
|
503
|
+
config,
|
|
504
|
+
assetMode,
|
|
505
|
+
probeRemoteOnMismatch: canProcessRemoteRefs && options.remoteAssets,
|
|
506
|
+
remoteFetch: args.remoteFetch
|
|
507
|
+
});
|
|
508
|
+
if (canProcessRemoteRefs) await processRemoteAssetRefs({
|
|
509
|
+
html,
|
|
510
|
+
documentName: document.name,
|
|
511
|
+
outDir,
|
|
512
|
+
remoteAssets: options.remoteAssets,
|
|
513
|
+
remoteFetch: args.remoteFetch,
|
|
514
|
+
quiet: args.quiet
|
|
515
|
+
});
|
|
516
|
+
if (!isHtmlOutput) {
|
|
517
|
+
args.capturedHtml?.set(document.name, html);
|
|
518
|
+
continue;
|
|
519
|
+
}
|
|
520
|
+
const htmlPath = getHtmlVariantPath(outDir, document.name, variant);
|
|
521
|
+
await mkdir(dirname(htmlPath), { recursive: true });
|
|
522
|
+
await writeFile(htmlPath, html, "utf-8");
|
|
523
|
+
const entries = htmlVariantEntries.get(document.name) ?? [];
|
|
524
|
+
entries.push({
|
|
525
|
+
variant,
|
|
526
|
+
html: `${document.name}/${variant}/${INDEX_HTML_FILE_NAME}`
|
|
527
|
+
});
|
|
528
|
+
htmlVariantEntries.set(document.name, entries);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
} finally {
|
|
532
|
+
await renderWorker.dispose();
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
if (isHtmlOutput) await writeHtmlOutput({
|
|
536
|
+
outDir,
|
|
537
|
+
buildDocuments,
|
|
538
|
+
htmlVariantEntries
|
|
539
|
+
});
|
|
540
|
+
if (!isHtmlOutput) {
|
|
541
|
+
const externals = await collectExternals(outDir, documentNames);
|
|
542
|
+
const externalsPayload = {
|
|
543
|
+
target: options.target,
|
|
544
|
+
externals
|
|
545
|
+
};
|
|
546
|
+
await writeFile(resolve(outDir, "externals.json"), JSON.stringify(externalsPayload, null, " "), "utf-8");
|
|
547
|
+
logger.debug(`Externals for ${options.target}:`, externals.length ? externals.join(", ") : "(none)");
|
|
548
|
+
}
|
|
549
|
+
const compiledIn = `${(performance.now() - startTime).toFixed(2)}ms`;
|
|
550
|
+
const documentName = buildDocuments.length === 1 ? buildDocuments[0].name : `${buildDocuments.length} documents`;
|
|
551
|
+
const structuredOutput = createStructuredOutput({
|
|
552
|
+
documentName,
|
|
553
|
+
outDir,
|
|
554
|
+
compiledIn
|
|
555
|
+
});
|
|
556
|
+
const isDebug = getLogLevel() === LogLevel$1.DEBUG;
|
|
557
|
+
if (isCli && !args.quiet || isDebug) logger.info(atlas(`✓ Successfully compiled ${documentName}`), "\n", JSON.stringify(structuredOutput, null, 2), "\n");
|
|
558
|
+
return [structuredOutput];
|
|
559
|
+
}
|
|
560
|
+
function warnIgnoredOption(message) {
|
|
561
|
+
logger.warn(`ℹ ${message}`);
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* Map each document to the data variants HTML output should render. Throws on
|
|
565
|
+
* the two unrecoverable cases — a selected document with no data at all, and a
|
|
566
|
+
* requested variant that exists for no document — and warns per document for a
|
|
567
|
+
* requested variant that only some documents have.
|
|
568
|
+
*/
|
|
569
|
+
function resolveHtmlVariantMatrix(documents, requestedVariants) {
|
|
570
|
+
const documentsWithoutData = documents.filter((document) => document.variants.length === 0);
|
|
571
|
+
if (documentsWithoutData.length > 0) throw new CompileError(`Can't use --output html for ${documentsWithoutData.map((document) => `"${document.name}"`).join(", ")}: no data files found. Add at least a \`data/${DEFAULT_VARIANT}.json\`.`);
|
|
572
|
+
const matrix = /* @__PURE__ */ new Map();
|
|
573
|
+
if (requestedVariants.length === 0) {
|
|
574
|
+
for (const document of documents) matrix.set(document.name, document.variants);
|
|
575
|
+
return matrix;
|
|
576
|
+
}
|
|
577
|
+
const orphanVariants = requestedVariants.filter((variant) => !documents.some((document) => document.variants.includes(variant)));
|
|
578
|
+
if (orphanVariants.length > 0) throw new CompileError(`No document has the variant(s) ${orphanVariants.map((variant) => `"${variant}"`).join(", ")}. Check the names against your \`data/*.json\` files.`);
|
|
579
|
+
for (const document of documents) {
|
|
580
|
+
const selected = requestedVariants.filter((variant) => document.variants.includes(variant));
|
|
581
|
+
const missing = requestedVariants.filter((variant) => !document.variants.includes(variant));
|
|
582
|
+
if (missing.length > 0) {
|
|
583
|
+
const names = missing.map((variant) => `"${variant}"`).join(", ");
|
|
584
|
+
logger.warn(`Document "${document.name}" has no variant(s) ${names}; skipping for this document.`);
|
|
585
|
+
}
|
|
586
|
+
matrix.set(document.name, selected);
|
|
587
|
+
}
|
|
588
|
+
return matrix;
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* HTML output renders from a forced node build with assets bundled at build
|
|
592
|
+
* time, so the JS-bundle and asset-mode flags have nothing to act on. None of
|
|
593
|
+
* them is build-breaking — we override and warn per flag. The genuinely
|
|
594
|
+
* unrecoverable cases (a document with no data, an unknown variant) are errors,
|
|
595
|
+
* raised later in resolveHtmlVariantMatrix.
|
|
596
|
+
*/
|
|
597
|
+
function warnIncompatibleHtmlOptions(options) {
|
|
598
|
+
const warnIgnored = (flag) => warnIgnoredOption(`The ${flag} flag is not compatible with html output, ignoring.`);
|
|
599
|
+
if (options.target !== "node") warnIgnored("--target");
|
|
600
|
+
if (options.preset !== "node") warnIgnored("--preset");
|
|
601
|
+
if (options.assets !== "static") warnIgnored("--assets");
|
|
602
|
+
if (options.external.length > 0) warnIgnored("--external");
|
|
603
|
+
if (options.bundle.length > 0) warnIgnored("--bundle");
|
|
604
|
+
if (options.conditions.length > 0) warnIgnored("--conditions");
|
|
605
|
+
if (options.externalConditions.length > 0) warnIgnored("--external-conditions");
|
|
606
|
+
if (options.cjs) warnIgnored("--cjs");
|
|
607
|
+
if (options.version) warnIgnored("--version");
|
|
608
|
+
}
|
|
609
|
+
async function runCompile(runArgs) {
|
|
610
|
+
const { options: inputOptions, source, smokeVariant, capturedHtml, capturedAssetState, capturedInputs } = runArgs;
|
|
611
|
+
setLogLevel(parseLogLevelFromEnv());
|
|
612
|
+
const logLevel = getLogLevel();
|
|
613
|
+
const isCli = source === "cli";
|
|
614
|
+
const rawOptions = normalizeCompileOptions(source === "unplugin" ? {
|
|
615
|
+
...inputOptions,
|
|
616
|
+
clean: inputOptions.clean ?? false
|
|
617
|
+
} : inputOptions);
|
|
618
|
+
const isHtmlOutput = rawOptions.output === "html";
|
|
619
|
+
if (isHtmlOutput) warnIncompatibleHtmlOptions(rawOptions);
|
|
620
|
+
const options = isHtmlOutput ? {
|
|
621
|
+
...rawOptions,
|
|
622
|
+
target: "node",
|
|
623
|
+
preset: "node",
|
|
624
|
+
assets: "static",
|
|
625
|
+
cjs: false,
|
|
626
|
+
external: [],
|
|
627
|
+
bundle: [],
|
|
628
|
+
conditions: [],
|
|
629
|
+
externalConditions: [],
|
|
630
|
+
bundleAll: false
|
|
631
|
+
} : rawOptions;
|
|
632
|
+
logger.debug("Compile options", options);
|
|
633
|
+
const { documents: documentNames } = options;
|
|
634
|
+
const { config } = await loadConfig(options.configPath);
|
|
635
|
+
if (!config) throw new Error(NO_CONFIG_FILE_MESSAGE);
|
|
636
|
+
assertProducersAgree(getUserProjectDir());
|
|
637
|
+
compileState.setConfig(config);
|
|
638
|
+
const allDocuments = await getDocuments(config);
|
|
639
|
+
const documents = allDocuments.filter(({ name }) => documentNames.length === 0 || documentNames.includes(name)).sort((a, b) => a.name.localeCompare(b.name));
|
|
640
|
+
const missingDocuments = documentNames.filter((name) => !allDocuments.some(({ name: documentName }) => documentName === name));
|
|
641
|
+
if (missingDocuments.length > 0) logger.warn(`Couldn't find the following documents: "${missingDocuments.join(", ")}"`);
|
|
642
|
+
if (documents.length === 0) throw new Error(NO_DOCUMENTS_MESSAGE);
|
|
643
|
+
buildDocumentExportMap(documents.map(({ name }) => name));
|
|
644
|
+
if (config.sharedAssetsDir) {
|
|
645
|
+
const sharedAssetsDir = getSharedAssetsDir(config);
|
|
646
|
+
const { isDirectory } = await checkDir(sharedAssetsDir);
|
|
647
|
+
if (!isDirectory) throw new Error(`Your configured \`sharedAssetsDir\` not found or is not a directory: ${sharedAssetsDir}`);
|
|
648
|
+
}
|
|
649
|
+
const htmlVariantMatrix = isHtmlOutput ? resolveHtmlVariantMatrix(documents, options.variants) : void 0;
|
|
650
|
+
const outDir = getBundleOutDir(config, options.outDir);
|
|
651
|
+
const isCacheableRun = (runArgs.useDiskCache ?? true) && (isCli || source === "unplugin" && options.assets !== "dynamic") && !isHtmlOutput;
|
|
652
|
+
const cacheKeyOptions = buildCacheKeyOptions({
|
|
653
|
+
options,
|
|
654
|
+
webpackNodeCompat: options.target === "node" && source === "unplugin" && options.userBundler === "webpack"
|
|
655
|
+
});
|
|
656
|
+
if (isCacheableRun) {
|
|
657
|
+
const currentHash = await computeCacheHash(getDocumentsDir(config), cacheKeyOptions);
|
|
658
|
+
if (await readCachedHash(outDir) === currentHash) {
|
|
659
|
+
if (await cachedOutputsExist(documents.map(({ name }) => getDocumentEntryPath(outDir, name)))) {
|
|
660
|
+
logger.info("Cache hit — documents unchanged, skipping compile.");
|
|
661
|
+
return [];
|
|
662
|
+
}
|
|
663
|
+
logger.debug("Cache hash matched but compiled outputs are missing — recompiling.");
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
const runAll = () => compileBundle({
|
|
667
|
+
documentNames: documents.map(({ name }) => name),
|
|
668
|
+
config,
|
|
669
|
+
options,
|
|
670
|
+
logLevel,
|
|
671
|
+
source,
|
|
672
|
+
smokeVariant,
|
|
673
|
+
capturedHtml,
|
|
674
|
+
capturedAssetState,
|
|
675
|
+
capturedInputs,
|
|
676
|
+
remoteFetch: runArgs.remoteFetch,
|
|
677
|
+
quiet: runArgs.quiet,
|
|
678
|
+
htmlVariantMatrix
|
|
679
|
+
});
|
|
680
|
+
const suppressBuildLogs = (_level, ...args) => {
|
|
681
|
+
const msg = args.join(" ");
|
|
682
|
+
if (msg.includes("building SSR bundle for production")) return false;
|
|
683
|
+
if (msg.includes("rolldown-vite") && msg.includes("building")) return false;
|
|
684
|
+
if (msg.includes("built in")) return false;
|
|
685
|
+
return true;
|
|
686
|
+
};
|
|
687
|
+
const results = isCli ? await withPrefixedConsole(() => runAll(), suppressBuildLogs) : await runAll();
|
|
688
|
+
if (isCacheableRun) await writeCacheHash(outDir, await computeCacheHash(getDocumentsDir(config), cacheKeyOptions));
|
|
689
|
+
const { external } = options;
|
|
690
|
+
const externalLen = external.length;
|
|
691
|
+
if (isCli && externalLen > 0 && !runArgs.quiet) logger.info(`ℹ External packages: ${external.join(", ")}. Make sure ${pluralize("this", externalLen)} ${pluralize("is", externalLen)} installed where you call render.`);
|
|
692
|
+
return results;
|
|
693
|
+
}
|
|
694
|
+
async function compile(options) {
|
|
695
|
+
await warnOnLockstepDrift(options.configPath ? dirname(options.configPath) : process.cwd());
|
|
696
|
+
return runCompile({
|
|
697
|
+
options,
|
|
698
|
+
source: "cli"
|
|
699
|
+
}).then(() => process.exit(0)).catch((error) => {
|
|
700
|
+
logger.error("Compile error", error);
|
|
701
|
+
process.exit(1);
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
async function compileForStudio(options, studioOptions = {}) {
|
|
705
|
+
const capturedHtml = /* @__PURE__ */ new Map();
|
|
706
|
+
const capturedInputs = /* @__PURE__ */ new Set();
|
|
707
|
+
return {
|
|
708
|
+
outputs: await runCompile({
|
|
709
|
+
options,
|
|
710
|
+
source: "cli",
|
|
711
|
+
smokeVariant: studioOptions.variant,
|
|
712
|
+
capturedHtml,
|
|
713
|
+
capturedInputs,
|
|
714
|
+
useDiskCache: studioOptions.useDiskCache,
|
|
715
|
+
remoteFetch: studioOptions.remoteFetch,
|
|
716
|
+
quiet: studioOptions.quiet
|
|
717
|
+
}),
|
|
718
|
+
html: capturedHtml,
|
|
719
|
+
inputs: [...capturedInputs]
|
|
720
|
+
};
|
|
721
|
+
}
|
|
722
|
+
async function compileForUnplugin(options, extras = {}) {
|
|
723
|
+
return runCompile({
|
|
724
|
+
options,
|
|
725
|
+
source: "unplugin",
|
|
726
|
+
capturedAssetState: extras.capturedAssetState
|
|
727
|
+
});
|
|
728
|
+
}
|
|
729
|
+
async function compileForTest(options) {
|
|
730
|
+
return compileForUnplugin(options);
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
//#endregion
|
|
734
|
+
export { compile, compileForStudio, compileForTest, compileForUnplugin, getBundleOutDir, getDefaultOutDir, getDocumentAssetsPath, getDocumentEntryPath, getDocumentOutDir, getHtmlVariantPath, renderCompiledDocument, resolveHtmlVariantMatrix, warnIncompatibleHtmlOptions };
|
|
735
|
+
//# sourceMappingURL=compile.mjs.map
|