Skip to content

Commit 397a83a

Browse files
committed
refactor: 💡 remove deprecated autoProcess props
BREAKING CHANGE: 🧨 `onBefore` and `transformers` were removed
1 parent 69ccd6d commit 397a83a

File tree

2 files changed

+2
-58
lines changed

2 files changed

+2
-58
lines changed

‎src/autoProcess.ts

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -29,30 +29,10 @@ interface Transformers {
2929
[languageName: string]: TransformerOptions;
3030
}
3131

32-
type AutoPreprocessOptions = {
33-
/** @deprecated for svelte v3 use instead a array of processors */
34-
onBefore?: ({
35-
content,
36-
filename,
37-
}: {
38-
content: string;
39-
filename: string;
40-
}) => Promise<string> | string;
32+
type AutoPreprocessOptions = Transformers & {
4133
markupTagName?: string;
42-
/** @deprecated add transformer config directly to svelte-preprocess options object */
43-
transformers?: Transformers;
4434
aliases?: Array<[string, string]>;
4535
preserve?: string[];
46-
typescript?: TransformerOptions<Options.Typescript>;
47-
scss?: TransformerOptions<Options.Sass>;
48-
sass?: TransformerOptions<Options.Sass>;
49-
less?: TransformerOptions<Options.Less>;
50-
stylus?: TransformerOptions<Options.Stylus>;
51-
postcss?: TransformerOptions<Options.Postcss>;
52-
babel?: TransformerOptions<Options.Babel>;
53-
coffeescript?: TransformerOptions<Options.Coffeescript>;
54-
pug?: TransformerOptions<Options.Pug>;
55-
globalStyle?: Options.GlobalStyle;
5636
// workaround while we don't have this
5737
// https://github.com/microsoft/TypeScript/issues/17867
5838
[languageName: string]:
@@ -63,7 +43,6 @@ type AutoPreprocessOptions = {
6343
| TransformerOptions;
6444
};
6545

66-
const SVELTE_MAJOR_VERSION = +version[0];
6746
const ALIAS_OPTION_OVERRIDES: Record<string, any> = {
6847
sass: {
6948
indentedSyntax: true,
@@ -72,7 +51,6 @@ const ALIAS_OPTION_OVERRIDES: Record<string, any> = {
7251

7352
export function autoPreprocess(
7453
{
75-
onBefore,
7654
aliases,
7755
markupTagName = 'template',
7856
preserve = [],
@@ -82,7 +60,7 @@ export function autoPreprocess(
8260
markupTagName = markupTagName.toLocaleLowerCase();
8361

8462
const optionsCache: Record<string, any> = {};
85-
const transformers = rest.transformers || (rest as Transformers);
63+
const transformers = rest as Transformers;
8664
const markupPattern = new RegExp(
8765
`<${markupTagName}([\\s\\S]*?)(?:>([\\s\\S]*)<\\/${markupTagName}>|/>)`,
8866
);
@@ -158,16 +136,6 @@ export function autoPreprocess(
158136

159137
return {
160138
async markup({ content, filename }) {
161-
if (typeof onBefore === 'function') {
162-
// istanbul ignore next
163-
if (SVELTE_MAJOR_VERSION >= 3) {
164-
console.warn(
165-
'[svelte-preprocess] For svelte >= v3, instead of onBefore(), prefer to prepend a preprocess object to your array of preprocessors',
166-
);
167-
}
168-
content = await onBefore({ content, filename });
169-
}
170-
171139
if (transformers.replace) {
172140
const transformed = await runTransformer(
173141
'replace',

‎test/autoProcess/autoProcess.test.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,6 @@ describe('options', () => {
6464
expect(preprocessed.toString()).toMatch(CSS_PATTERN);
6565
});
6666

67-
it('should execute a onBefore method before transforming markup', async () => {
68-
const input = `UPPERCASE?`;
69-
const opts = getAutoPreprocess({
70-
async onBefore({ content }) {
71-
return content.toLowerCase();
72-
},
73-
});
74-
const preprocessed = await preprocess(input, opts);
75-
76-
expect(preprocessed.toString()).toBe(input.toLowerCase());
77-
});
78-
7967
it('should append aliases to the language alias dictionary', async () => {
8068
const input = `<script lang="cl"></script>`;
8169
const opts = getAutoPreprocess({
@@ -146,16 +134,4 @@ describe('options', () => {
146134

147135
expect(await doesCompileThrow(input, opts)).toBe(true);
148136
});
149-
150-
it('should support the old `transformers` option', async () => {
151-
const input = `<script lang="mock"></script>`;
152-
const opts = getAutoPreprocess({
153-
transformers: {
154-
mock: () => ({ code: 'mock' }),
155-
},
156-
});
157-
const preprocessed = await preprocess(input, opts);
158-
159-
expect(preprocessed.toString()).toBe(`<script lang="mock">mock</script>`);
160-
});
161137
});

0 commit comments

Comments
 (0)