@seanhogg/builderforce-webcontainers-core 2026.10.2 → 2026.10.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.
- package/dist/build.d.ts +42 -0
- package/dist/build.d.ts.map +1 -0
- package/dist/build.js +65 -0
- package/dist/build.js.map +1 -0
- package/dist/buildHost.d.ts +31 -0
- package/dist/buildHost.d.ts.map +1 -0
- package/dist/buildHost.js +125 -0
- package/dist/buildHost.js.map +1 -0
- package/dist/buildHtml.d.ts +28 -0
- package/dist/buildHtml.d.ts.map +1 -0
- package/dist/buildHtml.js +74 -0
- package/dist/buildHtml.js.map +1 -0
- package/dist/bundler.d.ts +129 -0
- package/dist/bundler.d.ts.map +1 -0
- package/dist/bundler.js +79 -0
- package/dist/bundler.js.map +1 -0
- package/dist/check/acquire.d.ts +46 -0
- package/dist/check/acquire.d.ts.map +1 -0
- package/dist/check/acquire.js +179 -0
- package/dist/check/acquire.js.map +1 -0
- package/dist/check/compilerHost.d.ts +22 -0
- package/dist/check/compilerHost.d.ts.map +1 -0
- package/dist/check/compilerHost.js +128 -0
- package/dist/check/compilerHost.js.map +1 -0
- package/dist/check/diagnostics.d.ts +23 -0
- package/dist/check/diagnostics.d.ts.map +1 -0
- package/dist/check/diagnostics.js +28 -0
- package/dist/check/diagnostics.js.map +1 -0
- package/dist/check/index.d.ts +19 -0
- package/dist/check/index.d.ts.map +1 -0
- package/dist/check/index.js +13 -0
- package/dist/check/index.js.map +1 -0
- package/dist/check/projects.d.ts +26 -0
- package/dist/check/projects.d.ts.map +1 -0
- package/dist/check/projects.js +124 -0
- package/dist/check/projects.js.map +1 -0
- package/dist/check/shims.d.ts +29 -0
- package/dist/check/shims.d.ts.map +1 -0
- package/dist/check/shims.js +76 -0
- package/dist/check/shims.js.map +1 -0
- package/dist/check/typeStore.d.ts +57 -0
- package/dist/check/typeStore.d.ts.map +1 -0
- package/dist/check/typeStore.js +89 -0
- package/dist/check/typeStore.js.map +1 -0
- package/dist/check/typecheck.d.ts +29 -0
- package/dist/check/typecheck.d.ts.map +1 -0
- package/dist/check/typecheck.js +91 -0
- package/dist/check/typecheck.js.map +1 -0
- package/dist/compileComponent.d.ts +8 -0
- package/dist/compileComponent.d.ts.map +1 -0
- package/dist/compileComponent.js +22 -0
- package/dist/compileComponent.js.map +1 -0
- package/dist/compileScript.d.ts +19 -4
- package/dist/compileScript.d.ts.map +1 -1
- package/dist/compileScript.js +37 -12
- package/dist/compileScript.js.map +1 -1
- package/dist/components.d.ts +41 -0
- package/dist/components.d.ts.map +1 -0
- package/dist/components.js +14 -0
- package/dist/components.js.map +1 -0
- package/dist/detectProject.d.ts +3 -0
- package/dist/detectProject.d.ts.map +1 -1
- package/dist/detectProject.js +16 -6
- package/dist/detectProject.js.map +1 -1
- package/dist/devServer.d.ts +5 -2
- package/dist/devServer.d.ts.map +1 -1
- package/dist/devServer.js +12 -8
- package/dist/devServer.js.map +1 -1
- package/dist/hash.d.ts +2 -0
- package/dist/hash.d.ts.map +1 -0
- package/dist/hash.js +22 -0
- package/dist/hash.js.map +1 -0
- package/dist/index.d.ts +24 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -3
- package/dist/index.js.map +1 -1
- package/dist/installer/bins.d.ts +24 -0
- package/dist/installer/bins.d.ts.map +1 -0
- package/dist/installer/bins.js +56 -0
- package/dist/installer/bins.js.map +1 -0
- package/dist/installer/index.d.ts +14 -0
- package/dist/installer/index.d.ts.map +1 -0
- package/dist/installer/index.js +9 -0
- package/dist/installer/index.js.map +1 -0
- package/dist/installer/install.d.ts +46 -0
- package/dist/installer/install.d.ts.map +1 -0
- package/dist/installer/install.js +245 -0
- package/dist/installer/install.js.map +1 -0
- package/dist/installer/lockfile.d.ts +49 -0
- package/dist/installer/lockfile.d.ts.map +1 -0
- package/dist/installer/lockfile.js +110 -0
- package/dist/installer/lockfile.js.map +1 -0
- package/dist/installer/registry.d.ts +84 -0
- package/dist/installer/registry.d.ts.map +1 -0
- package/dist/installer/registry.js +130 -0
- package/dist/installer/registry.js.map +1 -0
- package/dist/installer/semver.d.ts +38 -0
- package/dist/installer/semver.d.ts.map +1 -0
- package/dist/installer/semver.js +187 -0
- package/dist/installer/semver.js.map +1 -0
- package/dist/installer/spec.d.ts +30 -0
- package/dist/installer/spec.d.ts.map +1 -0
- package/dist/installer/spec.js +30 -0
- package/dist/installer/spec.js.map +1 -0
- package/dist/installer/tar.d.ts +17 -0
- package/dist/installer/tar.d.ts.map +1 -0
- package/dist/installer/tar.js +150 -0
- package/dist/installer/tar.js.map +1 -0
- package/dist/installer/tree.d.ts +48 -0
- package/dist/installer/tree.d.ts.map +1 -0
- package/dist/installer/tree.js +179 -0
- package/dist/installer/tree.js.map +1 -0
- package/dist/node/assert.d.ts +15 -0
- package/dist/node/assert.d.ts.map +1 -0
- package/dist/node/assert.js +137 -0
- package/dist/node/assert.js.map +1 -0
- package/dist/node/buffer.d.ts +84 -0
- package/dist/node/buffer.d.ts.map +1 -0
- package/dist/node/buffer.js +304 -0
- package/dist/node/buffer.js.map +1 -0
- package/dist/node/builtins.d.ts +25 -0
- package/dist/node/builtins.d.ts.map +1 -0
- package/dist/node/builtins.js +101 -0
- package/dist/node/builtins.js.map +1 -0
- package/dist/node/callable.d.ts +13 -0
- package/dist/node/callable.d.ts.map +1 -0
- package/dist/node/callable.js +26 -0
- package/dist/node/callable.js.map +1 -0
- package/dist/node/childProcess.d.ts +13 -0
- package/dist/node/childProcess.d.ts.map +1 -0
- package/dist/node/childProcess.js +143 -0
- package/dist/node/childProcess.js.map +1 -0
- package/dist/node/crypto.d.ts +3 -0
- package/dist/node/crypto.d.ts.map +1 -0
- package/dist/node/crypto.js +180 -0
- package/dist/node/crypto.js.map +1 -0
- package/dist/node/esm.d.ts +9 -0
- package/dist/node/esm.d.ts.map +1 -0
- package/dist/node/esm.js +202 -0
- package/dist/node/esm.js.map +1 -0
- package/dist/node/events.d.ts +40 -0
- package/dist/node/events.d.ts.map +1 -0
- package/dist/node/events.js +160 -0
- package/dist/node/events.js.map +1 -0
- package/dist/node/fs/index.d.ts +7 -0
- package/dist/node/fs/index.d.ts.map +1 -0
- package/dist/node/fs/index.js +270 -0
- package/dist/node/fs/index.js.map +1 -0
- package/dist/node/fs/stats.d.ts +93 -0
- package/dist/node/fs/stats.d.ts.map +1 -0
- package/dist/node/fs/stats.js +104 -0
- package/dist/node/fs/stats.js.map +1 -0
- package/dist/node/fs/sync.d.ts +98 -0
- package/dist/node/fs/sync.d.ts.map +1 -0
- package/dist/node/fs/sync.js +348 -0
- package/dist/node/fs/sync.js.map +1 -0
- package/dist/node/hashes.d.ts +15 -0
- package/dist/node/hashes.d.ts.map +1 -0
- package/dist/node/hashes.js +195 -0
- package/dist/node/hashes.js.map +1 -0
- package/dist/node/http/client.d.ts +35 -0
- package/dist/node/http/client.d.ts.map +1 -0
- package/dist/node/http/client.js +161 -0
- package/dist/node/http/client.js.map +1 -0
- package/dist/node/http/index.d.ts +5 -0
- package/dist/node/http/index.d.ts.map +1 -0
- package/dist/node/http/index.js +125 -0
- package/dist/node/http/index.js.map +1 -0
- package/dist/node/http/server.d.ts +135 -0
- package/dist/node/http/server.d.ts.map +1 -0
- package/dist/node/http/server.js +308 -0
- package/dist/node/http/server.js.map +1 -0
- package/dist/node/http/status.d.ts +3 -0
- package/dist/node/http/status.d.ts.map +1 -0
- package/dist/node/http/status.js +13 -0
- package/dist/node/http/status.js.map +1 -0
- package/dist/node/inspect.d.ts +22 -0
- package/dist/node/inspect.d.ts.map +1 -0
- package/dist/node/inspect.js +172 -0
- package/dist/node/inspect.js.map +1 -0
- package/dist/node/loader.d.ts +91 -0
- package/dist/node/loader.d.ts.map +1 -0
- package/dist/node/loader.js +265 -0
- package/dist/node/loader.js.map +1 -0
- package/dist/node/loop.d.ts +71 -0
- package/dist/node/loop.d.ts.map +1 -0
- package/dist/node/loop.js +189 -0
- package/dist/node/loop.js.map +1 -0
- package/dist/node/misc.d.ts +10 -0
- package/dist/node/misc.d.ts.map +1 -0
- package/dist/node/misc.js +256 -0
- package/dist/node/misc.js.map +1 -0
- package/dist/node/path.d.ts +14 -0
- package/dist/node/path.d.ts.map +1 -0
- package/dist/node/path.js +128 -0
- package/dist/node/path.js.map +1 -0
- package/dist/node/process.d.ts +31 -0
- package/dist/node/process.d.ts.map +1 -0
- package/dist/node/process.js +309 -0
- package/dist/node/process.js.map +1 -0
- package/dist/node/program.d.ts +19 -0
- package/dist/node/program.d.ts.map +1 -0
- package/dist/node/program.js +165 -0
- package/dist/node/program.js.map +1 -0
- package/dist/node/readline.d.ts +2 -0
- package/dist/node/readline.d.ts.map +1 -0
- package/dist/node/readline.js +155 -0
- package/dist/node/readline.js.map +1 -0
- package/dist/node/resolve.d.ts +45 -0
- package/dist/node/resolve.d.ts.map +1 -0
- package/dist/node/resolve.js +206 -0
- package/dist/node/resolve.js.map +1 -0
- package/dist/node/runtime.d.ts +40 -0
- package/dist/node/runtime.d.ts.map +1 -0
- package/dist/node/runtime.js +149 -0
- package/dist/node/runtime.js.map +1 -0
- package/dist/node/stream/index.d.ts +52 -0
- package/dist/node/stream/index.d.ts.map +1 -0
- package/dist/node/stream/index.js +184 -0
- package/dist/node/stream/index.js.map +1 -0
- package/dist/node/stream/readable.d.ts +83 -0
- package/dist/node/stream/readable.d.ts.map +1 -0
- package/dist/node/stream/readable.js +325 -0
- package/dist/node/stream/readable.js.map +1 -0
- package/dist/node/stream/writable.d.ts +80 -0
- package/dist/node/stream/writable.d.ts.map +1 -0
- package/dist/node/stream/writable.js +224 -0
- package/dist/node/stream/writable.js.map +1 -0
- package/dist/node/urlqs.d.ts +22 -0
- package/dist/node/urlqs.d.ts.map +1 -0
- package/dist/node/urlqs.js +165 -0
- package/dist/node/urlqs.js.map +1 -0
- package/dist/node/util.d.ts +37 -0
- package/dist/node/util.d.ts.map +1 -0
- package/dist/node/util.js +160 -0
- package/dist/node/util.js.map +1 -0
- package/dist/node/zlib.d.ts +2 -0
- package/dist/node/zlib.d.ts.map +1 -0
- package/dist/node/zlib.js +133 -0
- package/dist/node/zlib.js.map +1 -0
- package/dist/packageCdn.d.ts +40 -0
- package/dist/packageCdn.d.ts.map +1 -1
- package/dist/packageCdn.js +54 -7
- package/dist/packageCdn.js.map +1 -1
- package/dist/projectConfig.d.ts +6 -2
- package/dist/projectConfig.d.ts.map +1 -1
- package/dist/projectConfig.js +32 -8
- package/dist/projectConfig.js.map +1 -1
- package/dist/shell/builtins.d.ts +23 -0
- package/dist/shell/builtins.d.ts.map +1 -0
- package/dist/shell/builtins.js +131 -0
- package/dist/shell/builtins.js.map +1 -0
- package/dist/shell/context.d.ts +41 -0
- package/dist/shell/context.d.ts.map +1 -0
- package/dist/shell/context.js +65 -0
- package/dist/shell/context.js.map +1 -0
- package/dist/shell/devHandoff.d.ts +18 -0
- package/dist/shell/devHandoff.d.ts.map +1 -0
- package/dist/shell/devHandoff.js +36 -0
- package/dist/shell/devHandoff.js.map +1 -0
- package/dist/shell/exec.d.ts +67 -0
- package/dist/shell/exec.d.ts.map +1 -0
- package/dist/shell/exec.js +247 -0
- package/dist/shell/exec.js.map +1 -0
- package/dist/shell/expand.d.ts +28 -0
- package/dist/shell/expand.d.ts.map +1 -0
- package/dist/shell/expand.js +149 -0
- package/dist/shell/expand.js.map +1 -0
- package/dist/shell/fileCommands.d.ts +10 -0
- package/dist/shell/fileCommands.d.ts.map +1 -0
- package/dist/shell/fileCommands.js +208 -0
- package/dist/shell/fileCommands.js.map +1 -0
- package/dist/shell/lineEditor.d.ts +43 -0
- package/dist/shell/lineEditor.d.ts.map +1 -0
- package/dist/shell/lineEditor.js +234 -0
- package/dist/shell/lineEditor.js.map +1 -0
- package/dist/shell/npm.d.ts +6 -0
- package/dist/shell/npm.d.ts.map +1 -0
- package/dist/shell/npm.js +234 -0
- package/dist/shell/npm.js.map +1 -0
- package/dist/shell/parse.d.ts +73 -0
- package/dist/shell/parse.d.ts.map +1 -0
- package/dist/shell/parse.js +300 -0
- package/dist/shell/parse.js.map +1 -0
- package/dist/shell/program.d.ts +12 -0
- package/dist/shell/program.d.ts.map +1 -0
- package/dist/shell/program.js +219 -0
- package/dist/shell/program.js.map +1 -0
- package/dist/shell/textCommands.d.ts +15 -0
- package/dist/shell/textCommands.d.ts.map +1 -0
- package/dist/shell/textCommands.js +185 -0
- package/dist/shell/textCommands.js.map +1 -0
- package/dist/styleModules.d.ts +6 -0
- package/dist/styleModules.d.ts.map +1 -1
- package/dist/styleModules.js +14 -4
- package/dist/styleModules.js.map +1 -1
- package/dist/svelteCompiler.d.ts +28 -0
- package/dist/svelteCompiler.d.ts.map +1 -0
- package/dist/svelteCompiler.js +13 -0
- package/dist/svelteCompiler.js.map +1 -0
- package/dist/system/commands.d.ts +26 -0
- package/dist/system/commands.d.ts.map +1 -0
- package/dist/system/commands.js +53 -0
- package/dist/system/commands.js.map +1 -0
- package/dist/system/index.d.ts +23 -0
- package/dist/system/index.d.ts.map +1 -0
- package/dist/system/index.js +16 -0
- package/dist/system/index.js.map +1 -0
- package/dist/system/kernel.d.ts +54 -0
- package/dist/system/kernel.d.ts.map +1 -0
- package/dist/system/kernel.js +81 -0
- package/dist/system/kernel.js.map +1 -0
- package/dist/system/ports.d.ts +32 -0
- package/dist/system/ports.d.ts.map +1 -0
- package/dist/system/ports.js +57 -0
- package/dist/system/ports.js.map +1 -0
- package/dist/system/process.d.ts +32 -0
- package/dist/system/process.d.ts.map +1 -0
- package/dist/system/process.js +130 -0
- package/dist/system/process.js.map +1 -0
- package/dist/system/programs.d.ts +10 -0
- package/dist/system/programs.d.ts.map +1 -0
- package/dist/system/programs.js +22 -0
- package/dist/system/programs.js.map +1 -0
- package/dist/system/terminal.d.ts +45 -0
- package/dist/system/terminal.d.ts.map +1 -0
- package/dist/system/terminal.js +127 -0
- package/dist/system/terminal.js.map +1 -0
- package/dist/system/types.d.ts +100 -0
- package/dist/system/types.d.ts.map +1 -0
- package/dist/system/types.js +2 -0
- package/dist/system/types.js.map +1 -0
- package/dist/vfs.d.ts +28 -4
- package/dist/vfs.d.ts.map +1 -1
- package/dist/vfs.js +95 -32
- package/dist/vfs.js.map +1 -1
- package/dist/vueCompiler.d.ts +75 -0
- package/dist/vueCompiler.d.ts.map +1 -0
- package/dist/vueCompiler.js +67 -0
- package/dist/vueCompiler.js.map +1 -0
- package/package.json +18 -2
- package/src/build.ts +105 -0
- package/src/buildHost.ts +154 -0
- package/src/buildHtml.ts +101 -0
- package/src/bundler.ts +190 -0
- package/src/check/acquire.ts +212 -0
- package/src/check/compilerHost.ts +138 -0
- package/src/check/diagnostics.ts +48 -0
- package/src/check/index.ts +28 -0
- package/src/check/projects.ts +149 -0
- package/src/check/shims.ts +88 -0
- package/src/check/typeStore.ts +103 -0
- package/src/check/typecheck.ts +134 -0
- package/src/compileComponent.ts +21 -0
- package/src/compileScript.ts +42 -13
- package/src/components.ts +59 -0
- package/src/detectProject.ts +18 -6
- package/src/devServer.ts +16 -11
- package/src/hash.ts +22 -0
- package/src/index.ts +35 -6
- package/src/installer/bins.ts +64 -0
- package/src/installer/index.ts +13 -0
- package/src/installer/install.ts +275 -0
- package/src/installer/lockfile.ts +146 -0
- package/src/installer/registry.ts +175 -0
- package/src/installer/semver.ts +190 -0
- package/src/installer/spec.ts +53 -0
- package/src/installer/tar.ts +155 -0
- package/src/installer/tree.ts +236 -0
- package/src/node/assert.ts +127 -0
- package/src/node/buffer.ts +304 -0
- package/src/node/builtins.ts +123 -0
- package/src/node/callable.ts +25 -0
- package/src/node/childProcess.ts +164 -0
- package/src/node/crypto.ts +187 -0
- package/src/node/esm.ts +196 -0
- package/src/node/events.ts +176 -0
- package/src/node/fs/index.ts +277 -0
- package/src/node/fs/stats.ts +110 -0
- package/src/node/fs/sync.ts +335 -0
- package/src/node/hashes.ts +171 -0
- package/src/node/http/client.ts +173 -0
- package/src/node/http/index.ts +122 -0
- package/src/node/http/server.ts +308 -0
- package/src/node/http/status.ts +13 -0
- package/src/node/inspect.ts +166 -0
- package/src/node/loader.ts +293 -0
- package/src/node/loop.ts +193 -0
- package/src/node/misc.ts +250 -0
- package/src/node/path.ts +135 -0
- package/src/node/process.ts +324 -0
- package/src/node/program.ts +170 -0
- package/src/node/readline.ts +157 -0
- package/src/node/resolve.ts +216 -0
- package/src/node/runtime.ts +184 -0
- package/src/node/stream/index.ts +196 -0
- package/src/node/stream/readable.ts +345 -0
- package/src/node/stream/writable.ts +244 -0
- package/src/node/urlqs.ts +162 -0
- package/src/node/util.ts +145 -0
- package/src/node/zlib.ts +145 -0
- package/src/packageCdn.ts +91 -7
- package/src/projectConfig.ts +34 -7
- package/src/shell/builtins.ts +141 -0
- package/src/shell/context.ts +89 -0
- package/src/shell/devHandoff.ts +49 -0
- package/src/shell/exec.ts +268 -0
- package/src/shell/expand.ts +145 -0
- package/src/shell/fileCommands.ts +206 -0
- package/src/shell/lineEditor.ts +233 -0
- package/src/shell/npm.ts +229 -0
- package/src/shell/parse.ts +295 -0
- package/src/shell/program.ts +223 -0
- package/src/shell/textCommands.ts +177 -0
- package/src/styleModules.ts +15 -4
- package/src/svelteCompiler.ts +31 -0
- package/src/system/commands.ts +72 -0
- package/src/system/index.ts +22 -0
- package/src/system/kernel.ts +106 -0
- package/src/system/ports.ts +73 -0
- package/src/system/process.ts +158 -0
- package/src/system/programs.ts +31 -0
- package/src/system/terminal.ts +135 -0
- package/src/system/types.ts +103 -0
- package/src/vfs.ts +92 -28
- package/src/vueCompiler.ts +121 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { dirname, extname, join } from '../paths.js';
|
|
2
|
+
/** Tool configs (`vite.config.ts`…) describe the build, which runs elsewhere: not checked. */
|
|
3
|
+
const TOOL_CONFIG = /(^|\/)(vite|vitest|svelte|tailwind|postcss|eslint|prettier|playwright)\.config\.[cm]?[jt]s$/;
|
|
4
|
+
const SOURCE_EXTENSIONS = ['.ts', '.tsx', '.mts', '.cts'];
|
|
5
|
+
/** "No inputs were found in config file" — a reference covering only tool configs. */
|
|
6
|
+
const NO_INPUTS = 18003;
|
|
7
|
+
/** Vite's React + TS template, made strict-ish; what a project with no tsconfig gets. */
|
|
8
|
+
export function defaultCompilerOptions(ts, jsxImportSource) {
|
|
9
|
+
return {
|
|
10
|
+
target: ts.ScriptTarget.ES2020,
|
|
11
|
+
lib: ['lib.es2020.d.ts', 'lib.dom.d.ts', 'lib.dom.iterable.d.ts'],
|
|
12
|
+
module: ts.ModuleKind.ESNext,
|
|
13
|
+
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
14
|
+
jsx: ts.JsxEmit.ReactJSX,
|
|
15
|
+
...(jsxImportSource ? { jsxImportSource } : {}),
|
|
16
|
+
strict: true,
|
|
17
|
+
noFallthroughCasesInSwitch: true,
|
|
18
|
+
isolatedModules: true,
|
|
19
|
+
resolveJsonModule: true,
|
|
20
|
+
allowImportingTsExtensions: true,
|
|
21
|
+
esModuleInterop: true,
|
|
22
|
+
skipLibCheck: true,
|
|
23
|
+
noEmit: true,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/** Options no in-browser check wants, whatever the config says: nothing is emitted. */
|
|
27
|
+
function forCheck(options) {
|
|
28
|
+
return {
|
|
29
|
+
...options,
|
|
30
|
+
noEmit: true,
|
|
31
|
+
skipLibCheck: true,
|
|
32
|
+
composite: false,
|
|
33
|
+
incremental: false,
|
|
34
|
+
declaration: false,
|
|
35
|
+
declarationMap: false,
|
|
36
|
+
emitDeclarationOnly: false,
|
|
37
|
+
tsBuildInfoFile: undefined,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function globToRegExp(pattern) {
|
|
41
|
+
let source = '';
|
|
42
|
+
for (let i = 0; i < pattern.length; i++) {
|
|
43
|
+
const ch = pattern[i];
|
|
44
|
+
if (ch === '*' && pattern[i + 1] === '*' && pattern[i + 2] === '/') {
|
|
45
|
+
source += '(?:[^/]+/)*';
|
|
46
|
+
i += 2;
|
|
47
|
+
}
|
|
48
|
+
else if (ch === '*')
|
|
49
|
+
source += '[^/]*';
|
|
50
|
+
else if (ch === '?')
|
|
51
|
+
source += '[^/]';
|
|
52
|
+
else
|
|
53
|
+
source += ch.replace(/[.+^${}()|[\]\\]/g, '\\$&');
|
|
54
|
+
}
|
|
55
|
+
return new RegExp(`^${source}$`);
|
|
56
|
+
}
|
|
57
|
+
/** A tsconfig `include`/`exclude` spec as a matcher; a bare directory means everything under it. */
|
|
58
|
+
function specMatcher(root, spec) {
|
|
59
|
+
let abs = join(root, spec);
|
|
60
|
+
const last = abs.slice(abs.lastIndexOf('/') + 1);
|
|
61
|
+
if (!/[*?]/.test(last) && !extname(last))
|
|
62
|
+
abs = `${abs === '/' ? '' : abs}/**/*`;
|
|
63
|
+
return globToRegExp(abs);
|
|
64
|
+
}
|
|
65
|
+
/** The ParseConfigHost the config parser reads through: the VFS plus fetched `extends` packages. */
|
|
66
|
+
export function createParseConfigHost(fs, store) {
|
|
67
|
+
return {
|
|
68
|
+
useCaseSensitiveFileNames: true,
|
|
69
|
+
fileExists: (path) => fs.isFile(path) || store.read(path) !== undefined,
|
|
70
|
+
readFile: (path) => fs.readText(path) ?? store.read(path),
|
|
71
|
+
readDirectory(rootDir, extensions, excludes, includes) {
|
|
72
|
+
const include = (includes ?? ['**/*']).map((spec) => specMatcher(rootDir, spec));
|
|
73
|
+
const exclude = (excludes ?? []).map((spec) => specMatcher(rootDir, spec));
|
|
74
|
+
return fs.list().filter((path) => extensions.some((ext) => path.endsWith(ext)) &&
|
|
75
|
+
!path.includes('/node_modules/') &&
|
|
76
|
+
include.some((re) => re.test(path)) &&
|
|
77
|
+
!exclude.some((re) => re.test(path)));
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function parseConfig(ts, host, configPath) {
|
|
82
|
+
const text = host.readFile(configPath) ?? '';
|
|
83
|
+
const json = ts.parseConfigFileTextToJson(configPath, text);
|
|
84
|
+
if (json.error)
|
|
85
|
+
return { errors: [json.error] };
|
|
86
|
+
return ts.parseJsonConfigFileContent(json.config, host, dirname(configPath), undefined, configPath);
|
|
87
|
+
}
|
|
88
|
+
function referencedConfigs(ts, host, configPath) {
|
|
89
|
+
const json = ts.parseConfigFileTextToJson(configPath, host.readFile(configPath) ?? '').config;
|
|
90
|
+
const references = json?.references ?? [];
|
|
91
|
+
// A "solution" config — references and nothing of its own — is checked through its references.
|
|
92
|
+
const ownsFiles = (json?.files?.length ?? 0) > 0 || json?.include !== undefined;
|
|
93
|
+
if (!references.length || ownsFiles)
|
|
94
|
+
return [];
|
|
95
|
+
return references
|
|
96
|
+
.map((ref) => (typeof ref.path === 'string' ? join(dirname(configPath), ref.path) : undefined))
|
|
97
|
+
.filter((path) => !!path)
|
|
98
|
+
.map((path) => (path.endsWith('.json') ? path : join(path, 'tsconfig.json')))
|
|
99
|
+
.filter((path) => host.fileExists(path));
|
|
100
|
+
}
|
|
101
|
+
export function resolveCheckProjects(ts, fs, store, jsxImportSource) {
|
|
102
|
+
const host = createParseConfigHost(fs, store);
|
|
103
|
+
const root = ['/tsconfig.json', '/jsconfig.json'].find((path) => fs.isFile(path));
|
|
104
|
+
if (!root) {
|
|
105
|
+
const rootNames = fs.list().filter((path) => SOURCE_EXTENSIONS.some((ext) => path.endsWith(ext)) && !path.includes('/node_modules/') && !TOOL_CONFIG.test(path));
|
|
106
|
+
return rootNames.length ? [{ options: defaultCompilerOptions(ts, jsxImportSource), rootNames, errors: [] }] : [];
|
|
107
|
+
}
|
|
108
|
+
const configs = referencedConfigs(ts, host, root);
|
|
109
|
+
const projects = [];
|
|
110
|
+
for (const configPath of configs.length ? configs : [root]) {
|
|
111
|
+
const parsed = parseConfig(ts, host, configPath);
|
|
112
|
+
const errors = parsed.errors.filter((d) => d.code !== NO_INPUTS);
|
|
113
|
+
if (!('options' in parsed)) {
|
|
114
|
+
projects.push({ configPath, options: {}, rootNames: [], errors });
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
const rootNames = parsed.fileNames.filter((path) => !TOOL_CONFIG.test(path));
|
|
118
|
+
if (!rootNames.length && !errors.length)
|
|
119
|
+
continue;
|
|
120
|
+
projects.push({ configPath, options: forCheck(parsed.options), rootNames, errors });
|
|
121
|
+
}
|
|
122
|
+
return projects;
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=projects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projects.js","sourceRoot":"","sources":["../../src/check/projects.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAqBrD,8FAA8F;AAC9F,MAAM,WAAW,GAAG,6FAA6F,CAAC;AAClH,MAAM,iBAAiB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAC1D,sFAAsF;AACtF,MAAM,SAAS,GAAG,KAAK,CAAC;AAExB,yFAAyF;AACzF,MAAM,UAAU,sBAAsB,CAAC,EAAa,EAAE,eAAwB;IAC5E,OAAO;QACL,MAAM,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM;QAC9B,GAAG,EAAE,CAAC,iBAAiB,EAAE,cAAc,EAAE,uBAAuB,CAAC;QACjE,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,MAAM;QAC5B,gBAAgB,EAAE,EAAE,CAAC,oBAAoB,CAAC,OAAO;QACjD,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ;QACxB,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/C,MAAM,EAAE,IAAI;QACZ,0BAA0B,EAAE,IAAI;QAChC,eAAe,EAAE,IAAI;QACrB,iBAAiB,EAAE,IAAI;QACvB,0BAA0B,EAAE,IAAI;QAChC,eAAe,EAAE,IAAI;QACrB,YAAY,EAAE,IAAI;QAClB,MAAM,EAAE,IAAI;KACb,CAAC;AACJ,CAAC;AAED,uFAAuF;AACvF,SAAS,QAAQ,CAAC,OAA2B;IAC3C,OAA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 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ambient declarations the checker adds, standing in for what a local install
|
|
3
|
+
* would provide:
|
|
4
|
+
* • Vite's `vite/client` (`import.meta.env`, CSS/asset/`?raw` imports) and CRA's
|
|
5
|
+
* `react-scripts` types. Shimmed rather than fetched: they are what every
|
|
6
|
+
* generated app references, and a small local copy never fails to load;
|
|
7
|
+
* • `.vue` / `.svelte` imports. Component internals are not type-checked yet;
|
|
8
|
+
* importing one must not be an error;
|
|
9
|
+
* • packages whose types could not be found, declared as `any` — a CDN miss is
|
|
10
|
+
* not the user's type error.
|
|
11
|
+
*
|
|
12
|
+
* A pattern the project (or a fetched package) already declares is skipped: two
|
|
13
|
+
* declarations of `*.vue` with a default export each would be an error of ours.
|
|
14
|
+
*/
|
|
15
|
+
export declare const SHIM_DIR = "/__bfwc_shims__";
|
|
16
|
+
export declare const AMBIENT_SHIM_PATH = "/__bfwc_shims__/ambient.d.ts";
|
|
17
|
+
/** What a shimmed type reference (`/// <reference types="vite/client" />`) resolves to. */
|
|
18
|
+
export declare const EMPTY_TYPES_PATH = "/__bfwc_shims__/empty.d.ts";
|
|
19
|
+
export declare const SHIMMED_TYPE_REFERENCES: ReadonlySet<string>;
|
|
20
|
+
/** True when any of `texts` declares `declare module '<pattern>'`. */
|
|
21
|
+
export declare function declaresModule(texts: Iterable<string>, pattern: string): boolean;
|
|
22
|
+
export interface AmbientShimOptions {
|
|
23
|
+
/** Declarations already loaded: the project's own `.d.ts` files and fetched package types. */
|
|
24
|
+
existing: string[];
|
|
25
|
+
/** Packages with no types found — declared as `any`. */
|
|
26
|
+
untyped: string[];
|
|
27
|
+
}
|
|
28
|
+
export declare function ambientShim(options: AmbientShimOptions): string;
|
|
29
|
+
//# sourceMappingURL=shims.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shims.d.ts","sourceRoot":"","sources":["../../src/check/shims.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,eAAO,MAAM,QAAQ,oBAAoB,CAAC;AAC1C,eAAO,MAAM,iBAAiB,iCAA6B,CAAC;AAC5D,2FAA2F;AAC3F,eAAO,MAAM,gBAAgB,+BAA2B,CAAC;AACzD,eAAO,MAAM,uBAAuB,EAAE,WAAW,CAAC,MAAM,CAA6C,CAAC;AAwCtG,sEAAsE;AACtE,wBAAgB,cAAc,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAIhF;AAED,MAAM,WAAW,kBAAkB;IACjC,8FAA8F;IAC9F,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,wDAAwD;IACxD,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,MAAM,CAc/D"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ambient declarations the checker adds, standing in for what a local install
|
|
3
|
+
* would provide:
|
|
4
|
+
* • Vite's `vite/client` (`import.meta.env`, CSS/asset/`?raw` imports) and CRA's
|
|
5
|
+
* `react-scripts` types. Shimmed rather than fetched: they are what every
|
|
6
|
+
* generated app references, and a small local copy never fails to load;
|
|
7
|
+
* • `.vue` / `.svelte` imports. Component internals are not type-checked yet;
|
|
8
|
+
* importing one must not be an error;
|
|
9
|
+
* • packages whose types could not be found, declared as `any` — a CDN miss is
|
|
10
|
+
* not the user's type error.
|
|
11
|
+
*
|
|
12
|
+
* A pattern the project (or a fetched package) already declares is skipped: two
|
|
13
|
+
* declarations of `*.vue` with a default export each would be an error of ours.
|
|
14
|
+
*/
|
|
15
|
+
export const SHIM_DIR = '/__bfwc_shims__';
|
|
16
|
+
export const AMBIENT_SHIM_PATH = `${SHIM_DIR}/ambient.d.ts`;
|
|
17
|
+
/** What a shimmed type reference (`/// <reference types="vite/client" />`) resolves to. */
|
|
18
|
+
export const EMPTY_TYPES_PATH = `${SHIM_DIR}/empty.d.ts`;
|
|
19
|
+
export const SHIMMED_TYPE_REFERENCES = new Set(['vite/client', 'react-scripts']);
|
|
20
|
+
const STRING_DEFAULT = '{ const src: string; export default src; }';
|
|
21
|
+
const ANY_DEFAULT = '{ const value: any; export default value; }';
|
|
22
|
+
const MODULE_SHIMS = [
|
|
23
|
+
['*.module.css', '{ const classes: { readonly [key: string]: string }; export default classes; }'],
|
|
24
|
+
['*.module.scss', '{ const classes: { readonly [key: string]: string }; export default classes; }'],
|
|
25
|
+
['*.css', '{}'],
|
|
26
|
+
['*.scss', '{}'],
|
|
27
|
+
['*.sass', '{}'],
|
|
28
|
+
['*.less', '{}'],
|
|
29
|
+
...['svg', 'png', 'jpg', 'jpeg', 'gif', 'webp', 'avif', 'ico', 'bmp', 'woff', 'woff2', 'ttf', 'otf', 'eot', 'mp4', 'webm', 'mp3', 'wav', 'ogg', 'pdf', 'txt', 'md', 'wasm'].map((ext) => [`*.${ext}`, STRING_DEFAULT]),
|
|
30
|
+
['*?raw', STRING_DEFAULT],
|
|
31
|
+
['*?url', STRING_DEFAULT],
|
|
32
|
+
['*?inline', STRING_DEFAULT],
|
|
33
|
+
['*.vue', ANY_DEFAULT],
|
|
34
|
+
['*.svelte', ANY_DEFAULT],
|
|
35
|
+
];
|
|
36
|
+
const IMPORT_META = `interface ImportMetaEnv {
|
|
37
|
+
readonly [key: string]: any;
|
|
38
|
+
readonly MODE: string;
|
|
39
|
+
readonly BASE_URL: string;
|
|
40
|
+
readonly PROD: boolean;
|
|
41
|
+
readonly DEV: boolean;
|
|
42
|
+
readonly SSR: boolean;
|
|
43
|
+
}
|
|
44
|
+
interface ImportMeta {
|
|
45
|
+
readonly env: ImportMetaEnv;
|
|
46
|
+
readonly hot?: any;
|
|
47
|
+
readonly glob: any;
|
|
48
|
+
}`;
|
|
49
|
+
function escapeRegExp(text) {
|
|
50
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
51
|
+
}
|
|
52
|
+
/** True when any of `texts` declares `declare module '<pattern>'`. */
|
|
53
|
+
export function declaresModule(texts, pattern) {
|
|
54
|
+
const re = new RegExp(`declare\\s+module\\s+['"]${escapeRegExp(pattern)}['"]`);
|
|
55
|
+
for (const text of texts)
|
|
56
|
+
if (re.test(text))
|
|
57
|
+
return true;
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
export function ambientShim(options) {
|
|
61
|
+
const lines = [IMPORT_META];
|
|
62
|
+
// CRA reads `process.env.REACT_APP_*`; @types/node, when loaded, declares it properly.
|
|
63
|
+
if (!options.existing.some((text) => /declare\s+var\s+process\b/.test(text))) {
|
|
64
|
+
lines.push('declare var process: { env: { readonly [key: string]: string | undefined; readonly NODE_ENV: string } };');
|
|
65
|
+
}
|
|
66
|
+
for (const [pattern, body] of MODULE_SHIMS) {
|
|
67
|
+
if (!declaresModule(options.existing, pattern))
|
|
68
|
+
lines.push(`declare module ${JSON.stringify(pattern)} ${body}`);
|
|
69
|
+
}
|
|
70
|
+
for (const name of options.untyped) {
|
|
71
|
+
lines.push(`declare module ${JSON.stringify(name)};`);
|
|
72
|
+
lines.push(`declare module ${JSON.stringify(`${name}/*`)};`);
|
|
73
|
+
}
|
|
74
|
+
return lines.join('\n') + '\n';
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=shims.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shims.js","sourceRoot":"","sources":["../../src/check/shims.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,MAAM,CAAC,MAAM,QAAQ,GAAG,iBAAiB,CAAC;AAC1C,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,QAAQ,eAAe,CAAC;AAC5D,2FAA2F;AAC3F,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,QAAQ,aAAa,CAAC;AACzD,MAAM,CAAC,MAAM,uBAAuB,GAAwB,IAAI,GAAG,CAAC,CAAC,aAAa,EAAE,eAAe,CAAC,CA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C,CAAC;IAC/E,KAAK,MAAM,IAAI,IAAI,KAAK;QAAE,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;YAAE,OAAO,IAAI,CAAC;IACzD,OAAO,KAAK,CAAC;AACf,CAAC;AASD,MAAM,UAAU,WAAW,CAAC,OAA2B;IACrD,MAAM,KAAK,GAAG,CAAC,WAAW,CAAC,CAAC;IAC5B,uFAAuF;IACvF,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,2BAA2B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;QAC7E,KAAK,CAAC,IAAI,CAAC,0GAA0G,CAAC,CAAC;IACzH,CAAC;IACD,KAAK,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,YAAY,EAAE,CAAC;QAC3C,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC;YAAE,KAAK,CAAC,IAAI,CAAC,kBAAkB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;IAClH,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACnC,KAAK,CAAC,IAAI,CAAC,kBAAkB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACtD,KAAK,CAAC,IAAI,CAAC,kBAAkB,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/D,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type * as TS from 'typescript';
|
|
2
|
+
/**
|
|
3
|
+
* Where the checker's non-project files live, and the cache that holds them.
|
|
4
|
+
*
|
|
5
|
+
* A TypeScript program is synchronous, but type definitions come from the
|
|
6
|
+
* network. So checking is two phases: acquisition fetches everything the project
|
|
7
|
+
* can reach into a {@link TypeStore}; the program then reads only the store. The
|
|
8
|
+
* store outlives one check (a worker keeps it), so a second check of the same
|
|
9
|
+
* project makes no requests and reuses parsed lib files.
|
|
10
|
+
*
|
|
11
|
+
* Fetched files are addressed by URL and exposed to TypeScript under virtual
|
|
12
|
+
* paths; libs and `extends`-ed tsconfig packages likewise.
|
|
13
|
+
*/
|
|
14
|
+
export declare const TYPES_DIR = "/__bfwc_types__";
|
|
15
|
+
export declare const LIB_DIR = "/__bfwc_lib__";
|
|
16
|
+
/** tsconfig `extends: "@vue/tsconfig/..."` resolves through node_modules, so fetched configs live there. */
|
|
17
|
+
export declare const CONFIG_MODULES_DIR = "/node_modules";
|
|
18
|
+
export interface TypeSources {
|
|
19
|
+
/** An esm.sh-compatible CDN: answers `X-TypeScript-Types` for a package URL. */
|
|
20
|
+
typesOrigin: string;
|
|
21
|
+
/** Directory holding `lib.*.d.ts` for the TypeScript version in use. */
|
|
22
|
+
libBaseUrl: string;
|
|
23
|
+
/** Raw npm files (for tsconfig `extends` packages), jsDelivr's `/npm` layout. */
|
|
24
|
+
npmBaseUrl: string;
|
|
25
|
+
}
|
|
26
|
+
export declare const DEFAULT_TYPES_ORIGIN = "https://esm.sh";
|
|
27
|
+
export declare const DEFAULT_NPM_BASE_URL = "https://cdn.jsdelivr.net/npm";
|
|
28
|
+
export declare function libBaseUrlFor(typescriptVersion: string): string;
|
|
29
|
+
/** `@scope/name` → `@types/scope__name`, DefinitelyTyped's naming. */
|
|
30
|
+
export declare function typesPackageName(name: string): string;
|
|
31
|
+
/** `name@range` when the project declares a registry range for it, else `name`. */
|
|
32
|
+
export declare function versioned(name: string, dependencies: Readonly<Record<string, string>>): string;
|
|
33
|
+
/** The CDN module URL whose `X-TypeScript-Types` names a specifier's types. */
|
|
34
|
+
export declare function packageRequestUrl(origin: string, specifier: string, dependencies: Readonly<Record<string, string>>): string;
|
|
35
|
+
/** URLs to try, in order, for a relative or absolute reference inside a fetched `.d.ts`. */
|
|
36
|
+
export declare function dtsCandidates(specifier: string, fromUrl: string): string[];
|
|
37
|
+
export declare class TypeStore {
|
|
38
|
+
/** Final (post-redirect) URL → text. */
|
|
39
|
+
readonly files: Map<string, string>;
|
|
40
|
+
/** Requested URL → final URL; `''` records a failure so it is not retried. */
|
|
41
|
+
readonly redirects: Map<string, string>;
|
|
42
|
+
/** Package request URL (or `types:<name>`) → final types URL, or null when it has none. */
|
|
43
|
+
readonly packages: Map<string, string | null>;
|
|
44
|
+
/** `lib.dom.d.ts` → text, or null when missing. */
|
|
45
|
+
readonly libs: Map<string, string | null>;
|
|
46
|
+
/** `/node_modules/@vue/tsconfig/tsconfig.json` → text, or null when missing. */
|
|
47
|
+
readonly configs: Map<string, string | null>;
|
|
48
|
+
/** Parsed lib and package files, reused by every program built over this store. */
|
|
49
|
+
readonly sourceFiles: Map<string, TS.SourceFile>;
|
|
50
|
+
/** The final URL for a requested one, when it was fetched. */
|
|
51
|
+
finalUrl(url: string): string | undefined;
|
|
52
|
+
virtualPath(url: string): string;
|
|
53
|
+
urlOf(virtualPath: string): string | undefined;
|
|
54
|
+
/** Text for any virtual non-project path, or undefined. */
|
|
55
|
+
read(path: string): string | undefined;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=typeStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeStore.d.ts","sourceRoot":"","sources":["../../src/check/typeStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AAItC;;;;;;;;;;;GAWG;AAEH,eAAO,MAAM,SAAS,oBAAoB,CAAC;AAC3C,eAAO,MAAM,OAAO,kBAAkB,CAAC;AACvC,4GAA4G;AAC5G,eAAO,MAAM,kBAAkB,kBAAkB,CAAC;AAElD,MAAM,WAAW,WAAW;IAC1B,gFAAgF;IAChF,WAAW,EAAE,MAAM,CAAC;IACpB,wEAAwE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,GAAG,SAAS;IAO9C,2DAA2D;IAC3D,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;CAMvC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { isRegistryRange } from '../packageCdn.js';
|
|
2
|
+
import { splitPackageSpecifier } from '../resolve.js';
|
|
3
|
+
/**
|
|
4
|
+
* Where the checker's non-project files live, and the cache that holds them.
|
|
5
|
+
*
|
|
6
|
+
* A TypeScript program is synchronous, but type definitions come from the
|
|
7
|
+
* network. So checking is two phases: acquisition fetches everything the project
|
|
8
|
+
* can reach into a {@link TypeStore}; the program then reads only the store. The
|
|
9
|
+
* store outlives one check (a worker keeps it), so a second check of the same
|
|
10
|
+
* project makes no requests and reuses parsed lib files.
|
|
11
|
+
*
|
|
12
|
+
* Fetched files are addressed by URL and exposed to TypeScript under virtual
|
|
13
|
+
* paths; libs and `extends`-ed tsconfig packages likewise.
|
|
14
|
+
*/
|
|
15
|
+
export const TYPES_DIR = '/__bfwc_types__';
|
|
16
|
+
export const LIB_DIR = '/__bfwc_lib__';
|
|
17
|
+
/** tsconfig `extends: "@vue/tsconfig/..."` resolves through node_modules, so fetched configs live there. */
|
|
18
|
+
export const CONFIG_MODULES_DIR = '/node_modules';
|
|
19
|
+
export const DEFAULT_TYPES_ORIGIN = 'https://esm.sh';
|
|
20
|
+
export const DEFAULT_NPM_BASE_URL = 'https://cdn.jsdelivr.net/npm';
|
|
21
|
+
export function libBaseUrlFor(typescriptVersion) {
|
|
22
|
+
return `${DEFAULT_NPM_BASE_URL}/typescript@${typescriptVersion}/lib`;
|
|
23
|
+
}
|
|
24
|
+
/** `@scope/name` → `@types/scope__name`, DefinitelyTyped's naming. */
|
|
25
|
+
export function typesPackageName(name) {
|
|
26
|
+
return `@types/${name.startsWith('@') ? name.slice(1).replace('/', '__') : name}`;
|
|
27
|
+
}
|
|
28
|
+
/** `name@range` when the project declares a registry range for it, else `name`. */
|
|
29
|
+
export function versioned(name, dependencies) {
|
|
30
|
+
const range = dependencies[name];
|
|
31
|
+
return range && isRegistryRange(range) ? `${name}@${range}` : name;
|
|
32
|
+
}
|
|
33
|
+
/** The CDN module URL whose `X-TypeScript-Types` names a specifier's types. */
|
|
34
|
+
export function packageRequestUrl(origin, specifier, dependencies) {
|
|
35
|
+
const { name, subpath } = splitPackageSpecifier(specifier);
|
|
36
|
+
return `${origin}/${versioned(name, dependencies)}${subpath}`;
|
|
37
|
+
}
|
|
38
|
+
/** URLs to try, in order, for a relative or absolute reference inside a fetched `.d.ts`. */
|
|
39
|
+
export function dtsCandidates(specifier, fromUrl) {
|
|
40
|
+
const url = new URL(specifier, fromUrl).href.replace(/[?#].*$/, '');
|
|
41
|
+
if (/\.d\.[mc]?ts$/.test(url))
|
|
42
|
+
return [url];
|
|
43
|
+
if (/\.[mc]?js$/.test(url))
|
|
44
|
+
return [url.replace(/\.([mc]?)js$/, '.d.$1ts')];
|
|
45
|
+
if (/\.[mc]?ts$/.test(url))
|
|
46
|
+
return [url];
|
|
47
|
+
return [`${url}.d.ts`, `${url}/index.d.ts`];
|
|
48
|
+
}
|
|
49
|
+
export class TypeStore {
|
|
50
|
+
/** Final (post-redirect) URL → text. */
|
|
51
|
+
files = new Map();
|
|
52
|
+
/** Requested URL → final URL; `''` records a failure so it is not retried. */
|
|
53
|
+
redirects = new Map();
|
|
54
|
+
/** Package request URL (or `types:<name>`) → final types URL, or null when it has none. */
|
|
55
|
+
packages = new Map();
|
|
56
|
+
/** `lib.dom.d.ts` → text, or null when missing. */
|
|
57
|
+
libs = new Map();
|
|
58
|
+
/** `/node_modules/@vue/tsconfig/tsconfig.json` → text, or null when missing. */
|
|
59
|
+
configs = new Map();
|
|
60
|
+
/** Parsed lib and package files, reused by every program built over this store. */
|
|
61
|
+
sourceFiles = new Map();
|
|
62
|
+
/** The final URL for a requested one, when it was fetched. */
|
|
63
|
+
finalUrl(url) {
|
|
64
|
+
const final = this.redirects.get(url) ?? (this.files.has(url) ? url : undefined);
|
|
65
|
+
return final || undefined;
|
|
66
|
+
}
|
|
67
|
+
virtualPath(url) {
|
|
68
|
+
return `${TYPES_DIR}/${url.replace(/^[a-z]+:\/\//i, '')}`;
|
|
69
|
+
}
|
|
70
|
+
urlOf(virtualPath) {
|
|
71
|
+
if (!virtualPath.startsWith(`${TYPES_DIR}/`))
|
|
72
|
+
return undefined;
|
|
73
|
+
const rest = virtualPath.slice(TYPES_DIR.length + 1);
|
|
74
|
+
for (const scheme of ['https://', 'http://'])
|
|
75
|
+
if (this.files.has(scheme + rest))
|
|
76
|
+
return scheme + rest;
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
/** Text for any virtual non-project path, or undefined. */
|
|
80
|
+
read(path) {
|
|
81
|
+
if (path.startsWith(`${LIB_DIR}/`))
|
|
82
|
+
return this.libs.get(path.slice(LIB_DIR.length + 1)) ?? undefined;
|
|
83
|
+
if (path.startsWith(`${CONFIG_MODULES_DIR}/`))
|
|
84
|
+
return this.configs.get(path) ?? undefined;
|
|
85
|
+
const url = this.urlOf(path);
|
|
86
|
+
return url ? this.files.get(url) : undefined;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=typeStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeStore.js","sourceRoot":"","sources":["../../src/check/typeStore.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAEtD;;;;;;;;;;;GAWG;AAEH,MAAM,CAAC,MAAM,SAAS,GAAG,iBAAiB,CAAC;AAC3C,MAAM,CAAC,MAAM,OAAO,GAAG,eAAe,CAAC;AACvC,4GAA4G;AAC5G,MAAM,CAAC,MAAM,kBAAkB,GAAG,eAAe,CAAC;AAWlD,MAAM,CAAC,MAAM,oBAAoB,GAAG,gBAAgB,CAAC;AACrD,MAAM,CAAC,MAAM,oBAAo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ACrD,KAAK,MAAM,MAAM,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC;YAAE,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC;gBAAE,OAAO,MAAM,GAAG,IAAI,CAAC;QACtG,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,2DAA2D;IAC3D,IAAI,CAAC,IAAY;QACf,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,OAAO,GAAG,CAAC;YAAE,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC;QACtG,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,kBAAkB,GAAG,CAAC;YAAE,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC;QAC1F,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC7B,OAAO,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/C,CAAC;CACF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type * as TS from 'typescript';
|
|
2
|
+
import { VirtualFileSystem, type FileSystemTree, type FlatFiles } from '../vfs.js';
|
|
3
|
+
import { type FetchLike } from './acquire.js';
|
|
4
|
+
import { type CheckDiagnostic } from './diagnostics.js';
|
|
5
|
+
import { TypeStore, type TypeSources } from './typeStore.js';
|
|
6
|
+
/**
|
|
7
|
+
* `tsc --noEmit` over a project held in memory. Runtime-agnostic: the caller
|
|
8
|
+
* passes the TypeScript module (the npm package in Node, the CDN build in a
|
|
9
|
+
* worker) and a `fetch` for type definitions, so the same code is tested in Node
|
|
10
|
+
* and run in the browser.
|
|
11
|
+
*/
|
|
12
|
+
export interface TypecheckOptions {
|
|
13
|
+
fetch: FetchLike;
|
|
14
|
+
/** Where types, libs and tsconfig packages come from. Libs default to jsDelivr at `ts.version`. */
|
|
15
|
+
sources?: Partial<TypeSources>;
|
|
16
|
+
/** Reuse fetched and parsed declarations across checks (a long-lived worker keeps one). */
|
|
17
|
+
store?: TypeStore;
|
|
18
|
+
/** Cap on fetched declaration files. Default 2000. */
|
|
19
|
+
maxTypeFiles?: number;
|
|
20
|
+
}
|
|
21
|
+
export interface TypecheckResult {
|
|
22
|
+
diagnostics: CheckDiagnostic[];
|
|
23
|
+
/** Imported packages with no types on the CDN — checked as `any` rather than reported. */
|
|
24
|
+
untypedPackages: string[];
|
|
25
|
+
/** Project files that were checked, project-relative. */
|
|
26
|
+
files: string[];
|
|
27
|
+
}
|
|
28
|
+
export declare function typecheckProject(ts: typeof TS, files: VirtualFileSystem | FlatFiles | FileSystemTree, options: TypecheckOptions): Promise<TypecheckResult>;
|
|
29
|
+
//# sourceMappingURL=typecheck.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typecheck.d.ts","sourceRoot":"","sources":["../../src/check/typecheck.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAGnF,OAAO,EAAwC,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAEpF,OAAO,EAAsC,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAG5F,OAAO,EAKL,SAAS,EACT,KAAK,WAAW,EACjB,MAAM,gBAAgB,CAAC;AAExB;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,SAAS,CAAC;IACjB,mGAAmG;IACnG,OAAO,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;IAC/B,2FAA2F;IAC3F,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,sDAAsD;IACtD,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,eAAe,EAAE,CAAC;IAC/B,0FAA0F;IAC1F,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,yDAAyD;IACzD,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAsCD,wBAAsB,gBAAgB,CACpC,EAAE,EAAE,OAAO,EAAE,EACb,KAAK,EAAE,iBAAiB,GAAG,SAAS,GAAG,cAAc,EACrD,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,eAAe,CAAC,CAmD1B"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { VirtualFileSystem } from '../vfs.js';
|
|
2
|
+
import { readProjectConfig } from '../projectConfig.js';
|
|
3
|
+
import { isBareSpecifier, resolveAlias, splitPackageSpecifier } from '../resolve.js';
|
|
4
|
+
import { acquireExtendedConfigs, acquireTypes } from './acquire.js';
|
|
5
|
+
import { createVirtualHost } from './compilerHost.js';
|
|
6
|
+
import { sortDiagnostics, toCheckDiagnostic } from './diagnostics.js';
|
|
7
|
+
import { resolveCheckProjects } from './projects.js';
|
|
8
|
+
import { AMBIENT_SHIM_PATH, ambientShim } from './shims.js';
|
|
9
|
+
import { DEFAULT_NPM_BASE_URL, DEFAULT_TYPES_ORIGIN, libBaseUrlFor, packageRequestUrl, TypeStore, } from './typeStore.js';
|
|
10
|
+
function toFileSystem(files) {
|
|
11
|
+
if (files instanceof VirtualFileSystem)
|
|
12
|
+
return files;
|
|
13
|
+
const fs = new VirtualFileSystem();
|
|
14
|
+
fs.mount(files);
|
|
15
|
+
return fs;
|
|
16
|
+
}
|
|
17
|
+
/** Everything a set of programs can reach outside the project: packages, type references, libs. */
|
|
18
|
+
function collectReach(ts, fs, projects, isAliased) {
|
|
19
|
+
const reach = { specifiers: new Set(), typeReferences: new Set(), libFiles: new Set() };
|
|
20
|
+
for (const project of projects) {
|
|
21
|
+
const { options } = project;
|
|
22
|
+
for (const path of project.rootNames) {
|
|
23
|
+
const info = ts.preProcessFile(fs.readText(path) ?? '', true, true);
|
|
24
|
+
for (const ref of info.importedFiles) {
|
|
25
|
+
if (isBareSpecifier(ref.fileName) && !ref.fileName.includes('?') && !isAliased(ref.fileName))
|
|
26
|
+
reach.specifiers.add(ref.fileName);
|
|
27
|
+
}
|
|
28
|
+
for (const ref of info.typeReferenceDirectives)
|
|
29
|
+
reach.typeReferences.add(ref.fileName);
|
|
30
|
+
for (const ref of info.libReferenceDirectives)
|
|
31
|
+
reach.libFiles.add(`lib.${ref.fileName.toLowerCase()}.d.ts`);
|
|
32
|
+
}
|
|
33
|
+
for (const name of options.types ?? [])
|
|
34
|
+
reach.typeReferences.add(name);
|
|
35
|
+
if (options.jsx === ts.JsxEmit.ReactJSX || options.jsx === ts.JsxEmit.ReactJSXDev) {
|
|
36
|
+
const runtime = options.jsx === ts.JsxEmit.ReactJSXDev ? 'jsx-dev-runtime' : 'jsx-runtime';
|
|
37
|
+
reach.specifiers.add(`${options.jsxImportSource ?? 'react'}/${runtime}`);
|
|
38
|
+
}
|
|
39
|
+
if (!options.noLib)
|
|
40
|
+
for (const lib of options.lib ?? [ts.getDefaultLibFileName(options)])
|
|
41
|
+
reach.libFiles.add(lib);
|
|
42
|
+
}
|
|
43
|
+
return reach;
|
|
44
|
+
}
|
|
45
|
+
export async function typecheckProject(ts, files, options) {
|
|
46
|
+
const fs = toFileSystem(files);
|
|
47
|
+
const store = options.store ?? new TypeStore();
|
|
48
|
+
const sources = {
|
|
49
|
+
typesOrigin: DEFAULT_TYPES_ORIGIN,
|
|
50
|
+
npmBaseUrl: DEFAULT_NPM_BASE_URL,
|
|
51
|
+
libBaseUrl: libBaseUrlFor(ts.version),
|
|
52
|
+
...options.sources,
|
|
53
|
+
};
|
|
54
|
+
const config = readProjectConfig(fs);
|
|
55
|
+
const { dependencies } = config;
|
|
56
|
+
await acquireExtendedConfigs(fs, store, dependencies, { fetch: options.fetch, sources });
|
|
57
|
+
const projects = resolveCheckProjects(ts, fs, store, config.jsx.importSource === 'react' ? undefined : config.jsx.importSource);
|
|
58
|
+
const reach = collectReach(ts, fs, projects, (spec) => resolveAlias(fs, config.aliases, spec) !== undefined);
|
|
59
|
+
await acquireTypes(ts, store, { specifiers: [...reach.specifiers], typeReferences: [...reach.typeReferences], libFiles: [...reach.libFiles], dependencies }, { fetch: options.fetch, sources, maxFiles: options.maxTypeFiles ?? 2000 });
|
|
60
|
+
const untypedPackages = [
|
|
61
|
+
...new Set([...reach.specifiers]
|
|
62
|
+
.filter((spec) => !store.packages.get(packageRequestUrl(sources.typesOrigin, spec, dependencies)))
|
|
63
|
+
.map((spec) => splitPackageSpecifier(spec).name)),
|
|
64
|
+
].sort();
|
|
65
|
+
const projectDeclarations = fs.list().filter((path) => path.endsWith('.d.ts')).map((path) => fs.readText(path) ?? '');
|
|
66
|
+
const shim = ambientShim({ existing: [...projectDeclarations, ...store.files.values()], untyped: untypedPackages });
|
|
67
|
+
const diagnostics = [];
|
|
68
|
+
const checked = new Set();
|
|
69
|
+
for (const project of projects) {
|
|
70
|
+
for (const error of project.errors)
|
|
71
|
+
diagnostics.push(toCheckDiagnostic(ts, error));
|
|
72
|
+
if (!project.rootNames.length)
|
|
73
|
+
continue;
|
|
74
|
+
const host = createVirtualHost(ts, { fs, store, typesOrigin: sources.typesOrigin, dependencies, aliases: config.aliases, shim });
|
|
75
|
+
const program = ts.createProgram({ rootNames: [...project.rootNames, AMBIENT_SHIM_PATH], options: project.options, host });
|
|
76
|
+
const found = [...program.getOptionsDiagnostics(), ...program.getGlobalDiagnostics()];
|
|
77
|
+
for (const file of program.getSourceFiles()) {
|
|
78
|
+
if (!fs.isFile(file.fileName))
|
|
79
|
+
continue; // libs, package types, shims
|
|
80
|
+
checked.add(file.fileName.slice(1));
|
|
81
|
+
found.push(...program.getSyntacticDiagnostics(file), ...program.getSemanticDiagnostics(file));
|
|
82
|
+
}
|
|
83
|
+
for (const diagnostic of found) {
|
|
84
|
+
if (diagnostic.file && !fs.isFile(diagnostic.file.fileName))
|
|
85
|
+
continue;
|
|
86
|
+
diagnostics.push(toCheckDiagnostic(ts, diagnostic));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return { diagnostics: sortDiagnostics(diagnostics), untypedPackages, files: [...checked].sort() };
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=typecheck.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typecheck.js","sourceRoot":"","sources":["../../src/check/typecheck.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAuC,MAAM,WAAW,CAAC;AACnF,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACrF,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAkB,MAAM,cAAc,CAAC;AACpF,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAwB,MAAM,kBAAkB,CAAC;AAC5F,OAAO,EAAE,oBAAoB,EAAqB,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,aAAa,EACb,iBAAiB,EACjB,SAAS,GAEV,MAAM,gBAAgB,CAAC;AAgCxB,SAAS,YAAY,CAAC,KAAqD;IACzE,IAAI,KAAK,YAAY,iBAAiB;QAAE,OAAO,KAAK,CAAC;IACrD,MAAM,EAAE,GAAG,IAAI,iBAAiB,EAAE,CAAC;IACnC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAChB,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,mGAAmG;AACnG,SAAS,YAAY,CAAC,EAAa,EAAE,EAAqB,E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,QAAQ,CAAC;gBAAE,SAAS,CAAC,6BAA6B;YACtE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YACpC,KAAK,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,uBAAuB,CAAC,IAAI,CAAC,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC,CAAC;QAChG,CAAC;QACD,KAAK,MAAM,UAAU,IAAI,KAAK,EAAE,CAAC;YAC/B,IAAI,UAAU,CAAC,IAAI,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC;gBAAE,SAAS;YACtE,WAAW,CAAC,IAAI,CAAC,iBAAiB,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;IACD,OAAO,EAAE,WAAW,EAAE,eAAe,CAAC,WAAW,CAAC,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;AACpG,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CompileContext } from './compileScript.js';
|
|
2
|
+
/**
|
|
3
|
+
* A `.vue` / `.svelte` file → one ES module for the dev server: the compiled
|
|
4
|
+
* component, its imports mapped like any script's, and its scoped CSS injected
|
|
5
|
+
* as a <style> tag keyed by the component's path (an edit replaces it in place).
|
|
6
|
+
*/
|
|
7
|
+
export declare function compileComponent(ctx: CompileContext, path: string): Promise<string>;
|
|
8
|
+
//# sourceMappingURL=compileComponent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compileComponent.d.ts","sourceRoot":"","sources":["../src/compileComponent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAMzD;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CASzF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { compileModule } from './compileScript.js';
|
|
2
|
+
import { componentExtension } from './components.js';
|
|
3
|
+
import { extname } from './paths.js';
|
|
4
|
+
import { injectStyleStatement, rewriteCssUrls } from './styleModules.js';
|
|
5
|
+
/**
|
|
6
|
+
* A `.vue` / `.svelte` file → one ES module for the dev server: the compiled
|
|
7
|
+
* component, its imports mapped like any script's, and its scoped CSS injected
|
|
8
|
+
* as a <style> tag keyed by the component's path (an edit replaces it in place).
|
|
9
|
+
*/
|
|
10
|
+
export async function compileComponent(ctx, path) {
|
|
11
|
+
const extension = componentExtension(extname(path));
|
|
12
|
+
if (!extension)
|
|
13
|
+
throw new Error(`Not a component: ${path}`);
|
|
14
|
+
const compiler = await ctx.components(extension, ctx.config.dependencies);
|
|
15
|
+
const compiled = await compiler.compile(ctx.fs.readText(path) ?? '', { path, dev: true });
|
|
16
|
+
const js = await compileModule(ctx, path, compiled.code, compiled.loader);
|
|
17
|
+
if (!compiled.css)
|
|
18
|
+
return js;
|
|
19
|
+
const css = rewriteCssUrls(ctx.fs, path, compiled.css, ctx.base);
|
|
20
|
+
return `${js}\n${injectStyleStatement(path, JSON.stringify(css))}\n`;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=compileComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compileComponent.js","sourceRoot":"","sources":["../src/compileComponent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEzE;;;;GAIG;AACH,MAAM,CA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