svelte-loader
Advanced tools
Comparing version 3.2.3 to 3.2.4
16
index.js
@@ -66,3 +66,3 @@ const path = require('path'); | ||
const svelte_module_regex = /\.svelte(\.[^./\\]+)*\.(js|ts)$/ | ||
const svelte_module_regex = /\.svelte(\.[^./\\]+)*\.(js|ts)$/; | ||
@@ -92,7 +92,9 @@ module.exports = function(source, map) { | ||
if (getMajor() >= 5 && svelte_module_regex.test(this.resourcePath)) { | ||
let js, warnings; | ||
try { | ||
const { js, warnings } = svelte.compileModule( | ||
({ js, warnings } = svelte.compileModule( | ||
source, | ||
{ filename: this.resourcePath, dev: compileOptions.dev, generate: compileOptions.generate } | ||
); | ||
)); | ||
@@ -104,4 +106,2 @@ warnings.forEach( | ||
); | ||
callback(null, js.code, js.map); | ||
} catch (err) { | ||
@@ -113,2 +113,6 @@ // wrap error to provide correct | ||
// outside try-catch - if this fails and we catch it, | ||
// calling callback again will mask the error with a "already called" error | ||
callback(null, js.code, js.map); | ||
return; | ||
@@ -183,3 +187,3 @@ } | ||
if (getMajor() < 5 || !err_str.startsWith('CompileError:')) { | ||
err_str = `${err.name}: ${err_str}` | ||
err_str = `${err.name}: ${err_str}`; | ||
} | ||
@@ -186,0 +190,0 @@ callback(new Error(err_str)); |
{ | ||
"name": "svelte-loader", | ||
"version": "3.2.3", | ||
"version": "3.2.4", | ||
"author": "Nico Rehwaldt <git_nikku@nixis.de>", | ||
@@ -10,3 +10,4 @@ "description": "A webpack loader for svelte", | ||
"test": "mocha --harmony --full-trace --check-leaks", | ||
"lint": "eslint index.js lib/*.js test/**/*.js" | ||
"lint": "eslint index.js lib/*.js test/**/*.js", | ||
"prepublishOnly": "npm run all" | ||
}, | ||
@@ -13,0 +14,0 @@ "keywords": [ |
@@ -35,8 +35,14 @@ > Undecided yet what bundler to use? We suggest using [SvelteKit](https://kit.svelte.dev), or Vite with [vite-plugin-svelte](https://github.com/sveltejs/vite-plugin-svelte/). | ||
... | ||
// This is only needed if you use Svelte 5+ with TypeScript | ||
// The following two loader entries are only needed if you use Svelte 5+ with TypeScript. | ||
// Also make sure your tsconfig.json includes `"target": "ESNext"` in order to not downlevel syntax | ||
{ | ||
test: /\.svelte\.ts$/, | ||
use: ['ts-loader', 'svelte-loader'] | ||
use: [ "svelte-loader", "ts-loader"], | ||
}, | ||
// This is the config for other .ts files - the regex makes sure to not process .svelte.ts files twice | ||
{ | ||
test: /(?<!\.svelte)\.ts$/, | ||
loader: "ts-loader", | ||
}, | ||
{ | ||
// Svelte 5+: | ||
@@ -43,0 +49,0 @@ test: /\.(svelte|svelte\.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
23583
252
398