@ripple-ts/rollup-plugin 0.2.153
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/LICENSE +21 -0
- package/index.js +66 -0
- package/package.json +27 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Dominic Gannaway
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/index.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { createFilter } from '@rollup/pluginutils';
|
|
3
|
+
import { compile } from 'ripple/compiler';
|
|
4
|
+
|
|
5
|
+
const PREFIX = '[@ripple-ts/rollup-plugin]';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @param [options] {Partial<import('.').Options>}
|
|
9
|
+
* @returns {import('rollup').Plugin}
|
|
10
|
+
*/
|
|
11
|
+
export default function (options = {}) {
|
|
12
|
+
const { compilerOptions = {}, ...rest } = options;
|
|
13
|
+
const extensions = ['.ripple'];
|
|
14
|
+
const filter = createFilter(rest.include, rest.exclude);
|
|
15
|
+
|
|
16
|
+
// [filename]:[chunk]
|
|
17
|
+
const cache_emit = new Map();
|
|
18
|
+
const { emitCss = true } = rest;
|
|
19
|
+
|
|
20
|
+
if (emitCss) {
|
|
21
|
+
const cssOptionValue = 'external';
|
|
22
|
+
if (compilerOptions.css) {
|
|
23
|
+
console.warn(
|
|
24
|
+
`${PREFIX} Forcing \`"compilerOptions.css": ${
|
|
25
|
+
typeof cssOptionValue === 'string' ? `"${cssOptionValue}"` : cssOptionValue
|
|
26
|
+
}\` because "emitCss" was truthy.`,
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
compilerOptions.css = cssOptionValue;
|
|
30
|
+
} else {
|
|
31
|
+
compilerOptions.css = 'injected';
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
name: 'ripple',
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Returns CSS contents for a file, if ours
|
|
39
|
+
*/
|
|
40
|
+
load(id) {
|
|
41
|
+
return cache_emit.get(id) || null;
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Transforms a `.ripple` file into a `.js` file.
|
|
46
|
+
* NOTE: If `emitCss`, append static `import` to virtual CSS file.
|
|
47
|
+
*/
|
|
48
|
+
async transform(code, id) {
|
|
49
|
+
if (!filter(id) || !id.endsWith('.ripple')) return null;
|
|
50
|
+
|
|
51
|
+
const extension = path.extname(id);
|
|
52
|
+
if (!~extensions.indexOf(extension)) return null;
|
|
53
|
+
|
|
54
|
+
const filename = path.relative(process.cwd(), id);
|
|
55
|
+
|
|
56
|
+
const { js, css } = await compile(code, filename, id);
|
|
57
|
+
|
|
58
|
+
if (emitCss && css && css.code) {
|
|
59
|
+
const fname = id.replace(new RegExp(`\\${extension}$`), '.css');
|
|
60
|
+
js.code += `\nimport ${JSON.stringify(fname)};\n`;
|
|
61
|
+
cache_emit.set(fname, css);
|
|
62
|
+
}
|
|
63
|
+
return js;
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ripple-ts/rollup-plugin",
|
|
3
|
+
"description": "Rollup plugin for Ripple",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"author": "Dominic Gannaway",
|
|
6
|
+
"version": "0.2.153",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "index.js",
|
|
9
|
+
"homepage": "https://ripple-ts.com",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/Ripple-TS/ripple.git",
|
|
13
|
+
"directory": "packages/rollup-plugin"
|
|
14
|
+
},
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/Ripple-TS/ripple/issues"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@rollup/pluginutils": "^4.1.0"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"rollup": "^2.33.3",
|
|
23
|
+
"source-map": "^0.7.3",
|
|
24
|
+
"uvu": "^0.5.6",
|
|
25
|
+
"ripple": "0.2.153"
|
|
26
|
+
}
|
|
27
|
+
}
|