@eik/esbuild-plugin 1.1.48 → 1.1.50

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.
Files changed (2) hide show
  1. package/README.md +25 -52
  2. package/package.json +12 -10
package/README.md CHANGED
@@ -1,11 +1,11 @@
1
1
  # @eik/esbuild-plugin
2
2
 
3
- ESBuild plugin for loading import maps from a [Eik server](https://eik.dev/) and applying the mapping to ECMAScript modules in preparation for upload to the same server.
3
+ [esbuild](https://esbuild.github.io/) plugin for [build-time import mapping with Eik](https://eik.dev/docs/guides/esbuild).
4
4
 
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- $ npm install @eik/esbuild-plugin
8
+ npm install --save-dev esbuild @eik/esbuild-plugin
9
9
  ```
10
10
 
11
11
  ## Usage
@@ -14,35 +14,30 @@ $ npm install @eik/esbuild-plugin
14
14
  import * as eik from "@eik/esbuild-plugin";
15
15
  import esbuild from "esbuild";
16
16
 
17
- await eik.load();
18
-
19
- await esbuild.build({
20
- entryPoints: ["./src/app.js"],
21
- bundle: true,
17
+ const options = /** @type {esbuild.BuildOptions}*/ ({
18
+ entryPoints: ["./src/index.js"],
19
+ outdir: "./public",
22
20
  format: "esm",
23
- target: ["esnext"],
24
- plugins: [eik.plugin()],
21
+ platform: "browser",
22
+ target: ["es2017"],
23
+ bundle: true,
24
+ sourcemap: true,
25
25
  });
26
- ```
27
-
28
- ## Description
29
26
 
30
- This plugin will read a local Eik config file (`eik.json`) and download the import maps from the Eik server defined in the config. The downloaded import maps will then be applied to the ECMAScript modules being processed.
31
-
32
- ### Plugin result
33
-
34
- Bundles will have bare imports mapped to absolute URLs.
35
-
36
- Ie. Something like this...
37
-
38
- ```js
39
- import { LitElement, html, css } from "lit-element";
40
- ```
41
-
42
- Will be mapped to something like this...
43
-
44
- ```js
45
- import { LitElement, html, css } from "https://cdn.eik.dev/lit-element/v2";
27
+ const watch = process.argv.includes("--dev");
28
+ if (watch) {
29
+ let ctx = await esbuild.context(options);
30
+ await ctx.watch();
31
+ console.log("[esbuild] watching...");
32
+ } else {
33
+ // Use the Eik plugin to to import mapping for the production build
34
+ // Load the import maps listed in eik.json from the Eik server
35
+ await eik.load();
36
+ await esbuild.build({
37
+ ...options,
38
+ plugins: [eik.plugin()],
39
+ });
40
+ }
46
41
  ```
47
42
 
48
43
  ## API
@@ -117,7 +112,7 @@ Any import map URLs in `eik.json` will be loaded first, then merged with (and ov
117
112
 
118
113
  ### .plugin()
119
114
 
120
- Returns the plugin which will apply the loaded import maps during build. The returned plugin should be appended to the ESBuild plugin array.
115
+ Returns the plugin which will apply the loaded import maps during build. The returned plugin should be appended to the esbuild plugin array.
121
116
 
122
117
  ```js
123
118
  import * as eik from "@eik/esbuild-plugin";
@@ -132,7 +127,7 @@ esbuild
132
127
  format: "esm",
133
128
  minify: false,
134
129
  sourcemap: false,
135
- target: ["chrome58", "firefox57", "safari11", "edge16"],
130
+ target: ["es2017"],
136
131
  plugins: [eik.plugin()],
137
132
  outfile: "out.js",
138
133
  })
@@ -142,25 +137,3 @@ esbuild
142
137
  ### .clear()
143
138
 
144
139
  Clears the loaded import maps from the plugins internal cache.
145
-
146
- ## License
147
-
148
- Copyright (c) 2020 Finn.no
149
-
150
- Permission is hereby granted, free of charge, to any person obtaining a copy
151
- of this software and associated documentation files (the "Software"), to deal
152
- in the Software without restriction, including without limitation the rights
153
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
154
- copies of the Software, and to permit persons to whom the Software is
155
- furnished to do so, subject to the following conditions:
156
-
157
- The above copyright notice and this permission notice shall be included in all
158
- copies or substantial portions of the Software.
159
-
160
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
161
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
162
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
163
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
164
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
165
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
166
- SOFTWARE.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@eik/esbuild-plugin",
3
- "version": "1.1.48",
4
- "description": "ESBuild plugin for loading import maps from a Eik server and applying the mapping to ECMAScript modules in preparation for upload to the same server.",
3
+ "version": "1.1.50",
4
+ "description": "esbuild 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
5
  "type": "module",
6
6
  "main": "./src/plugin.js",
7
7
  "types": "./types/plugin.d.ts",
@@ -10,6 +10,7 @@
10
10
  "types"
11
11
  ],
12
12
  "scripts": {
13
+ "clean": "rimraf .tap node_modules types",
13
14
  "test": "tap --disable-coverage --allow-empty-coverage",
14
15
  "lint": "eslint .",
15
16
  "lint:fix": "npm run lint -- --fix",
@@ -39,23 +40,24 @@
39
40
  },
40
41
  "homepage": "https://github.com/eik-lib/esbuild-plugin#readme",
41
42
  "devDependencies": {
42
- "@eik/eslint-config": "1.0.2",
43
+ "@eik/eslint-config": "1.0.10",
43
44
  "@eik/prettier-config": "1.0.1",
44
45
  "@eik/semantic-release-config": "1.0.0",
45
46
  "@eik/typescript-config": "1.0.0",
46
47
  "@types/esbuild-plugin-import-map": "0.0.3",
47
- "esbuild": "0.23.0",
48
- "eslint": "9.8.0",
48
+ "esbuild": "0.24.2",
49
+ "eslint": "9.16.0",
49
50
  "fastify": "4.28.1",
50
- "npm-run-all": "4.1.5",
51
- "prettier": "3.3.3",
52
- "semantic-release": "24.0.0",
51
+ "npm-run-all2": "5.0.2",
52
+ "prettier": "3.4.1",
53
+ "rimraf": "6.0.1",
54
+ "semantic-release": "24.2.3",
53
55
  "tap": "20.0.3",
54
- "typescript": "5.5.4"
56
+ "typescript": "5.7.2"
55
57
  },
56
58
  "dependencies": {
57
59
  "@eik/common": "3.0.1",
58
60
  "esbuild-plugin-import-map": "2.1.0",
59
- "undici": "5.28.4"
61
+ "undici": "5.29.0"
60
62
  }
61
63
  }