Skip to content

Commit a328b40

Browse files
committed
chore: get ready for Svelte 4
1 parent d1dcf88 commit a328b40

File tree

4 files changed

+22
-8
lines changed

4 files changed

+22
-8
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# svelte-loader changelog
22

3+
## 3.1.8
4+
5+
* Get ready for Svelte 4
6+
37
## 3.1.7
48

59
* More robust `conditionNames: ['svelte']` detection ([#226](https://github.com/sveltejs/svelte-loader/pull/226))

index.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const path = require('path');
22
const fs = require('fs');
33
const { getOptions } = require('loader-utils');
44
const { buildMakeHot } = require('./lib/make-hot.js');
5-
const { compile, preprocess } = require('svelte/compiler');
5+
const { compile, preprocess, VERSION } = require('svelte/compiler');
66

77
function posixify(file) {
88
return file.replace(/[/\\]/g, '/');
@@ -53,6 +53,8 @@ try {
5353
// do nothing and hope for the best
5454
}
5555

56+
let warned = false;
57+
5658
module.exports = function(source, map) {
5759
this.cacheable();
5860

@@ -72,9 +74,17 @@ module.exports = function(source, map) {
7274
const compileOptions = {
7375
filename: this.resourcePath,
7476
css: !options.emitCss,
75-
...options.compilerOptions,
76-
format: (options.compilerOptions && options.compilerOptions.format) || 'esm'
77+
...options.compilerOptions
7778
};
79+
if (VERSION[0] === '3') {
80+
compileOptions.format = (options.compilerOptions && options.compilerOptions.format) || 'esm'
81+
} else {
82+
if (options.compilerOptions && options.compilerOptions.format && !warned) {
83+
warned = true;
84+
console.warn(`[svelte-loader] Svelte's "format" compiler option was removed in version 4, the output is always ESM now.` +
85+
` Remove the format option from your webpack config to remove this warning.`);
86+
}
87+
}
7888

7989
const handleWarning = warning => this.emitWarning(new Error(warning));
8090

package-lock.json

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

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "svelte-loader",
3-
"version": "3.1.7",
3+
"version": "3.1.8",
44
"author": "Nico Rehwaldt <git_nikku@nixis.de>",
55
"description": "A webpack loader for svelte",
66
"license": "MIT",
@@ -29,7 +29,7 @@
2929
"svelte": "^3.0.0"
3030
},
3131
"peerDependencies": {
32-
"svelte": "^3.0.0 || ^4.0.0"
32+
"svelte": "^3.0.0 || 4.0.0-next.0 || 4.0.0-next.1 || ^4.0.0"
3333
},
3434
"repository": {
3535
"type": "git",

0 commit comments

Comments
 (0)