Skip to content

Commit 1ca4525

Browse files
authored
[feat] Add errorMode option to compile to allow continuing on errors (and mark them as warnings) (#6194)
This PR adds a new option errorMode to CompileOptions to allow continuing the compilation process when errors occured. When set to warn, this new option will indicate to Svelte that it should log errors as warnings and continue compilation. This allows (notably) preprocessors to compile the markup to detect vars in markup before preprocessing (in this case: script and style tags are stripped so it can produce a lot of errors). This PR is part of a work on the svelte-preprocess side to improve the preprocessing of TypeScript files: sveltejs/svelte-preprocess#318 - allow compiler to pass error as warnings - enforce stops after errors during compilation (for type-checking, TS doesn't know the error method throws) - should review Element.ts:302 - added a test case for errorMode - added documentation
1 parent f1dbbe4 commit 1ca4525

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

docs/04-compile-time.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ The following options can be passed to the compiler. None are required:
4545
| `name` | string | `"Component"`
4646
| `format` | `"esm"` or `"cjs"` | `"esm"`
4747
| `generate` | `"dom"` or `"ssr"` or `false` | `"dom"`
48+
| `errorMode` | `"throw"` or `"warn"` | `"throw"`
4849
| `varsReport` | `"strict"` or `"full"` or `false` | `"strict"`
4950
| `dev` | boolean | `false`
5051
| `immutable` | boolean | `false`
@@ -67,6 +68,7 @@ The following options can be passed to the compiler. None are required:
6768
| `name` | `"Component"` | `string` that sets the name of the resulting JavaScript class (though the compiler will rename it if it would otherwise conflict with other variables in scope). It will normally be inferred from `filename`.
6869
| `format` | `"esm"` | If `"esm"`, creates a JavaScript module (with `import` and `export`). If `"cjs"`, creates a CommonJS module (with `require` and `module.exports`), which is useful in some server-side rendering situations or for testing.
6970
| `generate` | `"dom"` | If `"dom"`, Svelte emits a JavaScript class for mounting to the DOM. If `"ssr"`, Svelte emits an object with a `render` method suitable for server-side rendering. If `false`, no JavaScript or CSS is returned; just metadata.
71+
| `errorMode` | `"throw"` | If `"throw"`, Svelte throws when a compilation error occured. If `"warn"`, Svelte will treat errors as warnings and add them to the warning report.
7072
| `varsReport` | `"strict"` | If `"strict"`, Svelte returns a variables report with only variables that are not globals nor internals. If `"full"`, Svelte returns a variables report with all detected variables. If `false`, no variables report is returned.
7173
| `dev` | `false` | If `true`, causes extra code to be added to components that will perform runtime checks and provide debugging information during development.
7274
| `immutable` | `false` | If `true`, tells the compiler that you promise not to mutate any objects. This allows it to be less conservative about checking whether values have changed.

0 commit comments

Comments
 (0)