Skip to content

Commit 2239da5

Browse files
committed
Drop Svelte 2 support
1 parent c4ca347 commit 2239da5

File tree

1 file changed

+7
-21
lines changed

1 file changed

+7
-21
lines changed

index.js

+7-21
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@ const VirtualModules = require('./lib/virtual');
44

55
const hotApi = require.resolve('./lib/hot-api.js');
66

7-
const { version } = require('svelte/package.json');
8-
const major_version = +version[0];
9-
const { compile, preprocess } = major_version >= 3
10-
? require('svelte/compiler')
11-
: require('svelte');
7+
const { compile, preprocess } = require('svelte/compiler');
128

139
const pluginOptions = {
1410
externalDependencies: true,
@@ -115,19 +111,11 @@ module.exports = function(source, map) {
115111

116112
const compileOptions = {
117113
filename: this.resourcePath,
118-
format: options.format || (major_version >= 3 ? 'esm' : 'es')
114+
format: options.format || 'esm'
119115
};
120116

121117
const handleWarning = warning => this.emitWarning(new Error(warning));
122118

123-
if (major_version >= 3) {
124-
// TODO anything?
125-
} else {
126-
compileOptions.shared = options.shared || 'svelte/shared.js';
127-
compileOptions.name = capitalize(sanitize(compileOptions.filename));
128-
compileOptions.onwarn = options.onwarn || handleWarning;
129-
}
130-
131119
for (const option in options) {
132120
if (!pluginOptions[option]) compileOptions[option] = options[option];
133121
}
@@ -146,13 +134,11 @@ module.exports = function(source, map) {
146134

147135
let { js, css, warnings } = normalize(compile(processed.toString(), compileOptions));
148136

149-
if (major_version >= 3) {
150-
warnings.forEach(
151-
options.onwarn
152-
? warning => options.onwarn(warning, handleWarning)
153-
: handleWarning
154-
);
155-
}
137+
warnings.forEach(
138+
options.onwarn
139+
? warning => options.onwarn(warning, handleWarning)
140+
: handleWarning
141+
);
156142

157143
if (options.hotReload && !isProduction && !isServer) {
158144
const hotOptions = Object.assign({}, options.hotOptions);

0 commit comments

Comments
 (0)