Skip to content

Commit

Permalink
fix: add deprecation warning to defaults prop (#393)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaisermann authored Aug 23, 2021
1 parent 988c047 commit 406d3a8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 0 additions & 1 deletion docs/preprocessing.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ The following options can be passed to the preprocessor. None are required:
| `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. |
| `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`. |
| preserve | `[]` | A `string` list of languages/aliases that shouldn't pass through the preprocessor. (i.e `ld+json`) |
| `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.** |
| `sourceMap` | `false` | If `true`, `svelte-preprocess` generates sourcemap for every language that supports it. |

##### Configuring preprocessors
Expand Down
7 changes: 7 additions & 0 deletions src/autoProcess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ export function sveltePreprocess(
...defaults,
});

// todo: remove this on v5
if (defaults != null) {
console.warn(
'[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',
);
}

const transformers = rest as Transformers;

if (aliases?.length) {
Expand Down
1 change: 1 addition & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export type AutoPreprocessOptions = {
markupTagName?: string;
aliases?: Array<[string, string]>;
preserve?: string[];
/** @deprecated Don't use "defaults" anymore, define the language being used explicitly instead */
defaults?: {
markup?: string;
style?: string;
Expand Down

0 comments on commit 406d3a8

Please sign in to comment.