Skip to content

Commit f268597

Browse files
committed
fix: add deprecation warning to defaults prop
1 parent 988c047 commit f268597

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

docs/preprocessing.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ The following options can be passed to the preprocessor. None are required:
7272
| `markupTagName` | `"template"` | `string` that sets the name of the tag `svelte-preprocess` looks for markup in custom languages.<br><br>i.e `markup` makes it possible to write your markup between `<markup lang="..."></markup>` tag. |
7373
| `aliases` | `null` | A list of tuples `[alias: string, language: string]` that correlates an `alias` to a `language`<br><br>i.e `['cst', 'customLanguage']` means<br>`<... src="./file.cst">`<br>`<... lang="cst">`<br>`<... type="text/customLanguage">`<br>`<... type="application/customLanguage">`<br>are treated as `customLanguage`. |
7474
| preserve | `[]` | A `string` list of languages/aliases that shouldn't pass through the preprocessor. (i.e `ld+json`) |
75-
| `defaults` | `{ markup: 'html', script: 'javascript', style: 'css' }` | An `object` that defines the default languages of your components.<br><br>i.e: `{ script: 'typescript' }` makes TypeScript the default language, removing the need of adding `lang="ts"` to `script` tags.<br><br>**Note: It is generally not recommended to use this setting because not all tooling is able to deal with it, resulting in for example broken syntax highlighting for SCSS.** |
7675
| `sourceMap` | `false` | If `true`, `svelte-preprocess` generates sourcemap for every language that supports it. |
7776

7877
##### Configuring preprocessors

src/autoProcess.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@ export function sveltePreprocess(
6363
...defaults,
6464
});
6565

66+
// todo: remove this on v5
67+
if (defaults != null) {
68+
console.warn(
69+
'[svelte-preprocess] Deprecation notice: using the "defaults" option is no longer recommended and will be removed in the next major version. Instead, define the language being used explicitly via the lang attribute.\n\nSee https://github.com/sveltejs/svelte-preprocess/issues/362',
70+
);
71+
}
72+
6673
const transformers = rest as Transformers;
6774

6875
if (aliases?.length) {

src/types/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export type AutoPreprocessOptions = {
6464
markupTagName?: string;
6565
aliases?: Array<[string, string]>;
6666
preserve?: string[];
67+
/** @deprecated Dont use this anymore, define the language being used explicitly instead */
6768
defaults?: {
6869
markup?: string;
6970
style?: string;

0 commit comments

Comments
 (0)