Skip to content

Commit

Permalink
fix: 🐛 inverted conditionals on typescript transformer
Browse files Browse the repository at this point in the history
  • Loading branch information
kaisermann committed Aug 29, 2019
1 parent 3d105ec commit a6937f0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/transformers/postcss.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ module.exports = async ({ content, filename, options, map = undefined }) => {
options = await postcssLoadConfig(options, options.configFilePath)
} catch (e) {
/** Something went wrong, do nothing */
// istanbul ignore next
if (e.code === 'MODULE_NOT_FOUND') {
console.error(
`[svelte-preprocess] PostCSS configuration was not passed. If you expect to load it from a file, make sure to install "postcss-load-config" and try again ʕ•ᴥ•ʔ`,
Expand Down
8 changes: 4 additions & 4 deletions src/transformers/typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ function isSvelteFile(filename) {
const IMPORTEE_PATTERN = /['"](.*?)['"]/
function isValidSvelteImportDiagnostic(filename, diagnostic) {
// TS2307: 'cannot find module'
if (diagnostic.code !== 2307) return false
if (diagnostic.code !== 2307) return true

const importeeMatch = diagnostic.messageText.match(IMPORTEE_PATTERN)
// istanbul ignore if
if (!importeeMatch) return false
if (!importeeMatch) return true

let [, importeePath] = importeeMatch
/** if we're not dealing with a relative path, assume the file exists */
if (importeePath[0] !== '.') return true
if (importeePath[0] !== '.') return false

/** if the importee is not a svelte file, do nothing */
if (!isSvelteFile(importeePath)) return false
if (!isSvelteFile(importeePath)) return true

importeePath = resolve(dirname(filename), importeePath)

Expand Down

0 comments on commit a6937f0

Please sign in to comment.