rollup-plugin-riot 10.0.0 → 10.1.0
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 +8 -1
- package/dist/rollup-plugin-riot.cjs +30 -2
- package/dist/rollup-plugin-riot.js +30 -2
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -53,12 +53,19 @@ export default {
|
|
|
53
53
|
- `ext`: extension of tag file (default is 'riot')
|
|
54
54
|
- `include`: a [minimatch](https://www.npmjs.com/package/minimatch) pattern for including files.
|
|
55
55
|
- `exclude`: a minimatch pattern for excluding files.
|
|
56
|
+
- `hot`: enable hot module replacement (HMR) support by injecting `@riotjs/hot-reload` integration code.
|
|
57
|
+
|
|
58
|
+
If you enable `hot` you will also need to install [`@riotjs/hot-reload`](https://www.npmjs.com/package/@riotjs/hot-reload):
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
npm install @riotjs/hot-reload -D
|
|
62
|
+
```
|
|
56
63
|
|
|
57
64
|
And other options of `@riotjs/compiler` could be used.
|
|
58
65
|
|
|
59
66
|
## Recipes
|
|
60
67
|
|
|
61
|
-
- https://github.com/riot/examples/tree/gh-pages/rollup
|
|
68
|
+
- <https://github.com/riot/examples/tree/gh-pages/rollup>
|
|
62
69
|
|
|
63
70
|
[ci-image]: https://img.shields.io/github/actions/workflow/status/riot/rollup-plugin-riot/test.yml?style=flat-square
|
|
64
71
|
[ci-url]: https://github.com/riot/rollup-plugin-riot/actions
|
|
@@ -28,18 +28,39 @@ function getFilter(opts) {
|
|
|
28
28
|
|
|
29
29
|
/* eslint-disable fp/no-delete */
|
|
30
30
|
|
|
31
|
+
function generateHotReloadCode() {
|
|
32
|
+
return `
|
|
33
|
+
const __riot_hot_reload__ = (component) =>
|
|
34
|
+
import('@riotjs/hot-reload').then(({ default: hotReload }) =>
|
|
35
|
+
hotReload(component),
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
if (import.meta.hot) {
|
|
39
|
+
import.meta.hot.accept((mod) => {
|
|
40
|
+
if (mod && mod.default) {
|
|
41
|
+
__riot_hot_reload__(mod.default)
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
} else if (typeof module !== 'undefined' && module.hot) {
|
|
45
|
+
module.hot.accept()
|
|
46
|
+
}
|
|
47
|
+
`
|
|
48
|
+
}
|
|
49
|
+
|
|
31
50
|
function riot(options) {
|
|
32
51
|
// clone options
|
|
33
52
|
options = Object.assign({}, options);
|
|
34
53
|
|
|
35
|
-
const filter = getFilter(options)
|
|
54
|
+
const filter = getFilter(options);
|
|
55
|
+
const hot = options.hot
|
|
36
56
|
|
|
37
57
|
// drop properties not necessary for Riot compiler
|
|
38
|
-
;['ext', 'include', 'parsers', 'sourcemap'].forEach((key) => {
|
|
58
|
+
;['ext', 'include', 'parsers', 'sourcemap', 'hot'].forEach((key) => {
|
|
39
59
|
delete options[key];
|
|
40
60
|
});
|
|
41
61
|
|
|
42
62
|
return {
|
|
63
|
+
name: 'riot',
|
|
43
64
|
transform(src, id) {
|
|
44
65
|
if (!filter(id)) {
|
|
45
66
|
return null
|
|
@@ -50,6 +71,13 @@ function riot(options) {
|
|
|
50
71
|
...options,
|
|
51
72
|
});
|
|
52
73
|
|
|
74
|
+
if (hot) {
|
|
75
|
+
return {
|
|
76
|
+
code: `${code}\n${generateHotReloadCode()}`,
|
|
77
|
+
map,
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
53
81
|
return { code, map }
|
|
54
82
|
},
|
|
55
83
|
}
|
|
@@ -26,18 +26,39 @@ function getFilter(opts) {
|
|
|
26
26
|
|
|
27
27
|
/* eslint-disable fp/no-delete */
|
|
28
28
|
|
|
29
|
+
function generateHotReloadCode() {
|
|
30
|
+
return `
|
|
31
|
+
const __riot_hot_reload__ = (component) =>
|
|
32
|
+
import('@riotjs/hot-reload').then(({ default: hotReload }) =>
|
|
33
|
+
hotReload(component),
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
if (import.meta.hot) {
|
|
37
|
+
import.meta.hot.accept((mod) => {
|
|
38
|
+
if (mod && mod.default) {
|
|
39
|
+
__riot_hot_reload__(mod.default)
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
} else if (typeof module !== 'undefined' && module.hot) {
|
|
43
|
+
module.hot.accept()
|
|
44
|
+
}
|
|
45
|
+
`
|
|
46
|
+
}
|
|
47
|
+
|
|
29
48
|
function riot(options) {
|
|
30
49
|
// clone options
|
|
31
50
|
options = Object.assign({}, options);
|
|
32
51
|
|
|
33
|
-
const filter = getFilter(options)
|
|
52
|
+
const filter = getFilter(options);
|
|
53
|
+
const hot = options.hot
|
|
34
54
|
|
|
35
55
|
// drop properties not necessary for Riot compiler
|
|
36
|
-
;['ext', 'include', 'parsers', 'sourcemap'].forEach((key) => {
|
|
56
|
+
;['ext', 'include', 'parsers', 'sourcemap', 'hot'].forEach((key) => {
|
|
37
57
|
delete options[key];
|
|
38
58
|
});
|
|
39
59
|
|
|
40
60
|
return {
|
|
61
|
+
name: 'riot',
|
|
41
62
|
transform(src, id) {
|
|
42
63
|
if (!filter(id)) {
|
|
43
64
|
return null
|
|
@@ -48,6 +69,13 @@ function riot(options) {
|
|
|
48
69
|
...options,
|
|
49
70
|
});
|
|
50
71
|
|
|
72
|
+
if (hot) {
|
|
73
|
+
return {
|
|
74
|
+
code: `${code}\n${generateHotReloadCode()}`,
|
|
75
|
+
map,
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
51
79
|
return { code, map }
|
|
52
80
|
},
|
|
53
81
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rollup-plugin-riot",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Rollup plugin for Riot.js",
|
|
6
6
|
"jsnext:main": "dist/rollup-plugin-riot.js",
|
|
@@ -27,20 +27,20 @@
|
|
|
27
27
|
"rollup-plugin"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@rollup/pluginutils": "^5.
|
|
30
|
+
"@rollup/pluginutils": "^5.5.1"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@riotjs/compiler": "^10.0.
|
|
33
|
+
"@riotjs/compiler": "^10.0.5",
|
|
34
34
|
"@riotjs/prettier-config": "^1.1.0",
|
|
35
|
-
"chai": "^6.0
|
|
36
|
-
"eslint": "^
|
|
37
|
-
"eslint-config-riot": "^
|
|
38
|
-
"fs-extra": "^11.
|
|
39
|
-
"mocha": "^
|
|
40
|
-
"postcss": "^8.5.
|
|
35
|
+
"chai": "^6.3.0",
|
|
36
|
+
"eslint": "^10.15.0",
|
|
37
|
+
"eslint-config-riot": "^6.0.1",
|
|
38
|
+
"fs-extra": "^11.4.1",
|
|
39
|
+
"mocha": "^12.0.3",
|
|
40
|
+
"postcss": "^8.5.33",
|
|
41
41
|
"postcss-cssnext": "^3.1.1",
|
|
42
|
-
"prettier": "^3.
|
|
43
|
-
"rollup": "^4.
|
|
42
|
+
"prettier": "^3.10.1",
|
|
43
|
+
"rollup": "^4.68.7"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "rollup -c",
|