@open-xchange/vite-plugin-es-decorators 1.2.1 → 1.4.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/CHANGELOG.md +10 -0
- package/README.md +1 -29
- package/dist/index.d.mts +14 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +34 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +4 -40
- package/dist/index.d.ts +0 -9
- package/dist/index.js +0 -36
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## `1.4.0` – 2026-Apr-20
|
|
4
|
+
|
|
5
|
+
### _PACKAGE DEPRECATED_
|
|
6
|
+
|
|
7
|
+
Use [@open-xchange/rolldown-plugin-es-decorators](https://www.npmjs.com/package/@open-xchange/rolldown-plugin-es-decorators) instead.
|
|
8
|
+
|
|
9
|
+
## `1.3.0` – 2026-Apr-09
|
|
10
|
+
|
|
11
|
+
- chore: switch to `tsdown` for building packages
|
|
12
|
+
|
|
3
13
|
## `1.2.1` – 2026-Mar-17
|
|
4
14
|
|
|
5
15
|
- fixed: missing dependency
|
package/README.md
CHANGED
|
@@ -1,31 +1,3 @@
|
|
|
1
1
|
# @open-xchange/vite-plugin-es-decorators
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Supports Vite 6 and 7 (with rollup/esbuild), and Vite 8 (with rolldown/oxc).
|
|
6
|
-
|
|
7
|
-
## Usage
|
|
8
|
-
|
|
9
|
-
Add the plugin to your Vite configuration:
|
|
10
|
-
|
|
11
|
-
```ts
|
|
12
|
-
// vite.config.ts
|
|
13
|
-
|
|
14
|
-
import { defineConfig } from 'vite' // or 'vitest/config'
|
|
15
|
-
import decoratorsPlugin from '@open-xchange/vite-plugin-es-decorators'
|
|
16
|
-
|
|
17
|
-
export default defineConfig(() => {
|
|
18
|
-
|
|
19
|
-
// ...
|
|
20
|
-
|
|
21
|
-
plugins: [
|
|
22
|
-
// ...
|
|
23
|
-
|
|
24
|
-
decoratorsPlugin(),
|
|
25
|
-
],
|
|
26
|
-
})
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
The plugin will detect the version of Vite currently used and will configure the appropriate Babel plugin ([vite-plugin-babel](https://www.npmjs.com/package/vite-plugin-babel) for Vite 7 and less with rollup/esbuild, or [@rolldown/plugin-babel](https://www.npmjs.com/package/@rolldown/plugin-babel) for Vite 8 and up with rolldown/oxc).
|
|
30
|
-
|
|
31
|
-
Vite will then send all source files to the Babel parser which will transpile ES decorators using the plugin [@babel/plugin-proposal-decorators](https://babeljs.io/docs/babel-plugin-proposal-decorators).
|
|
3
|
+
_Package is deprecated._ Use [@open-xchange/rolldown-plugin-es-decorators](https://www.npmjs.com/package/@open-xchange/rolldown-plugin-es-decorators) instead.
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Plugin } from "vite";
|
|
2
|
+
|
|
3
|
+
//#region src/index.d.ts
|
|
4
|
+
declare const PROJECT_NAME = "@open-xchange/vite-plugin-es-decorators";
|
|
5
|
+
/**
|
|
6
|
+
* Vite plugin that adds support for native ES decorators in JS source files.
|
|
7
|
+
*
|
|
8
|
+
* @returns
|
|
9
|
+
* The Vite plugin object.
|
|
10
|
+
*/
|
|
11
|
+
declare function vitePluginEsDecorators(): Promise<Plugin>;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { PROJECT_NAME, vitePluginEsDecorators as default };
|
|
14
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;cAOa,YAAA;;AAAb;;;;;iBAY8B,sBAAA,CAAA,GAA0B,OAAA,CAAQ,MAAA"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { version } from "vite";
|
|
2
|
+
import vitePluginBabel from "vite-plugin-babel";
|
|
3
|
+
import rolldownPluginBabel from "@rolldown/plugin-babel";
|
|
4
|
+
//#region src/index.ts
|
|
5
|
+
const PROJECT_NAME = "@open-xchange/vite-plugin-es-decorators";
|
|
6
|
+
const VITE_VERSION = parseInt(version.split(".")[0], 10);
|
|
7
|
+
/**
|
|
8
|
+
* Vite plugin that adds support for native ES decorators in JS source files.
|
|
9
|
+
*
|
|
10
|
+
* @returns
|
|
11
|
+
* The Vite plugin object.
|
|
12
|
+
*/
|
|
13
|
+
async function vitePluginEsDecorators() {
|
|
14
|
+
const plugin = { name: PROJECT_NAME };
|
|
15
|
+
const babelPlugins = [["@babel/plugin-proposal-decorators", { version: "2023-11" }]];
|
|
16
|
+
if (VITE_VERSION >= 8) Object.assign(plugin, await rolldownPluginBabel({ presets: [{
|
|
17
|
+
preset: () => ({ plugins: babelPlugins }),
|
|
18
|
+
rolldown: { filter: { code: "@" } }
|
|
19
|
+
}] }));
|
|
20
|
+
else {
|
|
21
|
+
const babelPlugin = vitePluginBabel({ babelConfig: {
|
|
22
|
+
babelrc: false,
|
|
23
|
+
configFile: false,
|
|
24
|
+
plugins: babelPlugins
|
|
25
|
+
} });
|
|
26
|
+
const config = babelPlugin.config;
|
|
27
|
+
Object.assign(plugin, babelPlugin, { config: () => Object.assign(config(), { esbuild: { target: "es2022" } }) });
|
|
28
|
+
}
|
|
29
|
+
return plugin;
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
export { PROJECT_NAME, vitePluginEsDecorators as default };
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["\nimport { type Plugin, type UserConfig, version } from 'vite'\nimport vitePluginBabel from 'vite-plugin-babel'\nimport rolldownPluginBabel from '@rolldown/plugin-babel'\n\n// constants ==================================================================\n\nexport const PROJECT_NAME = '@open-xchange/vite-plugin-es-decorators'\n\nconst VITE_VERSION = parseInt(version.split('.')[0], 10)\n\n// plugin =====================================================================\n\n/**\n * Vite plugin that adds support for native ES decorators in JS source files.\n *\n * @returns\n * The Vite plugin object.\n */\nexport default async function vitePluginEsDecorators(): Promise<Plugin> {\n\n const plugin: Plugin = { name: PROJECT_NAME }\n const babelPlugins = [['@babel/plugin-proposal-decorators', { version: '2023-11' }]]\n\n if (VITE_VERSION >= 8) {\n Object.assign(plugin, await rolldownPluginBabel({\n presets: [{\n preset: () => ({ plugins: babelPlugins }),\n // only for source files with decorators\n rolldown: { filter: { code: '@' } },\n }],\n }))\n } else {\n const babelPlugin = vitePluginBabel({\n babelConfig: { babelrc: false, configFile: false, plugins: babelPlugins },\n })\n const config = babelPlugin.config as () => UserConfig\n Object.assign(plugin, babelPlugin, {\n config: () => Object.assign(config(), { esbuild: { target: 'es2022' } }),\n })\n }\n\n return plugin\n}\n"],"mappings":";;;;AAOA,MAAa,eAAe;AAE5B,MAAM,eAAe,SAAS,QAAQ,MAAM,IAAI,CAAC,IAAI,GAAG;;;;;;;AAUxD,eAA8B,yBAA0C;CAEtE,MAAM,SAAiB,EAAE,MAAM,cAAc;CAC7C,MAAM,eAAe,CAAC,CAAC,qCAAqC,EAAE,SAAS,WAAW,CAAC,CAAC;AAEpF,KAAI,gBAAgB,EAClB,QAAO,OAAO,QAAQ,MAAM,oBAAoB,EAC9C,SAAS,CAAC;EACR,eAAe,EAAE,SAAS,cAAc;EAExC,UAAU,EAAE,QAAQ,EAAE,MAAM,KAAK,EAAE;EACpC,CAAC,EACH,CAAC,CAAC;MACE;EACL,MAAM,cAAc,gBAAgB,EAClC,aAAa;GAAE,SAAS;GAAO,YAAY;GAAO,SAAS;GAAc,EAC1E,CAAC;EACF,MAAM,SAAS,YAAY;AAC3B,SAAO,OAAO,QAAQ,aAAa,EACjC,cAAc,OAAO,OAAO,QAAQ,EAAE,EAAE,SAAS,EAAE,QAAQ,UAAU,EAAE,CAAC,EACzE,CAAC;;AAGJ,QAAO"}
|
package/package.json
CHANGED
|
@@ -1,47 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-xchange/vite-plugin-es-decorators",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Vite plugin that adds support for native ES decorators
|
|
3
|
+
"version": "1.4.0",
|
|
4
|
+
"description": "Vite plugin that adds support for native ES decorators",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "https://gitlab.open-xchange.com/fspd/commons/plugins",
|
|
7
|
+
"url": "git+https://gitlab.open-xchange.com/fspd/commons/plugins.git",
|
|
8
8
|
"directory": "packages/vite-plugin-es-decorators"
|
|
9
9
|
},
|
|
10
|
-
"license": "MIT"
|
|
11
|
-
"engines": {
|
|
12
|
-
"node": ">=20.18"
|
|
13
|
-
},
|
|
14
|
-
"type": "module",
|
|
15
|
-
"exports": "./dist/index.js",
|
|
16
|
-
"files": [
|
|
17
|
-
"dist",
|
|
18
|
-
"CHANGELOG.*"
|
|
19
|
-
],
|
|
20
|
-
"dependencies": {
|
|
21
|
-
"@babel/core": "^7.29.0",
|
|
22
|
-
"@babel/plugin-proposal-decorators": "^7.29.0",
|
|
23
|
-
"@rolldown/plugin-babel": "^0.2.1",
|
|
24
|
-
"vite-plugin-babel": "^1.5.1"
|
|
25
|
-
},
|
|
26
|
-
"devDependencies": {
|
|
27
|
-
"@types/babel__core": "^7.20.5",
|
|
28
|
-
"@vitest/coverage-v8": "^4.1.0",
|
|
29
|
-
"vite": "^8.0.0",
|
|
30
|
-
"vite-v6": "npm:vite@^6.4.1",
|
|
31
|
-
"vite-v7": "npm:vite@^7.3.1",
|
|
32
|
-
"vite-v8": "npm:vite@^8.0.0",
|
|
33
|
-
"vitest": "^4.1.0",
|
|
34
|
-
"@open-xchange/linter-presets": "^1.18.4",
|
|
35
|
-
"@open-xchange/vitest-vite-plugin-utils": "^0.0.1"
|
|
36
|
-
},
|
|
37
|
-
"peerDependencies": {
|
|
38
|
-
"vite": "^8.0.0"
|
|
39
|
-
},
|
|
40
|
-
"scripts": {
|
|
41
|
-
"build": "pnpm clean && tsc --project src/tsconfig.json",
|
|
42
|
-
"clean": "premove dist",
|
|
43
|
-
"coverage": "vitest run --coverage",
|
|
44
|
-
"lint": "tsc && tsc --project src/tsconfig.json --noEmit && eslint .",
|
|
45
|
-
"test": "vitest run"
|
|
46
|
-
}
|
|
10
|
+
"license": "MIT"
|
|
47
11
|
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { type Plugin } from 'vite';
|
|
2
|
-
export declare const PROJECT_NAME = "@open-xchange/vite-plugin-es-decorators";
|
|
3
|
-
/**
|
|
4
|
-
* Vite plugin that adds support for native ES decorators in JS source files.
|
|
5
|
-
*
|
|
6
|
-
* @returns
|
|
7
|
-
* The Vite plugin object.
|
|
8
|
-
*/
|
|
9
|
-
export default function vitePluginEsDecorators(): Promise<Plugin>;
|
package/dist/index.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { version } from 'vite';
|
|
2
|
-
import vitePluginBabel from 'vite-plugin-babel';
|
|
3
|
-
import rolldownPluginBabel from '@rolldown/plugin-babel';
|
|
4
|
-
// constants ==================================================================
|
|
5
|
-
export const PROJECT_NAME = '@open-xchange/vite-plugin-es-decorators';
|
|
6
|
-
const VITE_VERSION = parseInt(version.split('.')[0], 10);
|
|
7
|
-
// plugin =====================================================================
|
|
8
|
-
/**
|
|
9
|
-
* Vite plugin that adds support for native ES decorators in JS source files.
|
|
10
|
-
*
|
|
11
|
-
* @returns
|
|
12
|
-
* The Vite plugin object.
|
|
13
|
-
*/
|
|
14
|
-
export default async function vitePluginEsDecorators() {
|
|
15
|
-
const plugin = { name: PROJECT_NAME };
|
|
16
|
-
const babelPlugins = [['@babel/plugin-proposal-decorators', { version: '2023-11' }]];
|
|
17
|
-
if (VITE_VERSION >= 8) {
|
|
18
|
-
Object.assign(plugin, await rolldownPluginBabel({
|
|
19
|
-
presets: [{
|
|
20
|
-
preset: () => ({ plugins: babelPlugins }),
|
|
21
|
-
// only for source files with decorators
|
|
22
|
-
rolldown: { filter: { code: '@' } },
|
|
23
|
-
}],
|
|
24
|
-
}));
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
const babelPlugin = vitePluginBabel({
|
|
28
|
-
babelConfig: { babelrc: false, configFile: false, plugins: babelPlugins },
|
|
29
|
-
});
|
|
30
|
-
const config = babelPlugin.config;
|
|
31
|
-
Object.assign(plugin, babelPlugin, {
|
|
32
|
-
config: () => Object.assign(config(), { esbuild: { target: 'es2022' } }),
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
return plugin;
|
|
36
|
-
}
|