From db42b0b185a7ed3606ad3dbff6cd9b45b3feb6aa Mon Sep 17 00:00:00 2001 From: Christian Kaisermann Date: Mon, 23 Aug 2021 09:40:07 -0300 Subject: [PATCH] fix: add deprecation warning to defaults prop --- docs/preprocessing.md | 1 - src/autoProcess.ts | 7 +++++++ src/types/index.ts | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/preprocessing.md b/docs/preprocessing.md index fb92333d..5ea48dae 100644 --- a/docs/preprocessing.md +++ b/docs/preprocessing.md @@ -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.

i.e `markup` makes it possible to write your markup between `` tag. | | `aliases` | `null` | A list of tuples `[alias: string, language: string]` that correlates an `alias` to a `language`

i.e `['cst', 'customLanguage']` means
`<... src="./file.cst">`
`<... lang="cst">`
`<... type="text/customLanguage">`
`<... type="application/customLanguage">`
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.

i.e: `{ script: 'typescript' }` makes TypeScript the default language, removing the need of adding `lang="ts"` to `script` tags.

**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 diff --git a/src/autoProcess.ts b/src/autoProcess.ts index 44b6efec..fb6fa960 100644 --- a/src/autoProcess.ts +++ b/src/autoProcess.ts @@ -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) { diff --git a/src/types/index.ts b/src/types/index.ts index dfaf53ec..58f21392 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -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;