You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/docs/src/dist-files.md
+33-10Lines changed: 33 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -121,7 +121,7 @@ Tooling in the consuming application should pick this up automatically, as it's
121
121
122
122
### `<name>.esm.dev.mjs`
123
123
124
-
This file exposes the library as an ES module. It is intended to be used during development, either with a bundler or directly in the browser via `<script type="module">` and import maps.
124
+
This file exposes the library as an ES module. It is intended to be used during development, either with a bundler or directly in the browser via `<script type="module">` and import maps (see the section about `<name>.esm-browser.prod.js` for more information about direct browser usage).
125
125
126
126
Some features of this build:
127
127
- The file is not minified, to make debugging easier.
@@ -130,6 +130,10 @@ Some features of this build:
130
130
131
131
In production, you would use either `<name>.esm-browser.prod.js` or `<name>.esm-bundler.prod.mjs` instead.
132
132
133
+
This build is suitable for use in the Vue Playground:
If your library needs to differentiate between bundlers and direct browser usage during development then you may need to adjust the build to generate more files.
134
138
135
139
### `<name>.esm-browser.prod.js`
@@ -141,18 +145,35 @@ This file is an ES module build intended to be used directly in the browser, not
It's a production build, so in real code the versions should be pinned.
155
159
160
+
An *import map* is required. While browsers do support importing directly from a URL, that wouldn't be able to resolve imports from `vue` inside the library. So, for example, this wouldn't work:
161
+
162
+
```html
163
+
<scripttype="module">
164
+
// This won't work. // [!code error]
165
+
// It won't be able to resolve 'vue' inside the imported file. // [!code error]
In particular, note the configuration in the `Import Map` tab.
176
+
156
177
Some features of this build:
157
178
- The file is minified, reducing its size. Note that Vite doesn't fully minify `esm` builds for libraries.
158
179
- The global `__DEV__` flag will be set to `false` and dead code removed. This is only relevant if you're using it in your code.
@@ -175,28 +196,30 @@ From a bundler's perspective, the only significant difference between this build
175
196
176
197
Global builds can be used without build tools, just by including a `<script>` tag in the HTML page. They are built using the IIFE format.
177
198
178
-
The library is exposed using a global variable. For example, let's imagine our package is called `@skirtle/example-lib`, it might be used something like this:
199
+
The library is exposed using a global variable. For example, the library `@skirtle/example-vue-lib` can be used something like this:
The global build of Vue creates a global variable called `Vue`, exposing `createApp`. The global build of `@skirtle/example-lib` creates a global variable called `ExampleLib`, allowing us to access `ExampleComponent`.
218
+
You can see a complete, running example in this [JSFiddle](https://jsfiddle.net/skirtle/jep2ws9a/).
219
+
220
+
The global build of Vue creates a global variable called `Vue`, exposing `createApp`. The global build of `@skirtle/example-vue-lib` creates a global variable called `ExampleVueLib`, allowing us to access `ExampleComponent`.
198
221
199
-
In production applications, the `prod` builds of both `vue` and `@skirtle/example-lib` should be used instead, and exact versions should be pinned in the URL.
222
+
In production applications, the `prod` builds of both `vue` and `@skirtle/example-vue-lib` should be used instead, and exact versions should be pinned in the URL.
200
223
201
224
The differences between the `dev` and `prod` builds are:
Copy file name to clipboardExpand all lines: packages/docs/src/introduction.md
+8Lines changed: 8 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -58,6 +58,14 @@ Currently unsupported (you'd need to configure them yourself):
58
58
- Other Vue libraries, such as VueUse, Vue Router and Pinia
59
59
- E2E testing
60
60
61
+
## Examples
62
+
63
+
You can see an example library, created using this tool, at:
64
+
65
+
-https://github.com/skirtles-code/example-vue-lib
66
+
67
+
This has been published to the npm registry as [`@skirtle/example-vue-lib`](https://www.npmjs.com/package/@skirtle/example-vue-lib).
68
+
61
69
## Prerequisites
62
70
63
71
Developing libraries to publish to npm is tricky. There is some inherent complexity to publishing packages that can't be avoided, and you're unlikely to succeed if you don't have prior experience of working with Vue, Vite and the wider ecosystem.
0 commit comments