svelte-preprocess
Advanced tools
Comparing version 4.10.0 to 4.10.1
@@ -0,1 +1,11 @@ | ||
## [4.10.1](https://github.com/sveltejs/svelte-preprocess/compare/v4.10.0...v4.10.1) (2021-12-17) | ||
### Bug Fixes | ||
* adjust store regex ([#441](https://github.com/sveltejs/svelte-preprocess/issues/441)) ([85a86c8](https://github.com/sveltejs/svelte-preprocess/commit/85a86c86513f98c2b02f2d314a18b0e68378c8f6)), closes [#433](https://github.com/sveltejs/svelte-preprocess/issues/433) | ||
* generate high resolution source map ([#443](https://github.com/sveltejs/svelte-preprocess/issues/443)) ([57012ba](https://github.com/sveltejs/svelte-preprocess/commit/57012ba9f87abfec99f061196fb955da4ccfa384)) | ||
# [4.10.0](https://github.com/sveltejs/svelte-preprocess/compare/v4.9.8...v4.10.0) (2021-12-13) | ||
@@ -2,0 +12,0 @@ |
@@ -96,3 +96,3 @@ "use strict"; | ||
const getTransformerTo = (type, targetLanguage) => async (svelteFile) => { | ||
let { content, markup, filename, lang, alias, dependencies, attributes, } = await (0, tagInfo_1.getTagInfo)(svelteFile); | ||
let { content, markup, filename, lang, alias, dependencies, attributes } = await (0, tagInfo_1.getTagInfo)(svelteFile); | ||
if (lang == null || alias == null) { | ||
@@ -99,0 +99,0 @@ alias = defaultLanguages[type]; |
@@ -28,3 +28,3 @@ "use strict"; | ||
const { transformer } = await Promise.resolve().then(() => __importStar(require('../transformers/coffeescript'))); | ||
let { content, filename, attributes, lang, dependencies, } = await (0, tagInfo_1.getTagInfo)(svelteFile); | ||
let { content, filename, attributes, lang, dependencies } = await (0, tagInfo_1.getTagInfo)(svelteFile); | ||
if (lang !== 'coffeescript') { | ||
@@ -31,0 +31,0 @@ return { code: content }; |
@@ -28,3 +28,3 @@ "use strict"; | ||
const { transformer } = await Promise.resolve().then(() => __importStar(require('../transformers/less'))); | ||
let { content, filename, attributes, lang, dependencies, } = await (0, tagInfo_1.getTagInfo)(svelteFile); | ||
let { content, filename, attributes, lang, dependencies } = await (0, tagInfo_1.getTagInfo)(svelteFile); | ||
if (lang !== 'less') { | ||
@@ -31,0 +31,0 @@ return { code: content }; |
@@ -28,3 +28,3 @@ "use strict"; | ||
const { transformer } = await Promise.resolve().then(() => __importStar(require('../transformers/scss'))); | ||
let { content, filename, attributes, lang, alias, dependencies, } = await (0, tagInfo_1.getTagInfo)(svelteFile); | ||
let { content, filename, attributes, lang, alias, dependencies } = await (0, tagInfo_1.getTagInfo)(svelteFile); | ||
if (alias === 'sass') { | ||
@@ -31,0 +31,0 @@ options = { |
@@ -28,3 +28,3 @@ "use strict"; | ||
const { transformer } = await Promise.resolve().then(() => __importStar(require('../transformers/stylus'))); | ||
let { content, filename, attributes, lang, dependencies, } = await (0, tagInfo_1.getTagInfo)(svelteFile); | ||
let { content, filename, attributes, lang, dependencies } = await (0, tagInfo_1.getTagInfo)(svelteFile); | ||
if (lang !== 'stylus') { | ||
@@ -31,0 +31,0 @@ return { code: content }; |
@@ -28,3 +28,3 @@ "use strict"; | ||
const { transformer } = await Promise.resolve().then(() => __importStar(require('../transformers/typescript'))); | ||
let { content, markup, filename, attributes, lang, dependencies, } = await (0, tagInfo_1.getTagInfo)(svelteFile); | ||
let { content, markup, filename, attributes, lang, dependencies } = await (0, tagInfo_1.getTagInfo)(svelteFile); | ||
if (lang !== 'typescript') { | ||
@@ -31,0 +31,0 @@ return { code: content }; |
@@ -10,3 +10,2 @@ "use strict"; | ||
const compiler_1 = require("svelte/compiler"); | ||
const package_json_1 = __importDefault(require("svelte/package.json")); | ||
const magic_string_1 = __importDefault(require("magic-string")); | ||
@@ -17,2 +16,3 @@ const sorcery_1 = __importDefault(require("sorcery")); | ||
const utils_1 = require("../modules/utils"); | ||
const package_json_1 = __importDefault(require("svelte/package.json")); | ||
const injectedCodeSeparator = 'const $$$$$$$$ = null;'; | ||
@@ -90,3 +90,4 @@ /** | ||
// TS transformer (previous attemps have failed) | ||
const codestores = Array.from(contentForCodestores.match(/\$[^\s();:,[\]{}.?!+-=*/~|&%<>^`"']+/g) || [], (name) => name.slice(1)).filter((name) => !utils_1.JAVASCRIPT_RESERVED_KEYWORD_SET.has(name)); | ||
const codestores = Array.from(contentForCodestores.match(/\$[^\s();:,[\]{}.?!+-=*/\\~|&%<>^`"'°§]+/g) || | ||
[], (name) => name.slice(1)).filter((name) => !utils_1.JAVASCRIPT_RESERVED_KEYWORD_SET.has(name)); | ||
const varsString = [...codestores, ...varnames].join(','); | ||
@@ -100,9 +101,9 @@ const injectedVars = `const $$vars$$ = [${varsString}];`; | ||
if (sourceMapChain) { | ||
const s = new magic_string_1.default(content); | ||
s.append(injectedCode); | ||
const ms = new magic_string_1.default(content).append(injectedCode); | ||
const fname = `${filename}.injected.ts`; | ||
const code = s.toString(); | ||
const map = s.generateMap({ | ||
const code = ms.toString(); | ||
const map = ms.generateMap({ | ||
source: filename, | ||
file: fname, | ||
hires: true, | ||
}); | ||
@@ -120,10 +121,10 @@ sourceMapChain.content[fname] = code; | ||
if (sourceMapChain) { | ||
const s = new magic_string_1.default(transpiledCode); | ||
const st = s.snip(0, injectedCodeStart); | ||
const ms = new magic_string_1.default(transpiledCode).snip(0, injectedCodeStart); | ||
const source = `${filename}.transpiled.js`; | ||
const file = `${filename}.js`; | ||
const code = st.toString(); | ||
const map = st.generateMap({ | ||
const code = ms.toString(); | ||
const map = ms.generateMap({ | ||
source, | ||
file, | ||
hires: true, | ||
}); | ||
@@ -130,0 +131,0 @@ sourceMapChain.content[file] = code; |
@@ -0,3 +1,3 @@ | ||
import * as Options from './options'; | ||
import type { Processed as SvelteProcessed, Preprocessor, PreprocessorGroup } from 'svelte/types/compiler/preprocess'; | ||
import * as Options from './options'; | ||
export { Options }; | ||
@@ -4,0 +4,0 @@ export { Processed as SvelteProcessed, PreprocessorGroup, Preprocessor, } from 'svelte/types/compiler/preprocess'; |
{ | ||
"name": "svelte-preprocess", | ||
"version": "4.10.0", | ||
"version": "4.10.1", | ||
"license": "MIT", | ||
@@ -80,4 +80,4 @@ "main": "dist/index.js", | ||
"@commitlint/config-conventional": "^11.0.0", | ||
"@kiwi/eslint-config": "^1.16.6", | ||
"@kiwi/prettier-config": "^1.16.6", | ||
"@kiwi/eslint-config": "^1.18.1", | ||
"@kiwi/prettier-config": "^1.18.1", | ||
"@types/jest": "^27.0.2", | ||
@@ -84,0 +84,0 @@ "@types/node": "^14.0.11", |
144105
2163
173
2
2
0
7