piral-svelte 0.14.8-beta.3487 → 0.14.8-beta.3490

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -51,6 +51,67 @@ export function setup(piral: PiletApi) {
51
51
  }
52
52
  ```
53
53
 
54
+ How you built your Svelte-pilet is up to you. If you use Webpack then the bundler options such as `piral-cli-webpack` or `piral-cli-webpack5` can be leveraged. In these cases you'd need to install the `svelte-loader` package and create a custom *webpack.config.js*:
55
+
56
+ ```sh
57
+ npm i svelte-loader --save-dev
58
+ ```
59
+
60
+ The Webpack configuration can be rather simplistic, as shown on the [svelte-loader readme](https://github.com/sveltejs/svelte-loader). In many cases you can use the convenience `extend-webpack` module.
61
+
62
+ This is how your *webpack.config.js* can look like with the convenience module:
63
+
64
+ ```js
65
+ const extendWebpack = require('piral-svelte/extend-webpack');
66
+
67
+ module.exports = extendWebpack({});
68
+ ```
69
+
70
+ For using `piral-svelte/extend-webpack` you must have installed:
71
+
72
+ - `svelte-loader`
73
+ - `webpack`, e.g., via `piral-cli-webpack5`
74
+
75
+ You can do that via:
76
+
77
+ ```sh
78
+ npm i svelte-loader piral-cli-webpack5 --save-dev
79
+ ```
80
+
81
+ The available options for `piral-svelte/extend-webpack` are the same as for the options of the `svelte-loader`, e.g.:
82
+
83
+ ```js
84
+ const extendWebpack = require('piral-svelte/extend-webpack');
85
+
86
+ module.exports = extendWebpack({
87
+ emitCss: false,
88
+ compilerOptions: {
89
+ css: false,
90
+ },
91
+ });
92
+ ```
93
+
94
+ You can also customize the options even more:
95
+
96
+ ```js
97
+ const extendWebpack = require('piral-svelte/extend-webpack');
98
+
99
+ const applySvelte = extendWebpack({
100
+ emitCss: false,
101
+ compilerOptions: {
102
+ css: false,
103
+ },
104
+ });
105
+
106
+ module.exports = config => {
107
+ config = applySvelte(config);
108
+
109
+ // your changes to config
110
+
111
+ return config;
112
+ };
113
+ ```
114
+
54
115
  :::
55
116
 
56
117
  ::: summary: For Piral instance developers
@@ -113,7 +174,7 @@ For Svelte to work the Svelte compiler and the associated Parcel plugin need to
113
174
  npm i svelte parcel-plugin-svelte --save-dev
114
175
  ```
115
176
 
116
- Furthermore, since Svelte distributes its source code as ES6 we need to change the browserlist setting in the *package.json* of the pilet:
177
+ Furthermore, since Svelte distributes its source code as ES6 we need to change the `browserslist` setting in the *package.json* of the pilet:
117
178
 
118
179
  ```json
119
180
  {
@@ -0,0 +1,42 @@
1
+ const { resolve } = require('path');
2
+
3
+ const svelteLoader = require.resolve('svelte-loader');
4
+
5
+ module.exports =
6
+ (options = {}) =>
7
+ (config) => {
8
+ if (!config.resolve.alias) {
9
+ config.resolve.alias = {};
10
+ }
11
+
12
+ if (!config.resolve.extensions) {
13
+ config.resolve.extensions = ['.mjs', '.js'];
14
+ }
15
+
16
+ if (!config.resolve.mainFields) {
17
+ config.resolve.mainFields = ['browser', 'module', 'main'];
18
+ }
19
+
20
+ config.resolve.alias.svelte = resolve('node_modules', 'svelte');
21
+ config.resolve.extensions.push('.svelte');
22
+ config.resolve.mainFields.unshift('svelte');
23
+
24
+ config.module.rules.push(
25
+ {
26
+ test: /\.(html|svelte)$/,
27
+ use: svelteLoader,
28
+ options: {
29
+ emitCss: true,
30
+ ...options,
31
+ },
32
+ },
33
+ {
34
+ test: /node_modules\/svelte\/.*\.mjs$/,
35
+ resolve: {
36
+ fullySpecified: false,
37
+ },
38
+ },
39
+ );
40
+
41
+ return config;
42
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "piral-svelte",
3
- "version": "0.14.8-beta.3487",
3
+ "version": "0.14.8-beta.3490",
4
4
  "description": "Plugin for integrating Svelte components in Piral.",
5
5
  "keywords": [
6
6
  "piral",
@@ -25,7 +25,8 @@
25
25
  "lib",
26
26
  "src",
27
27
  "convert.d.ts",
28
- "convert.js"
28
+ "convert.js",
29
+ "extend-webpack.js"
29
30
  ],
30
31
  "repository": {
31
32
  "type": "git",
@@ -43,10 +44,10 @@
43
44
  "test": "echo \"Error: run tests from root\" && exit 1"
44
45
  },
45
46
  "devDependencies": {
46
- "piral-core": "0.14.8-beta.3487"
47
+ "piral-core": "0.14.8-beta.3490"
47
48
  },
48
49
  "peerDependencies": {
49
50
  "piral-core": "0.14.x"
50
51
  },
51
- "gitHead": "95872598216edbf8efd99c8b7044094ea209a049"
52
+ "gitHead": "c8a70566a926e3306ad5aee94e0f3f7b1bc3d690"
52
53
  }