-
Notifications
You must be signed in to change notification settings - Fork 150
/
Copy pathcoffeescript.ts
44 lines (36 loc) · 1.28 KB
/
coffeescript.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { getTagInfo, removeSrcAttribute } from '../modules/tagInfo';
import { concat } from '../modules/utils';
import { prepareContent } from '../modules/prepareContent';
import type { PreprocessorGroup, Options } from '../types';
const coffeescript = (options?: Options.Coffeescript): PreprocessorGroup => ({
async script(svelteFile) {
const { transformer } = await import('../transformers/coffeescript');
let { content, filename, attributes, lang, dependencies } =
await getTagInfo(svelteFile);
if (lang !== 'coffeescript') {
return { code: content };
}
content = prepareContent({
options: {
...options,
stripIndent: true,
},
content,
});
const transformed = await transformer({
content,
filename,
attributes,
options,
});
return {
...transformed,
attributes: removeSrcAttribute(transformed.attributes || attributes),
dependencies: concat(dependencies, transformed.dependencies),
};
},
});
// both for backwards compat with old svelte-preprocess versions
// (was only default export once, now is named export because of transpilation causing node not to detect the named exports of 'svelte-preprocess' otherwise)
export default coffeescript;
export { coffeescript };