From 851a935a5487efe4e0522ca7c2461f55ad52d246 Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Sun, 17 Dec 2023 07:48:46 -0800 Subject: [PATCH 1/3] breaking: remove preserve option --- src/autoProcess.ts | 5 ----- src/types/index.ts | 1 - test/autoProcess/autoProcess.test.ts | 12 +++--------- 3 files changed, 3 insertions(+), 15 deletions(-) diff --git a/src/autoProcess.ts b/src/autoProcess.ts index 4db85095..09da5146 100644 --- a/src/autoProcess.ts +++ b/src/autoProcess.ts @@ -58,7 +58,6 @@ export function sveltePreprocess( { aliases, markupTagName = 'template', - preserve = [], sourceMap = process?.env?.NODE_ENV === 'development' ?? false, ...rest } = {} as AutoPreprocessOptions, @@ -128,10 +127,6 @@ export function sveltePreprocess( lang = getLanguageFromAlias(alias); } - if ((lang && preserve.includes(lang)) || preserve.includes(alias)) { - return { code: content }; - } - const transformerOptions = getTransformerOptions(lang, alias); content = prepareContent({ diff --git a/src/types/index.ts b/src/types/index.ts index f7a0effa..5fd36ce8 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -68,7 +68,6 @@ export type AutoPreprocessGroup = PreprocessorGroup; export type AutoPreprocessOptions = { markupTagName?: string; aliases?: Array<[string, string]>; - preserve?: string[]; sourceMap?: boolean; // transformers diff --git a/test/autoProcess/autoProcess.test.ts b/test/autoProcess/autoProcess.test.ts index c13afc9a..b2f6cb13 100644 --- a/test/autoProcess/autoProcess.test.ts +++ b/test/autoProcess/autoProcess.test.ts @@ -107,19 +107,13 @@ describe('options', () => { }); it('should NOT preprocess preserved languages', async () => { - const input = `
`; - const opts = sveltePreprocess({ - preserve: ['ld+json'], - aliases: [['ld+json', 'structuredData']], - structuredData() { - return { code: '', map: '' }; - }, - }); + const input = `
`; + const opts = sveltePreprocess(); const preprocessed = await preprocess(input, opts); expect(preprocessed.toString?.()).toContain( - ``, + ``, ); }); From f617675ccd768bca1f7367b551e6491b4e00b623 Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Sun, 17 Dec 2023 08:15:24 -0800 Subject: [PATCH 2/3] update docs --- docs/preprocessing.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/preprocessing.md b/docs/preprocessing.md index c49d0401..8f7394b9 100644 --- a/docs/preprocessing.md +++ b/docs/preprocessing.md @@ -71,7 +71,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">`
are treated as `customLanguage`. | -| `preserve` | `[]` | A `string` list of languages/aliases that shouldn't pass through the preprocessor. (i.e `ld+json`) | | `sourceMap` | `false` | If `true`, `svelte-preprocess` generates sourcemap for every language that supports it. | ##### Configuring preprocessors From 74072dbf35cae13100efbc5c4faf209e4065ca6e Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Sun, 17 Dec 2023 08:17:38 -0800 Subject: [PATCH 3/3] update test name --- test/autoProcess/autoProcess.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/autoProcess/autoProcess.test.ts b/test/autoProcess/autoProcess.test.ts index b2f6cb13..a43c4cf8 100644 --- a/test/autoProcess/autoProcess.test.ts +++ b/test/autoProcess/autoProcess.test.ts @@ -106,7 +106,7 @@ describe('options', () => { expect(preprocessed.toString?.()).toContain('div{}'); }); - it('should NOT preprocess preserved languages', async () => { + it('should NOT preprocess unrecognized languages', async () => { const input = `
`; const opts = sveltePreprocess();