Skip to content

Commit e46b53e

Browse files
authored
breaking: remove preserve option (#622)
closes #305 closes #312 Turns out the preserve option doesn't actually do anything useful anymore because it's now looking at lang and not type as it was originally. The original issues are already fixed without specifying preserve at all.
1 parent c435ebd commit e46b53e

File tree

4 files changed

+4
-17
lines changed

4 files changed

+4
-17
lines changed

docs/preprocessing.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ The following options can be passed to the preprocessor. None are required:
7171
| --------------- | ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
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>are treated as `customLanguage`. |
74-
| `preserve` | `[]` | A `string` list of languages/aliases that shouldn't pass through the preprocessor. (i.e `ld+json`) |
7574
| `sourceMap` | `false` | If `true`, `svelte-preprocess` generates sourcemap for every language that supports it. |
7675

7776
##### Configuring preprocessors

src/autoProcess.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ export function sveltePreprocess(
5858
{
5959
aliases,
6060
markupTagName = 'template',
61-
preserve = [],
6261
sourceMap = process?.env?.NODE_ENV === 'development' ?? false,
6362
...rest
6463
} = {} as AutoPreprocessOptions,
@@ -128,10 +127,6 @@ export function sveltePreprocess(
128127
lang = getLanguageFromAlias(alias);
129128
}
130129

131-
if ((lang && preserve.includes(lang)) || preserve.includes(alias)) {
132-
return { code: content };
133-
}
134-
135130
const transformerOptions = getTransformerOptions(lang, alias);
136131

137132
content = prepareContent({

src/types/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ export type AutoPreprocessGroup = PreprocessorGroup;
6868
export type AutoPreprocessOptions = {
6969
markupTagName?: string;
7070
aliases?: Array<[string, string]>;
71-
preserve?: string[];
7271
sourceMap?: boolean;
7372

7473
// transformers

test/autoProcess/autoProcess.test.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,20 +107,14 @@ describe('options', () => {
107107
expect(preprocessed.toString?.()).toContain('div{}');
108108
});
109109

110-
it('should NOT preprocess preserved languages', async () => {
111-
const input = `<div></div><script lang="ld+json">{"json":true}</script>`;
112-
const opts = sveltePreprocess({
113-
preserve: ['ld+json'],
114-
aliases: [['ld+json', 'structuredData']],
115-
structuredData() {
116-
return { code: '', map: '' };
117-
},
118-
});
110+
it('should NOT preprocess unrecognized languages', async () => {
111+
const input = `<div></div><script type="ld+json">{"json":true}</script>`;
112+
const opts = sveltePreprocess();
119113

120114
const preprocessed = await preprocess(input, opts);
121115

122116
expect(preprocessed.toString?.()).toContain(
123-
`<script lang="ld+json">{"json":true}</script>`,
117+
`<script type="ld+json">{"json":true}</script>`,
124118
);
125119
});
126120

0 commit comments

Comments
 (0)