Skip to content

Commit ee60199

Browse files
committed
use Rollup-provided this.warn and this.error functions
1 parent f1a8784 commit ee60199

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

package-lock.json

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.js

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -121,16 +121,6 @@ export default function svelte(options = {}) {
121121

122122
fixedOptions.format = 'es';
123123
fixedOptions.shared = require.resolve(options.shared || 'svelte/shared.js');
124-
fixedOptions.onerror = err => {
125-
let message =
126-
(err.loc ? `(${err.loc.line}:${err.loc.column}) ` : '') + err.message;
127-
if (err.frame) message += `\n${err.frame}`;
128-
129-
const err2 = new Error(message);
130-
err2.stack = err.stack;
131-
132-
throw err2;
133-
};
134124

135125
// handle CSS extraction
136126
if ('css' in options) {
@@ -148,6 +138,10 @@ export default function svelte(options = {}) {
148138
fixedOptions.css = false;
149139
}
150140

141+
if (options.onwarn) {
142+
fixedOptions.onwarn = options.onwarn;
143+
}
144+
151145
return {
152146
name: 'svelte',
153147

@@ -189,7 +183,10 @@ export default function svelte(options = {}) {
189183

190184
const compiled = compile(
191185
code,
192-
Object.assign({}, fixedOptions, {
186+
Object.assign({}, {
187+
onwarn: warning => this.warn(warning),
188+
onerror: error => this.error(error)
189+
}, fixedOptions, {
193190
name: capitalize(sanitize(id)),
194191
filename: id
195192
})

0 commit comments

Comments
 (0)