From a8c5699c8e5383c18e7971f05b3ca4e1cdd6fe6a Mon Sep 17 00:00:00 2001 From: Non <19non91@gmail.com> Date: Thu, 3 Jun 2021 16:28:16 +0300 Subject: [PATCH 1/6] Adjust stuff to point to a fork --- LICENSE.md | 2 +- README.md | 2 ++ package.json | 6 +++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/LICENSE.md b/LICENSE.md index ea0fb28b..8e931c38 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,4 +1,4 @@ -Copyright (c) 2016-21 [these people](https://github.com/sveltejs/svelte-loader/graphs/contributors) +Copyright (c) 2016-21 [these people](https://github.com/non25/svelte-loader/graphs/contributors) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/README.md b/README.md index 7b9fe51a..87a55d5b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # svelte-loader +This is a fork for faster merges and releases. [More info](https://github.com/sveltejs/svelte-loader/issues/185). + [![Build Status](https://travis-ci.org/sveltejs/svelte-loader.svg?branch=master)](https://travis-ci.org/sveltejs/svelte-loader) A [webpack](https://webpack.js.org) loader for [svelte](https://svelte.technology). diff --git a/package.json b/package.json index 2331a1c3..54ece2d7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "svelte-loader", - "version": "3.1.1", + "name": "@non25/svelte-loader", + "version": "3.1.2", "author": "Nico Rehwaldt ", "description": "A webpack loader for svelte", "license": "MIT", @@ -33,7 +33,7 @@ }, "repository": { "type": "git", - "url": "git@github.com:sveltejs/svelte-loader.git" + "url": "git@github.com:non25/svelte-loader.git" }, "files": [ "lib", From 3fbeebf7995652bb023a1f42798d33ca45dcbe89 Mon Sep 17 00:00:00 2001 From: Non <19non91@gmail.com> Date: Thu, 3 Jun 2021 16:39:57 +0300 Subject: [PATCH 2/6] -> 3.1.2 --- CHANGELOG.md | 2 +- package-lock.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 188d4365..1ba7a7f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # svelte-loader changelog -## 3.1.2 (Unreleased) +## 3.1.2 * Update to latest `svelte-hmr` package fixing Webpack 4 support * Fix sourcemap breakpoints ([#183](https://github.com/sveltejs/svelte-loader/pull/183)) diff --git a/package-lock.json b/package-lock.json index dbb7321f..388f25ec 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "svelte-loader", - "version": "3.1.1", + "version": "3.1.2", "lockfileVersion": 1, "requires": true, "dependencies": { From 1b4b8a2a28ad9736e6aa061882d1feb5367fb806 Mon Sep 17 00:00:00 2001 From: Non <19non91@gmail.com> Date: Thu, 3 Jun 2021 23:43:09 +0300 Subject: [PATCH 3/6] Readme overhaul --- README.md | 338 ++++++++++++++++----------------------------------- package.json | 2 +- 2 files changed, 104 insertions(+), 236 deletions(-) diff --git a/README.md b/README.md index 87a55d5b..da35b21b 100644 --- a/README.md +++ b/README.md @@ -1,271 +1,183 @@ -# svelte-loader +# @non25/svelte-loader -This is a fork for faster merges and releases. [More info](https://github.com/sveltejs/svelte-loader/issues/185). - -[![Build Status](https://travis-ci.org/sveltejs/svelte-loader.svg?branch=master)](https://travis-ci.org/sveltejs/svelte-loader) - -A [webpack](https://webpack.js.org) loader for [svelte](https://svelte.technology). +Fork of a [webpack](https://webpack.js.org) loader for [svelte](https://svelte.dev) with bugs fixed. +Webpack 4 & 5 are supported. ## Install +On the existing project, make sure to have following packages: + ``` -npm install --save svelte svelte-loader +npm install -D svelte @non25/svelte-loader svelte-preprocess postcss postcss-import postcss-load-config ``` - ## Usage -Configure inside your `webpack.config.js`: +Here's full-featured configuration with hot module replacement: ```javascript +const MiniCssExtractPlugin = require('mini-css-extract-plugin'); +const sveltePreprocess = require('svelte-preprocess'); +const mode = process.env.NODE_ENV || 'development'; +const prod = mode === 'production'; ... resolve: { - // see below for an explanation + // include only one version of svelte runtime alias: { svelte: path.resolve('node_modules', 'svelte') }, + + // import .svelte files without extension extensions: ['.mjs', '.js', '.svelte'], + + // use sources of third-party svelte packages mainFields: ['svelte', 'browser', 'module', 'main'] }, module: { rules: [ ... { - test: /\.(html|svelte)$/, - use: 'svelte-loader' - }, - { - // required to prevent errors from Svelte on Webpack 5+, omit on Webpack 4 - test: /node_modules\/svelte\/.*\.mjs$/, - resolve: { - fullySpecified: false - } - } - ... - ] - } - ... -``` - -Check out the [example project](https://github.com/sveltejs/template-webpack). - -### resolve.alias - -The [`resolve.alias`](https://webpack.js.org/configuration/resolve/#resolvealias) option is used to make sure that only one copy of the Svelte runtime is bundled in the app, even if you are `npm link`ing in dependencies with their own copy of the `svelte` package. Having multiple copies of the internal scheduler in an app, besides being inefficient, can also cause various problems. - -### resolve.mainFields - -Webpack's [`resolve.mainFields`](https://webpack.js.org/configuration/resolve/#resolve-mainfields) option determines which fields in package.json are used to resolve identifiers. If you're using Svelte components installed from npm, you should specify this option so that your app can use the original component source code, rather than consuming the already-compiled version (which is less efficient). - -### Extracting CSS + test: /\.svelte$/, + use: { + loader: '@non25/svelte-loader', + options: { + compilerOptions: { + // required by hot module replacement (HMR) + dev: !prod, + }, -If your Svelte components contain `