UNPKG

svelte-preprocess

Version:

A Svelte preprocessor wrapper with baked-in support for commonly used preprocessors

32 lines (31 loc) 1.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.typescript = void 0; const tagInfo_1 = require("../modules/tagInfo"); const utils_1 = require("../modules/utils"); const prepareContent_1 = require("../modules/prepareContent"); const typescript = (options) => ({ async script(svelteFile) { const { transformer } = await import('../transformers/typescript.js'); let { content, markup, filename, attributes, lang, dependencies } = await (0, tagInfo_1.getTagInfo)(svelteFile); if (lang !== 'typescript') { return { code: content }; } content = (0, prepareContent_1.prepareContent)({ options, content }); const transformed = await transformer({ content, markup, filename, attributes, options, }); return { ...transformed, dependencies: (0, utils_1.concat)(dependencies, transformed.dependencies), }; }, }); exports.typescript = typescript; // 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) exports.default = typescript;