@eik/vite-plugin 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Eik
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/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # @eik/vite-plugin
2
+
3
+ [Vite](https://vite.dev/) plugin for [build-time import mapping with Eik](https://eik.dev/docs/guides/vite).
4
+
5
+ This is a small wrapper around the [Rollup plugin](https://github.com/eik-lib/rollup-plugin) to make it slightly more ergonomic to use in Vite.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install --save-dev vite @eik/vite-plugin
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```js
16
+ import eik from "@eik/vite-plugin";
17
+ import { defineConfig } from "vite";
18
+
19
+ export default defineConfig({
20
+ plugins: [eik()],
21
+ build: {
22
+ rollupOptions: {
23
+ output: {
24
+ // Turn off the asset hashes. Stable file names
25
+ // make it easier to use the Eik node client:
26
+ // https://github.com/eik-lib/node-client
27
+ // Publishinig a new version on Eik gives a
28
+ // unique URL, no hash needed.
29
+ assetFileNames: "[name].[ext]",
30
+ entryFileNames: "[name].js",
31
+ chunkFileNames: "[name].js",
32
+ },
33
+ },
34
+ },
35
+ });
36
+ ```
37
+
38
+ ## Options
39
+
40
+ The options you can give to `eik()` are the same as for the Rollup plugin.
41
+ Refer to [the Rollup plugin documentation](https://github.com/eik-lib/rollup-plugin?tab=readme-ov-file#options) to see what you can do.
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@eik/vite-plugin",
3
+ "version": "1.0.0",
4
+ "description": "Vite plugin for loading import maps from a Eik server and applying the mapping to ECMAScript modules in preparation for upload to the same server.",
5
+ "type": "module",
6
+ "main": "./src/plugin.js",
7
+ "types": "./types/plugin.d.ts",
8
+ "files": [
9
+ "src",
10
+ "types"
11
+ ],
12
+ "scripts": {
13
+ "clean": "rimraf node_modules types",
14
+ "test": "node --test --experimental-test-snapshots",
15
+ "test:update": "node --test --test-update-snapshots --experimental-test-snapshots",
16
+ "lint": "eslint .",
17
+ "lint:fix": "npm run lint -- --fix",
18
+ "start": "node --experimental-modules ./example/server.mjs",
19
+ "types": "run-s types:module types:test",
20
+ "types:module": "tsc",
21
+ "types:test": "tsc --project tsconfig.test.json"
22
+ },
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+ssh://git@github.com/eik-lib/vite-plugin.git"
26
+ },
27
+ "bugs": {
28
+ "url": "https://github.com/eik-lib/vite-plugin/issues"
29
+ },
30
+ "homepage": "https://github.com/eik-lib/vite-plugin#readme",
31
+ "publishConfig": {
32
+ "access": "public"
33
+ },
34
+ "keywords": [
35
+ "vite-plugin"
36
+ ],
37
+ "author": "Finn.no",
38
+ "license": "MIT",
39
+ "dependencies": {
40
+ "@eik/rollup-plugin": "4.0.64"
41
+ },
42
+ "devDependencies": {
43
+ "@eik/eslint-config": "1.0.6",
44
+ "@eik/prettier-config": "1.0.1",
45
+ "@eik/semantic-release-config": "1.0.0",
46
+ "@eik/typescript-config": "1.0.0",
47
+ "@types/node": "22.10.2",
48
+ "eslint": "9.17.0",
49
+ "fastify": "5.2.0",
50
+ "npm-run-all2": "7.0.2",
51
+ "prettier": "3.3.3",
52
+ "rimraf": "6.0.1",
53
+ "semantic-release": "24.2.0",
54
+ "typescript": "5.7.2",
55
+ "vite": "6.0.3"
56
+ }
57
+ }
package/src/plugin.js ADDED
@@ -0,0 +1,24 @@
1
+ import rollupPlugin from "@eik/rollup-plugin";
2
+
3
+ /**
4
+ * @typedef {import('@eik/rollup-plugin').PluginOptions} EikPluginOptions
5
+ */
6
+ /**
7
+ * @typedef {import('@eik/rollup-plugin').ImportMap} EikImportMap
8
+ */
9
+
10
+ /**
11
+ * @param {EikPluginOptions} [options]
12
+ * @returns {import('vite').Plugin[]}
13
+ */
14
+ export default function eik(options) {
15
+ return [
16
+ {
17
+ ...rollupPlugin(options),
18
+ enforce: "pre",
19
+ apply: (_config, { command, isSsrBuild }) =>
20
+ // only apply plugin for client code, while building
21
+ command === "build" && !isSsrBuild,
22
+ },
23
+ ];
24
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @typedef {import('@eik/rollup-plugin').PluginOptions} EikPluginOptions
3
+ */
4
+ /**
5
+ * @typedef {import('@eik/rollup-plugin').ImportMap} EikImportMap
6
+ */
7
+ /**
8
+ * @param {EikPluginOptions} [options]
9
+ * @returns {import('vite').Plugin[]}
10
+ */
11
+ export default function eik(options?: EikPluginOptions): import("vite").Plugin[];
12
+ export type EikPluginOptions = import("@eik/rollup-plugin").PluginOptions;
13
+ export type EikImportMap = import("@eik/rollup-plugin").ImportMap;