svelte-preprocess
Advanced tools
Comparing version 4.9.3 to 4.9.4
@@ -17,2 +17,6 @@ "use strict"; | ||
const injectedCodeSeparator = 'const $$$$$$$$ = null;'; | ||
/** | ||
* Map of valid tsconfigs (no errors). Key is the path. | ||
*/ | ||
const tsconfigMap = new Map(); | ||
function createFormatDiagnosticsHost(cwd) { | ||
@@ -78,7 +82,14 @@ return { | ||
: v.name); | ||
const contentForCodestores = content + | ||
// Append instance script content because it's valid | ||
// to import a store in module script and autosubscribe to it in instance script | ||
((attributes === null || attributes === void 0 ? void 0 : attributes.context) === 'module' ? getScriptContent(markup, false) : ''); | ||
// This regex extracts all possible store variables | ||
// TODO investigate if it's possible to achieve this with a | ||
// TS transformer (previous attemps have failed) | ||
const codestores = Array.from(content.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(','); | ||
const injectedVars = `const $$vars$$ = [${varsString}];`; | ||
// Append instance/markup script content because it's valid | ||
// to import things in one and reference it in the other. | ||
const injectedCode = (attributes === null || attributes === void 0 ? void 0 : attributes.context) === 'module' | ||
@@ -189,2 +200,8 @@ ? `${sep}${getScriptContent(markup, false)}\n${injectedVars}` | ||
basePath = (0, path_1.dirname)(tsconfigFile); | ||
if (tsconfigMap.has(tsconfigFile)) { | ||
return { | ||
errors: [], | ||
options: tsconfigMap.get(tsconfigFile), | ||
}; | ||
} | ||
const { error, config } = typescript_1.default.readConfigFile(tsconfigFile, typescript_1.default.sys.readFile); | ||
@@ -199,2 +216,5 @@ if (error) { | ||
errors = errors.filter((d) => d.code !== 18003); | ||
if (errors.length === 0) { | ||
tsconfigMap.set(tsconfigFile, options); | ||
} | ||
return { errors, options }; | ||
@@ -201,0 +221,0 @@ } |
{ | ||
"name": "svelte-preprocess", | ||
"version": "4.9.3", | ||
"version": "4.9.4", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
96185
2145