@orgajs/rollup 1.3.0 → 1.3.2
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/index.d.ts +34 -1
- package/index.d.ts.map +1 -1
- package/index.js +45 -5
- package/package.json +10 -4
package/index.d.ts
CHANGED
|
@@ -8,8 +8,41 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export default function rollup(options?: Options | null | undefined): Plugin;
|
|
10
10
|
export type FilterPattern = import("@rollup/pluginutils").FilterPattern;
|
|
11
|
-
export type Plugin = import("rollup").Plugin;
|
|
12
11
|
export type SourceDescription = import("rollup").SourceDescription;
|
|
12
|
+
/**
|
|
13
|
+
* Plugin that is compatible with both Rollup and Vite.
|
|
14
|
+
*/
|
|
15
|
+
export type Plugin = {
|
|
16
|
+
/**
|
|
17
|
+
* The name of the plugin
|
|
18
|
+
*/
|
|
19
|
+
name: string;
|
|
20
|
+
/**
|
|
21
|
+
* Function used by Vite to set additional configuration options.
|
|
22
|
+
*/
|
|
23
|
+
config: ViteConfig;
|
|
24
|
+
/**
|
|
25
|
+
* Function to transform the source content.
|
|
26
|
+
*/
|
|
27
|
+
transform: Transform;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Callback called by Rollup and Vite to transform.
|
|
31
|
+
*/
|
|
32
|
+
export type Transform = (value: string, path: string) => Promise<SourceDescription | undefined>;
|
|
33
|
+
/**
|
|
34
|
+
* Callback called by Vite to set additional configuration options.
|
|
35
|
+
*/
|
|
36
|
+
export type ViteConfig = (config: unknown, env: ViteEnv) => undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Environment variables used by Vite.
|
|
39
|
+
*/
|
|
40
|
+
export type ViteEnv = {
|
|
41
|
+
/**
|
|
42
|
+
* Mode.
|
|
43
|
+
*/
|
|
44
|
+
mode: string;
|
|
45
|
+
};
|
|
13
46
|
/**
|
|
14
47
|
* Default configuration.
|
|
15
48
|
*/
|
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.js"],"names":[],"mappings":"AAwDA;;;;;;;GAOG;AACH,yCALW,OAAO,GAAG,IAAI,GAAG,SAAS,GAEzB,MAAM,CAwCjB;4BApGY,OAAO,qBAAqB,EAAE,aAAa;gCAC3C,OAAO,QAAQ,EAAE,iBAAiB;;;;;;;;UAGjC,MAAM;;;;YAEN,UAAU;;;;eAEV,SAAS;;;;;gCAKZ,MAAM,QAEN,MAAM,KAEJ,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC;;;;kCAKxC,OAAO,OAEP,OAAO,KAEL,SAAS;;;;;;;;UAKR,MAAM;;;;;6BAKP,IAAI,CAAC,OAAO,cAAc,EAAE,cAAc,EAAE,oBAAoB,CAAC;;;;;;;;cAKhE,aAAa;;;;cAEb,aAAa;;;;;sBAGd,cAAc,GAAG,mBAAmB"}
|
package/index.js
CHANGED
|
@@ -1,7 +1,37 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @typedef {import('@rollup/pluginutils').FilterPattern} FilterPattern
|
|
3
|
-
* @typedef {import('rollup').Plugin} Plugin
|
|
4
3
|
* @typedef {import('rollup').SourceDescription} SourceDescription
|
|
4
|
+
* @typedef Plugin
|
|
5
|
+
* Plugin that is compatible with both Rollup and Vite.
|
|
6
|
+
* @property {string} name
|
|
7
|
+
* The name of the plugin
|
|
8
|
+
* @property {ViteConfig} config
|
|
9
|
+
* Function used by Vite to set additional configuration options.
|
|
10
|
+
* @property {Transform} transform
|
|
11
|
+
* Function to transform the source content.
|
|
12
|
+
*
|
|
13
|
+
* @callback Transform
|
|
14
|
+
* Callback called by Rollup and Vite to transform.
|
|
15
|
+
* @param {string} value
|
|
16
|
+
* File contents.
|
|
17
|
+
* @param {string} path
|
|
18
|
+
* File path.
|
|
19
|
+
* @returns {Promise<SourceDescription | undefined>}
|
|
20
|
+
* Result.
|
|
21
|
+
*
|
|
22
|
+
* @callback ViteConfig
|
|
23
|
+
* Callback called by Vite to set additional configuration options.
|
|
24
|
+
* @param {unknown} config
|
|
25
|
+
* Configuration object (unused).
|
|
26
|
+
* @param {ViteEnv} env
|
|
27
|
+
* Environment variables.
|
|
28
|
+
* @returns {undefined}
|
|
29
|
+
* Nothing.
|
|
30
|
+
*
|
|
31
|
+
* @typedef ViteEnv
|
|
32
|
+
* Environment variables used by Vite.
|
|
33
|
+
* @property {string} mode
|
|
34
|
+
* Mode.
|
|
5
35
|
*/
|
|
6
36
|
|
|
7
37
|
/**
|
|
@@ -34,15 +64,25 @@ import { SourceMapGenerator } from 'source-map'
|
|
|
34
64
|
*/
|
|
35
65
|
export default function rollup(options) {
|
|
36
66
|
const { include, exclude, ...rest } = options || {}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
...rest
|
|
40
|
-
})
|
|
67
|
+
/** @type {ReturnType<typeof import('@orgajs/orgx').createProcessor>} */
|
|
68
|
+
let processor
|
|
41
69
|
const filter = createFilter(include, exclude)
|
|
42
70
|
|
|
43
71
|
return {
|
|
44
72
|
name: '@orgajs/rollup',
|
|
73
|
+
config(config, env) {
|
|
74
|
+
processor = createProcessor({
|
|
75
|
+
SourceMapGenerator,
|
|
76
|
+
development: env.mode === 'development',
|
|
77
|
+
...rest
|
|
78
|
+
})
|
|
79
|
+
},
|
|
45
80
|
async transform(value, path) {
|
|
81
|
+
processor ||= createProcessor({
|
|
82
|
+
SourceMapGenerator,
|
|
83
|
+
...rest
|
|
84
|
+
})
|
|
85
|
+
|
|
46
86
|
const file = new VFile({ value, path })
|
|
47
87
|
|
|
48
88
|
if (file.extname === '.org' && filter(file.path)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orgajs/rollup",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "Rollup plugin for Orga",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -8,6 +8,12 @@
|
|
|
8
8
|
"index.d.ts",
|
|
9
9
|
"index.d.ts.map"
|
|
10
10
|
],
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./index.d.ts",
|
|
14
|
+
"import": "./index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
11
17
|
"type": "module",
|
|
12
18
|
"author": "Xiaoxing Hu <hi@xiaoxing.dev>",
|
|
13
19
|
"homepage": "https://orga.js.org",
|
|
@@ -22,16 +28,16 @@
|
|
|
22
28
|
"@types/react-dom": "^19.0.3",
|
|
23
29
|
"react": "^19.0.0",
|
|
24
30
|
"react-dom": "^19.0.0",
|
|
25
|
-
"rollup": "^
|
|
31
|
+
"rollup": "^4.40.0"
|
|
26
32
|
},
|
|
27
33
|
"peerDependencies": {
|
|
28
34
|
"rollup": ">=2"
|
|
29
35
|
},
|
|
30
36
|
"dependencies": {
|
|
31
|
-
"@rollup/pluginutils": "^5.
|
|
37
|
+
"@rollup/pluginutils": "^5.1.4",
|
|
32
38
|
"source-map": "^0.7.4",
|
|
33
39
|
"vfile": "^6.0.3",
|
|
34
|
-
"@orgajs/orgx": "^2.5.
|
|
40
|
+
"@orgajs/orgx": "^2.5.2"
|
|
35
41
|
},
|
|
36
42
|
"scripts": {
|
|
37
43
|
"test": "node --test test.js"
|