Skip to content

Commit 5b3d36f

Browse files
committed
Merge remote-tracking branch 'benmccann/compilerOptions' into refactor
2 parents 7b9380a + 3934f57 commit 5b3d36f

File tree

7 files changed

+1207
-760
lines changed

7 files changed

+1207
-760
lines changed

.eslintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
},
1313
"extends": "eslint:recommended",
1414
"parserOptions": {
15+
ecmaVersion: 9,
1516
"sourceType": "module"
1617
},
1718
"plugins": [

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
* Breaking: dropped Svelte 2 support ([#150](https://github.com/sveltejs/svelte-loader/pull/150))
66
* Breaking: dropped Node 8 support ([#157](https://github.com/sveltejs/svelte-loader/pull/157))
7+
* Breaking: compiler options must now be specified under `compilerOptions` ([#159](https://github.com/sveltejs/svelte-loader/pull/159))
78
* Add Webpack 5 support ([#151](https://github.com/sveltejs/svelte-loader/pull/151))
89
* Replace broken Svelte 2 HMR with the implementation from `rixo/svelte-loader-hot` ([#156](https://github.com/sveltejs/svelte-loader/pull/156))
910
* Add Node 14 support and fix intermittent crashes when using `cache-loader` in front of `svelte-loader` ([#125](https://github.com/sveltejs/svelte-loader/pull/125))

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,12 @@ module.exports = {
177177
use: {
178178
loader: 'svelte-loader',
179179
options: {
180-
// NOTE Svelte's dev mode MUST be enabled for HMR to work
181-
// -- in a real config, you'd probably set it to false for prod build,
182-
// based on a env variable or so
183-
dev: true,
180+
compilerOptions: {
181+
// NOTE Svelte's dev mode MUST be enabled for HMR to work
182+
// -- in a real config, you'd probably set it to false for prod build,
183+
// based on a env variable or so
184+
dev: true,
185+
},
184186

185187
// NOTE emitCss: true is currently not supported with HMR
186188
// Enable it for production to output separate css file

index.js

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,6 @@ const { getOptions } = require('loader-utils');
33
const { makeHot } = require('./lib/make-hot.js');
44
const { compile, preprocess } = require('svelte/compiler');
55

6-
const pluginOptions = {
7-
hotReload: true,
8-
hotOptions: true,
9-
preprocess: true,
10-
emitCss: true,
11-
12-
// legacy
13-
onwarn: true,
14-
style: true,
15-
script: true,
16-
markup: true
17-
};
18-
196
function posixify(file) {
207
return file.replace(/[/\\]/g, '/');
218
}
@@ -36,22 +23,18 @@ module.exports = function(source, map) {
3623
return;
3724
}
3825

39-
const isServer = this.target === 'node' || (options.generate && options.generate == 'ssr');
26+
const isServer = this.target === 'node' || (options.compilerOptions && options.compilerOptions.generate == 'ssr');
4027
const isProduction = this.minimize || process.env.NODE_ENV === 'production';
4128

4229
const compileOptions = {
4330
filename: this.resourcePath,
44-
format: options.format || 'esm'
31+
css: !options.emitCss,
32+
...options.compilerOptions,
33+
format: (options.compilerOptions && options.compilerOptions.format) || 'esm'
4534
};
4635

4736
const handleWarning = warning => this.emitWarning(new Error(warning));
4837

49-
for (const option in options) {
50-
if (!pluginOptions[option]) compileOptions[option] = options[option];
51-
}
52-
53-
if (options.emitCss) compileOptions.css = false;
54-
5538
options.preprocess = { filename: compileOptions.filename };
5639

5740
preprocess(source, options.preprocess).then(processed => {

0 commit comments

Comments
 (0)