@qubit-ltd/rollup-builder 1.8.4

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 (49) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +335 -0
  3. package/README.zh_CN.md +288 -0
  4. package/dist/rollup-builder.cjs +793 -0
  5. package/dist/rollup-builder.cjs.map +1 -0
  6. package/dist/rollup-builder.min.cjs +1 -0
  7. package/dist/rollup-builder.min.cjs.map +1 -0
  8. package/dist/rollup-builder.min.mjs +1 -0
  9. package/dist/rollup-builder.min.mjs.map +1 -0
  10. package/dist/rollup-builder.mjs +791 -0
  11. package/dist/rollup-builder.mjs.map +1 -0
  12. package/doc/api/fonts/OpenSans-Bold-webfont.eot +0 -0
  13. package/doc/api/fonts/OpenSans-Bold-webfont.svg +1838 -0
  14. package/doc/api/fonts/OpenSans-Bold-webfont.woff +0 -0
  15. package/doc/api/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
  16. package/doc/api/fonts/OpenSans-BoldItalic-webfont.svg +1838 -0
  17. package/doc/api/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
  18. package/doc/api/fonts/OpenSans-Italic-webfont.eot +0 -0
  19. package/doc/api/fonts/OpenSans-Italic-webfont.svg +1838 -0
  20. package/doc/api/fonts/OpenSans-Italic-webfont.woff +0 -0
  21. package/doc/api/fonts/OpenSans-Light-webfont.eot +0 -0
  22. package/doc/api/fonts/OpenSans-Light-webfont.svg +1839 -0
  23. package/doc/api/fonts/OpenSans-Light-webfont.woff +0 -0
  24. package/doc/api/fonts/OpenSans-LightItalic-webfont.eot +0 -0
  25. package/doc/api/fonts/OpenSans-LightItalic-webfont.svg +1843 -0
  26. package/doc/api/fonts/OpenSans-LightItalic-webfont.woff +0 -0
  27. package/doc/api/fonts/OpenSans-Regular-webfont.eot +0 -0
  28. package/doc/api/fonts/OpenSans-Regular-webfont.svg +1839 -0
  29. package/doc/api/fonts/OpenSans-Regular-webfont.woff +0 -0
  30. package/doc/api/fonts/OpenSans-Semibold-webfont.eot +0 -0
  31. package/doc/api/fonts/OpenSans-Semibold-webfont.svg +1838 -0
  32. package/doc/api/fonts/OpenSans-Semibold-webfont.ttf +0 -0
  33. package/doc/api/fonts/OpenSans-Semibold-webfont.woff +0 -0
  34. package/doc/api/fonts/OpenSans-SemiboldItalic-webfont.eot +0 -0
  35. package/doc/api/fonts/OpenSans-SemiboldItalic-webfont.svg +1838 -0
  36. package/doc/api/fonts/OpenSans-SemiboldItalic-webfont.ttf +0 -0
  37. package/doc/api/fonts/OpenSans-SemiboldItalic-webfont.woff +0 -0
  38. package/doc/api/global.html +2913 -0
  39. package/doc/api/index.html +418 -0
  40. package/doc/api/scripts/linenumber.js +34 -0
  41. package/doc/api/scripts/prettify/Apache-License-2.0.txt +202 -0
  42. package/doc/api/scripts/prettify/lang-css.js +2 -0
  43. package/doc/api/scripts/prettify/prettify.js +28 -0
  44. package/doc/api/styles/jsdoc-default.css +699 -0
  45. package/doc/api/styles/prettify-jsdoc.css +120 -0
  46. package/doc/api/styles/prettify-tomorrow.css +141 -0
  47. package/doc/rollup-builder.min.visualization.html +4842 -0
  48. package/doc/rollup-builder.visualization.html +4842 -0
  49. package/package.json +85 -0
