Skip to content

Commit

Permalink
chore: get ready for Svelte 4
Browse files Browse the repository at this point in the history
  • Loading branch information
dummdidumm committed May 26, 2023
1 parent d1dcf88 commit a328b40
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# svelte-loader changelog

## 3.1.8

* Get ready for Svelte 4

## 3.1.7

* More robust `conditionNames: ['svelte']` detection ([#226](https://github.com/sveltejs/svelte-loader/pull/226))
Expand Down
16 changes: 13 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const path = require('path');
const fs = require('fs');
const { getOptions } = require('loader-utils');
const { buildMakeHot } = require('./lib/make-hot.js');
const { compile, preprocess } = require('svelte/compiler');
const { compile, preprocess, VERSION } = require('svelte/compiler');

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

let warned = false;

module.exports = function(source, map) {
this.cacheable();

Expand All @@ -72,9 +74,17 @@ module.exports = function(source, map) {
const compileOptions = {
filename: this.resourcePath,
css: !options.emitCss,
...options.compilerOptions,
format: (options.compilerOptions && options.compilerOptions.format) || 'esm'
...options.compilerOptions
};
if (VERSION[0] === '3') {
compileOptions.format = (options.compilerOptions && options.compilerOptions.format) || 'esm'

Check failure on line 80 in index.js

View workflow job for this annotation

GitHub Actions / Test on Node v14 on ubuntu-latest

Missing semicolon

Check failure on line 80 in index.js

View workflow job for this annotation

GitHub Actions / Test on Node v16 on ubuntu-latest

Missing semicolon

Check failure on line 80 in index.js

View workflow job for this annotation

GitHub Actions / Test on Node v18 on ubuntu-latest

Missing semicolon

Check failure on line 80 in index.js

View workflow job for this annotation

GitHub Actions / Test on Node v14 on ubuntu-latest

Missing semicolon

Check failure on line 80 in index.js

View workflow job for this annotation

GitHub Actions / Test on Node v16 on ubuntu-latest

Missing semicolon

Check failure on line 80 in index.js

View workflow job for this annotation

GitHub Actions / Test on Node v18 on ubuntu-latest

Missing semicolon
} else {
if (options.compilerOptions && options.compilerOptions.format && !warned) {
warned = true;
console.warn(`[svelte-loader] Svelte's "format" compiler option was removed in version 4, the output is always ESM now.` +
` Remove the format option from your webpack config to remove this warning.`);
}
}

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

Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "svelte-loader",
"version": "3.1.7",
"version": "3.1.8",
"author": "Nico Rehwaldt <git_nikku@nixis.de>",
"description": "A webpack loader for svelte",
"license": "MIT",
Expand Down Expand Up @@ -29,7 +29,7 @@
"svelte": "^3.0.0"
},
"peerDependencies": {
"svelte": "^3.0.0 || ^4.0.0"
"svelte": "^3.0.0 || 4.0.0-next.0 || 4.0.0-next.1 || ^4.0.0"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit a328b40

Please sign in to comment.