Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deprecate defaults prop #393

Merged
merged 1 commit into from
Aug 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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