@@ -4,11 +4,7 @@ const VirtualModules = require('./lib/virtual');
4
4
5
5
const hotApi = require . resolve ( './lib/hot-api.js' ) ;
6
6
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' ) ;
12
8
13
9
const pluginOptions = {
14
10
externalDependencies : true ,
@@ -53,19 +49,6 @@ function posixify(file) {
53
49
return file . replace ( / [ / \\ ] / g, '/' ) ;
54
50
}
55
51
56
- function sanitize ( input ) {
57
- return basename ( input )
58
- . replace ( extname ( input ) , '' )
59
- . replace ( / [ ^ a - z A - Z _ $ 0 - 9 ] + / g, '_' )
60
- . replace ( / ^ _ / , '' )
61
- . replace ( / _ $ / , '' )
62
- . replace ( / ^ ( \d ) / , '_$1' ) ;
63
- }
64
-
65
- function capitalize ( str ) {
66
- return str [ 0 ] . toUpperCase ( ) + str . slice ( 1 ) ;
67
- }
68
-
69
52
function normalize ( compiled ) {
70
53
// svelte.compile signature changed in 1.60 — this avoids
71
54
// future deprecation warnings while preserving backwards
@@ -115,19 +98,11 @@ module.exports = function(source, map) {
115
98
116
99
const compileOptions = {
117
100
filename : this . resourcePath ,
118
- format : options . format || ( major_version >= 3 ? 'esm' : 'es' )
101
+ format : options . format || 'esm'
119
102
} ;
120
103
121
104
const handleWarning = warning => this . emitWarning ( new Error ( warning ) ) ;
122
105
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
-
131
106
for ( const option in options ) {
132
107
if ( ! pluginOptions [ option ] ) compileOptions [ option ] = options [ option ] ;
133
108
}
@@ -146,13 +121,11 @@ module.exports = function(source, map) {
146
121
147
122
let { js, css, warnings } = normalize ( compile ( processed . toString ( ) , compileOptions ) ) ;
148
123
149
- if ( major_version >= 3 ) {
150
- warnings . forEach (
151
- options . onwarn
152
- ? warning => options . onwarn ( warning , handleWarning )
153
- : handleWarning
154
- ) ;
155
- }
124
+ warnings . forEach (
125
+ options . onwarn
126
+ ? warning => options . onwarn ( warning , handleWarning )
127
+ : handleWarning
128
+ ) ;
156
129
157
130
if ( options . hotReload && ! isProduction && ! isServer ) {
158
131
const hotOptions = Object . assign ( { } , options . hotOptions ) ;
0 commit comments