@@ -0,0 +1,418 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <title>Home - Documentation</title>
7
+
8
+ <script src="scripts/prettify/prettify.js"></script>
9
+ <script src="scripts/prettify/lang-css.js"></script>
10
+ <!--[if lt IE 9]>
11
+ <script src="https://cdn.bootcdn.net/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
12
+ <![endif]-->
13
+ <link type="text/css" rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/ionicons/2.0.1/css/ionicons.min.css">
14
+ <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
15
+ <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
16
+ </head>
17
+ <body>
18
+
19
+ <input type="checkbox" id="nav-trigger" class="nav-trigger" />
20
+ <label for="nav-trigger" class="navicon-button x">
21
+ <div class="navicon"></div>
22
+ </label>
23
+
24
+ <label for="nav-trigger" class="overlay"></label>
25
+
26
+ <nav>
27
+ <li class="nav-link nav-home-link"><a href="index.html">Home</a></li><li class="nav-heading"><a href="global.html">Globals</a></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#configAliasPlugin">configAliasPlugin</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#configAnalyzerPlugin">configAnalyzerPlugin</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#configBabelPlugin">configBabelPlugin</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#configCommonJsPlugin">configCommonJsPlugin</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#configNodeResolvePlugin">configNodeResolvePlugin</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#configTerserPlugin">configTerserPlugin</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#configVisualizerPlugin">configVisualizerPlugin</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#getRollupExternal">getRollupExternal</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#getRollupOutput">getRollupOutput</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#getRollupPlugins">getRollupPlugins</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#rollupBuilder">rollupBuilder</a></span></li>
28
+ </nav>
29
+
30
+ <div id="main">
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+
50
+ <section class="readme">
51
+ <article><h1>Rollup Builder</h1>
52
+ <p><a href="https://npmjs.com/package/@haixing_hu/rollup-builder"><img src="https://img.shields.io/npm/v/@haixing_hu/rollup-builder.svg" alt="npm package"></a>
53
+ <a href="https://www.apache.org/licenses/LICENSE-2.0"><img src="https://img.shields.io/badge/License-Apache-blue.svg" alt="License"></a>
54
+ <a href="README.zh_CN.md"><img src="https://img.shields.io/badge/%E6%96%87%E6%A1%A3-%E4%B8%AD%E6%96%87%E7%89%88-blue.svg" alt="中文文档"></a>
55
+ <a href="https://dl.circleci.com/status-badge/redirect/gh/Haixing-Hu/rollup-builder/tree/master"><img src="https://dl.circleci.com/status-badge/img/gh/Haixing-Hu/rollup-builder/tree/master.svg?style=shield" alt="CircleCI"></a></p>
56
+ <p><code>rollup-builder</code> provides a utility function to simplify the process of building
57
+ JavaScript libraries using the <a href="https://rollupjs.org/">Rollup</a> bundler. It allows you to generate various
58
+ formats such as CommonJS (CJS), ES Module (ESM), and Universal Module Definition
59
+ (UMD), and gives you the option to choose whether to perform code minification.</p>
60
+ <h2>Table of Contents</h2>
61
+ <ul>
62
+ <li><a href="#features">Features</a></li>
63
+ <li><a href="#installation">Installation</a></li>
64
+ <li><a href="#usage">Usage</a></li>
65
+ <li><a href="#configuration">Configuration Options</a></li>
66
+ <li><a href="#mix-default-named">Mixing Default and Named Exports</a></li>
67
+ <li><a href="#contributions">Contributions</a></li>
68
+ <li><a href="#license">License</a></li>
69
+ </ul>
70
+ <h2><span id="features">Features</span></h2>
71
+ <ul>
72
+ <li>Build JavaScript libraries in multiple formats, making them compatible with a
73
+ variety of environments.</li>
74
+ <li>Minify your library for production use with ease.</li>
75
+ <li>Automatic generation of sourcemaps for debugging.</li>
76
+ <li>Configure the library's format, filename, and more using simple options.</li>
77
+ <li>You can <a href="#mix-default-named">mix default and named exports</a> in ESM modules and
78
+ the <a href="https://rollupjs.org/">Rollup</a> will generate code in CJS or UMD format that compatible with both
79
+ CommonJS and ES6.</li>
80
+ <li>Highly customizable using <a href="https://rollupjs.org/">Rollup</a> plugins and custom configurations.</li>
81
+ </ul>
82
+ <h2><span id="installation">Installation</span></h2>
83
+ <p>You can install <code>rollup-builder</code> as a development dependency using <code>npm</code> or <code>yarn</code>:</p>
84
+ <pre class="prettyprint source lang-bash"><code>npm install @haixing_hu/rollup-builder --save-dev
85
+ # or
86
+ yarn add @haixing_hu/rollup-builder --dev
87
+ </code></pre>
88
+ <h2><span id="usage">Usage</span></h2>
89
+ <ol>
90
+ <li>
91
+ <p>Create a <a href="https://rollupjs.org/">Rollup</a> configuration file (usually named <code>rollup.config.mjs</code>) and
92
+ export a function that defines the library's build options. You can use the
93
+ provided <code>rollupBuilder</code> function to streamline this process.</p>
94
+ <p>Example <code>rollup.config.mjs</code>:</p>
95
+ <pre class="prettyprint source lang-js"><code>import rollupBuilder from '@haixing_hu/rollup-builder';
96
+
97
+ export default rollupBuilder('MyLibrary', import.meta.url);
98
+ </code></pre>
99
+ </li>
100
+ <li>
101
+ <p>Customize the <code>rollup.config.mjs</code> file to match your library's specific
102
+ requirements. You can specify the input file, formats, filename prefix, and
103
+ other options. Refer to the <a href="#configuration">Configuration Options</a> section
104
+ for more details.</p>
105
+ <p>Example <code>rollup.config.mjs</code>:</p>
106
+ <pre class="prettyprint source lang-js"><code>import rollupBuilder from '@haixing_hu/rollup-builder';
107
+
108
+ export default rollupBuilder('MyLibrary', import.meta.url, {
109
+ formats: ['cjs', 'esm'],
110
+ minify: true,
111
+ // Customize additional options as needed.
112
+ });
113
+ </code></pre>
114
+ </li>
115
+ <li>
116
+ <p>Run the <a href="https://rollupjs.org/">Rollup</a> build process using the following command:</p>
117
+ <pre class="prettyprint source lang-bash"><code>rollup -c rollup.config.mjs
118
+ </code></pre>
119
+ </li>
120
+ <li>
121
+ <p>The resulting library files will be placed in the <code>dist</code> directory, following
122
+ the format you specified. For example, if you specified <code>formats: ['cjs', 'esm']</code>,
123
+ the following files will be generated:</p>
124
+ <pre class="prettyprint source lang-bash"><code> dist/my-library.cjs.js
125
+ dist/my-library.cjs.min.js
126
+ dist/my-library.esm.mjs
127
+ dist/my-library.esm.min.mjs
128
+ </code></pre>
129
+ </li>
130
+ <li>
131
+ <p>You should modify your <code>package.json</code> file to specify the entry point of your
132
+ library. For example, if you specified <code>formats: ['cjs', 'esm']</code>, you should
133
+ add the following lines to your <code>package.json</code> file:</p>
134
+ <pre class="prettyprint source lang-json"><code>{
135
+ &quot;main&quot;: &quot;dist/my-library.cjs.min.js&quot;,
136
+ &quot;module&quot;: &quot;dist/my-library.esm.min.mjs&quot;,
137
+ &quot;exports&quot;: {
138
+ &quot;.&quot;: {
139
+ &quot;require&quot;: &quot;./dist/my-library.cjs.min.js&quot;,
140
+ &quot;import&quot;: &quot;./dist/my-library.esm.min.mjs&quot;
141
+ }
142
+ }
143
+ }
144
+ </code></pre>
145
+ </li>
146
+ <li>
147
+ <p>You should add the following dev dependencies to your library:</p>
148
+ <pre class="prettyprint source lang-bash"><code>yarn add --dev @babel/core @babel/plugin-transform-runtime @babel/preset-env \
149
+ @rollup/plugin-alias @rollup/plugin-babel @rollup/plugin-commonjs \
150
+ @rollup/plugin-node-resolve @rollup/plugin-terser rollup rollup-plugin-analyzer
151
+ </code></pre>
152
+ <p>or</p>
153
+ <pre class="prettyprint source lang-bash"><code>npm install -D @babel/core @babel/plugin-transform-runtime @babel/preset-env \
154
+ @rollup/plugin-alias @rollup/plugin-babel @rollup/plugin-commonjs \
155
+ @rollup/plugin-node-resolve @rollup/plugin-terser rollup rollup-plugin-analyzer
156
+ </code></pre>
157
+ </li>
158
+ </ol>
159
+ <h2><span id="configuration">Configuration Options</span></h2>
160
+ <ul>
161
+ <li><code>libraryName: string</code>: The name of your library (used in the UMD format).</li>
162
+ <li><code>importMetaUrl: string</code>: The <code>import.meta.url</code> of the caller module.</li>
163
+ <li><code>options: object</code>: Additional build options, including:
164
+ <ul>
165
+ <li>
166
+ <p><code>debug: boolean</code>: Whether to print debug information. If this field is not
167
+ specified, the default value is <code>false</code>.</p>
168
+ </li>
169
+ <li>
170
+ <p><code>formats: [string]</code>: An array of formats to build. It can be an array
171
+ of the following values:</p>
172
+ <ul>
173
+ <li><code>'cjs'</code>: the CommonJS format.</li>
174
+ <li><code>'umd'</code>: the UMD format.</li>
175
+ <li><code>'esm'</code>: the ES module format.</li>
176
+ </ul>
177
+ <p>If this field is not specified, the default value is <code>['cjs', 'esm']</code>.</p>
178
+ </li>
179
+ <li>
180
+ <p><code>exports: string</code>: the export mode to use. It can be one of the following
181
+ values:</p>
182
+ <ul>
183
+ <li><code>'auto'</code>: automatically guesses your intentions based on what the
184
+ input module exports.</li>
185
+ <li><code>'default'</code>: if you are only exporting one thing using
186
+ <code>export default ...</code>; note that this can cause issues when generating
187
+ CommonJS output that is meant to be interchangeable with ESM output.</li>
188
+ <li><code>'named'</code>: if you are using named exports.</li>
189
+ <li><code>'none'</code>: if you are not exporting anything (e.g. you are building an
190
+ app, not a library)</li>
191
+ <li><code>'mixed'</code>: if you are using named exports mixed with a default export.
192
+ Note that this is not a standard exports mode officially supported by
193
+ <a href="https://rollupjs.org/">Rollup</a>, instead, it is an additional mode add by this library.
194
+ Refer to the <a href="#mix-default-named">Mixing Default and Named Exports</a> for
195
+ more details.</li>
196
+ </ul>
197
+ <p>If this field is not specified, the default value is <code>'auto'</code>.</p>
198
+ </li>
199
+ <li>
200
+ <p><code>nodeEnv: string</code>: The <code>NODE_ENV</code> environment variable. If this field is
201
+ not specified, the default value is <code>process.env.NODE_ENV</code>.</p>
202
+ </li>
203
+ <li>
204
+ <p><code>minify: boolean</code>: Whether to minify the code. If this field is not
205
+ specified, the default value will be <code>true</code> for production environment,
206
+ and <code>false</code> otherwise.</p>
207
+ </li>
208
+ <li>
209
+ <p><code>sourcemap: boolean</code>: Whether to generate sourcemaps. If this field is not
210
+ specified, the default value is <code>true</code>.</p>
211
+ </li>
212
+ <li>
213
+ <p><code>input: string</code>: The input file of the library. If this field is not
214
+ specified, the default value is <code>src/index.js</code>.</p>
215
+ </li>
216
+ <li>
217
+ <p><code>outputDir: string</code>: The output directory of the library. If this field
218
+ is not specified, the default value is <code>dist</code>.</p>
219
+ </li>
220
+ <li>
221
+ <p><code>filenamePrefix: string</code>: The prefix for the output filename. If this
222
+ field is not specified, the default value the dash-case of the library
223
+ name.</p>
224
+ </li>
225
+ <li>
226
+ <p><code>externals: [string]</code>: the additional external packages, each can be
227
+ specified with either a string or a regular expression. If this field is
228
+ not specified, the default value is an empty array.</p>
229
+ </li>
230
+ <li>
231
+ <p><code>useAliasPlugin: boolean</code>: whether to use the <code>@rollup/plugin-alias</code>
232
+ plugin. If this field is not specified, the default value is <code>true</code>.</p>
233
+ </li>
234
+ <li>
235
+ <p><code>aliasPluginOptions: object</code>: the options for the <code>@rollup/plugin-alias</code>
236
+ plugin. If this field is not specified, the default value is:</p>
237
+ <pre class="prettyprint source lang-js"><code>{
238
+ entries: {
239
+ 'src': fileURLToPath(new URL('src', importMetaUrl)),
240
+ },
241
+ }
242
+ </code></pre>
243
+ </li>
244
+ <li>
245
+ <p><code>useNodeResolvePlugin: boolean</code>: whether to use the <code>@rollup/plugin-node-resolve</code>
246
+ plugin. If this field is not specified, the default value is <code>true</code>.</p>
247
+ </li>
248
+ <li>
249
+ <p><code>nodeResolvePluginOptions: object</code>: the options for the <code>@rollup/plugin-node-resolve</code>
250
+ plugin. If this field is not specified, the default value is: <code>{}</code>.</p>
251
+ </li>
252
+ <li>
253
+ <p><code>useCommonjsPlugin: boolean</code>: whether to use the <code>@rollup/plugin-commonjs</code> plugin.
254
+ If this field is not specified, the default value is <code>true</code>.</p>
255
+ </li>
256
+ <li>
257
+ <p><code>commonjsPluginOptions: object</code>: the options for the <code>@rollup/plugin-commonjs</code>
258
+ plugin. If this field is not specified, the default value is:</p>
259
+ <pre class="prettyprint source lang-js"><code>{
260
+ include: ['node_modules/**']
261
+ }
262
+ </code></pre>
263
+ </li>
264
+ <li>
265
+ <p><code>useBabelPlugin: boolean</code>: whether to use the <code>@rollup/plugin-babel</code> plugin.
266
+ If this field is not specified, the default value is <code>true</code>.</p>
267
+ </li>
268
+ <li>
269
+ <p><code>babelPluginOptions: object</code>: the options for the <code>@rollup/plugin-babel</code> plugin.
270
+ If this field is not specified, the default value is:</p>
271
+ <pre class="prettyprint source lang-js"><code>{
272
+ babelHelpers: 'runtime',
273
+ exclude: ['node_modules/**'],
274
+ presets: [
275
+ '@babel/preset-env',
276
+ ],
277
+ plugins: [
278
+ '@babel/plugin-transform-runtime',
279
+ ]
280
+ }
281
+ </code></pre>
282
+ <p>Note that if use the <code>@rollup/plugin-babel</code> plugin, you can also specify
283
+ the configuration of Babel in the standard Babel configuration files,
284
+ such as <code>babel.config.js</code>, <code>.babelrc</code>, etc.</p>
285
+ </li>
286
+ <li>
287
+ <p><code>terserOptions: object</code>: the options for the <code>@rollup/plugin-terser</code> plugin.
288
+ If this field is not specified, the default value is: <code>{}</code>. Whether
289
+ to use the <code>@rollup/plugin-terser</code> plugin depends on the <code>minify</code>
290
+ field of the options or the <code>NODE_ENV</code> environment variable.</p>
291
+ </li>
292
+ <li>
293
+ <p><code>useAnalyzerPlugin: boolean</code>: whether to use the <code>rollup-plugin-analyzer</code> plugin.
294
+ If this field is not specified, the default value is <code>true</code>.</p>
295
+ </li>
296
+ <li>
297
+ <p><code>analyzerOptions: object</code>: the options for the <code>rollup-plugin-analyzer</code> plugin.
298
+ If this field is not specified, the default value is:</p>
299
+ <pre class="prettyprint source lang-js"><code>{
300
+ hideDeps: true,
301
+ limit: 0,
302
+ summaryOnly: true,
303
+ }
304
+ </code></pre>
305
+ </li>
306
+ <li>
307
+ <p><code>useVisualizerPlugin: boolean</code>: whether to use the <code>rollup-plugin-visualizer</code> plugin.
308
+ If this field is not specified, the default value is <code>true</code>.</p>
309
+ </li>
310
+ <li>
311
+ <p><code>visualizerPluginOptions: object</code>: the options for the <code>rollup-plugin-visualizer</code> plugin.
312
+ If this field is not specified, the default value is:</p>
313
+ <pre class="prettyprint source lang-js"><code>{
314
+ filename: './doc/${filenameBase}.visualization.html',
315
+ gzipSize: true,
316
+ brotliSize: true,
317
+ }
318
+ </code></pre>
319
+ <p>where the <code>filenameBase</code> is the basename of the compiled library file in the
320
+ <code>./dist</code> directory.</p>
321
+ </li>
322
+ <li>
323
+ <p><code>plugins: [object]</code>: the additional <a href="https://rollupjs.org/">Rollup</a> plugins. If this field is not
324
+ specified, the default value is an empty array.</p>
325
+ </li>
326
+ </ul>
327
+ </li>
328
+ </ul>
329
+ <h2><span id="mix-default-named">Mixing Default and Named Exports</span></h2>
330
+ <p>If an ESM module has both default export and named exports, <a href="https://rollupjs.org/">Rollup</a> cannot
331
+ handle it correctly. For example, the following is a source ESM module:</p>
332
+ <pre class="prettyprint source lang-js"><code>export { Foo, Bar };
333
+ export default Foo;
334
+ </code></pre>
335
+ <p>The rollup will translate it into the following codes:</p>
336
+ <pre class="prettyprint source lang-js"><code>exports.Foo = Foo;
337
+ exports.Bar = Bar;
338
+ exports.default = Foo;
339
+ </code></pre>
340
+ <p>However, a common-js consumer will use the module as follows:</p>
341
+ <pre class="prettyprint source lang-js"><code>const Foo = require('my-module');
342
+ </code></pre>
343
+ <p>which will cause an error. The correct usage should be</p>
344
+ <pre class="prettyprint source lang-js"><code>const Foo = require('my-module').default
345
+ </code></pre>
346
+ <p>But unfortunately, <a href="https://rollupjs.org/">Rollup</a> will translate the ESM default import as follows:</p>
347
+ <pre class="prettyprint source lang-js"><code>// source
348
+ import Foo from 'my-module';
349
+
350
+ // translated
351
+ const Foo = require('my-module');
352
+ </code></pre>
353
+ <p>Note that the above translation has no <code>.default</code> suffix, which will cause an error.</p>
354
+ <p>If you mix default and named exports in an ESM module, <a href="https://rollupjs.org/">Rollup</a> will generate
355
+ a warning message as follows:</p>
356
+ <pre class="prettyprint source lang-bash"><code>(!) Mixing named and default exports
357
+ https://rollupjs.org/configuration-options/#output-exports
358
+ The following entry modules are using named and default exports together:
359
+ src/index.js
360
+
361
+ Consumers of your bundle will have to use chunk.default to access their default export, which may not be what you want. Use `output.exports: &quot;named&quot;` to disable this warning.
362
+ </code></pre>
363
+ <p>The workaround is copied from the <a href="https://github.com/rollup/plugins/blob/master/shared/rollup.config.mjs">source code of the official rollup plugins</a>.
364
+ It makes the rollup option <code>output.exports</code> to <code>'named'</code> and adds a simple footer
365
+ statements to each <code>CJS</code> format bundle:</p>
366
+ <pre class="prettyprint source lang-js"><code>module.exports = Object.assign(exports.default, exports);
367
+ </code></pre>
368
+ <p>With this workaround, <a href="https://rollupjs.org/">Rollup</a> will transform mixed exports into the following form:</p>
369
+ <pre class="prettyprint source lang-js"><code>exports.Foo = Foo;
370
+ exports.Bar = Bar;
371
+ exports.default = Foo;
372
+ module.exports = Object.assign(exports.default, exports);
373
+ </code></pre>
374
+ <p>Thus, the caller can directly use the following methods to import the default export:</p>
375
+ <pre class="prettyprint source lang-js"><code>const Foo = require('my-module');
376
+ // or
377
+ import Foo from 'my-module';
378
+ </code></pre>
379
+ <p>See the following web pages for more details:</p>
380
+ <ul>
381
+ <li><a href="https://rollupjs.org/configuration-options/#output-exports">Rollup Configuration Options: output.exports</a></li>
382
+ <li><a href="https://github.com/rollup/rollup/issues/1961">Issue #1961: Question regarding mixing default and named exports</a></li>
383
+ <li><a href="https://stackoverflow.com/questions/58246998/mixing-default-and-named-exports-with-rollup">StackOverflow: Mixing default and named exports with Rollup</a></li>
384
+ <li><a href="https://github.com/avisek/rollup-patch-seamless-default-export">Github Repository: rollup-patch-seamless-default-export</a></li>
385
+ </ul>
386
+ <p><strong>NOTE:</strong> In order to use this feature, you must specify the <code>exports</code> option to
387
+ <code>'mixed'</code> in the <code>rollup.config.mjs</code> file, i.e.,</p>
388
+ <pre class="prettyprint source lang-js"><code>import rollupBuilder from '@haixing_hu/rollup-builder';
389
+
390
+ export default rollupBuilder('MyLibrary', import.meta.url, { exports: 'mixed' });
391
+ </code></pre>
392
+ <h2><span id="contributions">Contributions</span></h2>
393
+ <p>Contributions are welcome! If you find any issues or have suggestions for
394
+ improvements, please feel free to open an issue or create a pull request.</p>
395
+ <h2><span id="license">License</span></h2>
396
+ <p>This project is licensed under the Apache 2.0 License.
397
+ See the <a href="LICENSE">LICENSE</a> file for details.</p></article>
398
+ </section>
399
+
400
+
401
+
402
+
403
+
404
+
405
+ </div>
406
+
407
+ <br class="clear">
408
+
409
+ <footer>
410
+ Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a>
411
+ on Sun Jan 05 2025 14:08:32 GMT+0800 (China Standard Time)
412
+ using the <a href="https://github.com/Haixing-Hu/jsdoc-minami">customized Minami theme</a>.
413
+ </footer>
414
+
415
+ <script>prettyPrint();</script>
416
+ <script src="scripts/linenumber.js"></script>
417
+ </body>
418
+ </html>
@@ -0,0 +1,34 @@
1
+ ////////////////////////////////////////////////////////////////////////////////
2
+ //
3
+ // Copyright (c) 2022 - 2023.
4
+ // Haixing Hu, Qubit Co. Ltd.
5
+ //
6
+ // All rights reserved.
7
+ //
8
+ ////////////////////////////////////////////////////////////////////////////////
9
+
10
+ /*global document */
11
+ (function() {
12
+ var source = document.getElementsByClassName('prettyprint source linenums');
13
+ var i = 0;
14
+ var lineNumber = 0;
15
+ var lineId;
16
+ var lines;
17
+ var totalLines;
18
+ var anchorHash;
19
+
20
+ if (source && source[0]) {
21
+ anchorHash = document.location.hash.substring(1);
22
+ lines = source[0].getElementsByTagName('li');
23
+ totalLines = lines.length;
24
+
25
+ for (; i < totalLines; i++) {
26
+ lineNumber++;
27
+ lineId = 'line' + lineNumber;
28
+ lines[i].id = lineId;
29
+ if (lineId === anchorHash) {
30
+ lines[i].className += ' selected';
31
+ }
32
+ }
33
+ }
34
+ })();
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.