Skip to content

Commit 0575191

Browse files
authored
Merge pull request ghiscoding#164 from ghiscoding/feat/drop-legacy-script
feat!: drop standalone legacy browser <script> & `window` object usage
2 parents addbca1 + 8658f49 commit 0575191

File tree

7 files changed

+45
-185
lines changed

7 files changed

+45
-185
lines changed

README.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ This project was originally created by Stephen Liberty and `excel-builder-vanill
2424

2525
### Comparison to other similar libraries
2626

27-
Excel-builder-vanilla is at the minimum 7-13x times smaller than the most popular libraries (we used `Bundlephobia` to compare), excel-builder-vanilla is 19Kb gzip while [XLSX](https://bundlephobia.com/package/xlsx) is 136Kb and [ExcelJS](https://bundlephobia.com/package/exceljs) is 251Kb gzip. The reason as to why it's much smaller is very simple and relates to these 2 major differences:
27+
Excel-builder-vanilla is at the minimum 7-13x times smaller than the most popular libraries (we used `Bundlephobia` to compare), excel-builder-vanilla is 19Kb gzip while [XLSX](https://bundlephobia.com/package/xlsx) is 136Kb and [ExcelJS](https://bundlephobia.com/package/exceljs) is 251Kb gzip. The reason as to why it's much smaller is very simple and relates to these 2 major differences:
2828
- excel-builder-vanilla is ESM-Only (tree shakable) and all other libraries are still just offering CJS (CommonJS) which increases their download/install size (not tree shakable)
2929
- excel-builder-vanilla is only offering Excel export (writer) but without any reading capabilities making the project very lightweight
3030

@@ -43,12 +43,7 @@ You can also take a look at the "[Used by](#used-by)" section below to see real
4343
npm install excel-builder-vanilla
4444
```
4545

46-
The project offers 2 different build types, choose the best one depending on your use case
47-
1. **ESM**: to `import from` (_**preferred**_)
48-
2. **IIFE**: standalone script which provides `ExcelBuilder` on the `window` object
49-
50-
> [!NOTE]
51-
> ESM import is the preferred approach and IIFE might actually be removed in the future to lower download size even further.
46+
The project is now only offered as an ESM Only build
5247

5348
```ts
5449
// ESM (preferred) - npm install
@@ -57,7 +52,7 @@ import { createWorksheet } from 'excel-builder-vanilla';
5752
// IIFE - CDN
5853
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/excel-builder.iife.js"></script>
5954
<script>
60-
const worksheet = ExcelBuilder.createWorksheet(); // or window.ExcelBuilder.createWorksheet();
55+
const worksheet = ExcelBuilder.createWorksheet();
6156
</script>
6257
```
6358

@@ -110,6 +105,17 @@ The project now has only 1 small dependency which is [fflate](https://github.com
110105

111106
This modernization provides a huge decrease in the final build size, with only 1 dependency, and also offers better performance 🚀
112107

108+
## Major Changes
109+
110+
### version 3.0
111+
- initial release (forked from original `excel-builder` library)
112+
113+
### version 4.0
114+
- build as ESM-Only and drop CJS (CommonJS) build (aka `require()`)
115+
116+
### version 5.0
117+
- drop the legacy IIFE build and the use of `window` object (typically used when loading as the legacy `<script>`).
118+
113119
### Used by
114120

115121
This fork was created mostly to support Tree Shaking (ESM), provide TS Types and finally to update all project dependencies. It is used by a few other Open Source libraries that I also maintain and require Excel export:

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ or from CDN with standalone script (IIFE)
2020
```html
2121
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/excel-builder.iife.js"></script>
2222
<script>
23-
const worksheet = ExcelBuilder.createWorksheet(); // or window.ExcelBuilder.createWorksheet();
23+
const worksheet = ExcelBuilder.createWorksheet();
2424
</script>
2525
```
2626

packages/demo/src/examples/example-standalone-iife.html

Lines changed: 0 additions & 128 deletions
This file was deleted.

packages/demo/src/getting-started.html

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,15 @@ <h5>CDN</h5>
1919
<a href="https://www.jsdelivr.com/" target="__blank">jsDelivr</a>
2020
graciously provide CDNs for many JavaScript libraries including Excel-Builder-Vanilla. Just use the following CDN links.
2121
</p>
22-
<p>
23-
The project now ships as ESM-Only, if you still wish to use the legacy CommonJS (CJS) format with <code>require()</code>, then use
24-
previous 3.x version.
25-
</p>
2622

2723
<div style="background: #f7f7f7; padding: 10px">
2824
<pre>
29-
&lt;!-- (IIFE Standalone Script) Latest compiled and minified JavaScript --&gt;
30-
&lt;script type=&quot;module&quot; src=&quot;<span style="color:#880000">https://cdn.jsdelivr.net/npm/[email protected]/dist/excel-builder.iife.js</span>&quot;&gt;&lt;/script&gt;
25+
&lt;script <span style="color:#207eb1">type</span>=&quot;<span style="color:#f06605">module</span>&quot;&gt;
26+
// ESM Module import
27+
<span style="color:#cf222e">import</span> excelBuilderVanilla <span style="color:#cf222e">from</span> <span style="color:#0a3069">'https://cdn.jsdelivr.net/npm/[email protected]/+esm'</span>;
28+
&lt;/script&gt;
29+
</pre>
3130
</div>
32-
33-
<quote>
34-
<b>Note:</b> the <code>excel-builder.iife.js</code> is the only dist bundle providing the <code>ExcelBuilder</code> on the
35-
<code>window</code> object.
36-
</quote>
37-
<br />
38-
<br />
39-
<quote>
40-
You can find a Standalone Script (IIFE) example at the location
41-
<a href="https://github.com/ghiscoding/excel-builder-vanilla/blob/main/packages/demo/src/examples/example-standalone-iife.html"
42-
>examples/example-standalone-iife.html</a
43-
>
44-
</quote>
4531
</section>
4632

4733
<section>
@@ -59,16 +45,19 @@ <h5>
5945
<p>The library provides both CommonJS or ESM, see the example below:</p>
6046
<div style="background: #f7f7f7; padding: 10px">
6147
<pre>
62-
// CommonJS
63-
const { createWorkbook, Workbook } = require('excel-builder-vanilla');
64-
6548
// ESM
66-
import { createWorkbook } from 'excel-builder-vanilla';
49+
<span style="color:#cf222e">import</span> { createWorkbook } <span style="color:#cf222e">from</span> <span style="color:#00265f">'excel-builder-vanilla'</span>;
6750

6851
// use it
69-
const artistWorkbook = createWorkbook(); // or new Workbook();
70-
const albumList = artistWorkbook.createWorksheet({ name: 'Artists' });
71-
albumList.setData(this.originalData);
52+
const artistWorkbook = <span style="color:#ce8601">createWorksheet</span>(); // or new Workbook();
53+
const albumList = <span style="color:#009db2">artistWorkbook</span>.<span style="color:#ce8601">createWorksheet</span>({ <span style="color:#003c44">name</span>: <span style="color:#aa8202">'Artists'</span> })</span>;
54+
<span style="color:#009db2">albumList</span>.<span style="color:#ce8601">setData</span>(this.originalData);
7255
</pre>
56+
57+
<h5>Legacy Versions</h5>
58+
<p>
59+
The project now ships as ESM-Only, if you still wish to use the legacy <code>&lt;script&gt;</code> standalone IIFE Script on the
60+
<code>window</code> object, then use the previous 4.x version.
61+
</p>
7362
</div>
7463
</div>

packages/excel-builder-vanilla/README.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,12 @@ Available [**Live demo**](https://ghiscoding.github.io/excel-builder-vanilla/) w
1414
npm install excel-builder-vanilla
1515
```
1616

17-
The project offers 2 different bundle types, choose the best one depending on your use case:
18-
1. ESM: to `import from` (preferred)
19-
2. IIFE: standalone script with `ExcelBuilder` available on the `window` object
20-
21-
> [!NOTE]
22-
> ESM import is the preferred approach and IIFE might actually be removed in the future to lower download size even further.
17+
The project only offers 1 bundle type
18+
- ESM: to `import from` (preferred)
2319

2420
```ts
2521
// ESM - npm install
2622
import { createWorksheet } from 'excel-builder-vanilla';
27-
28-
// IIFE - CDN
29-
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/excel-builder.iife.js"></script>
30-
<script>
31-
const worksheet = ExcelBuilder.createWorksheet();
32-
</script>
3323
```
3424

3525
### Basic Usage
@@ -58,3 +48,14 @@ downloadExcelFile(artistWorkbook, 'Artist WB.xlsx');
5848
## LICENSE
5949

6050
[MIT License](https://github.com/ghiscoding/excel-builder-vanilla/blob/main/LICENSE.md)
51+
52+
## Major Changes
53+
54+
### version 3.0
55+
- initial release (forked from original `excel-builder` library)
56+
57+
### version 4.0
58+
- build as ESM-Only and drop CJS (CommonJS) build (aka `require()`)
59+
60+
### version 5.0
61+
- drop the legacy IIFE build and the use of `window` object (typically used when loading as the legacy `<script>`).

packages/excel-builder-vanilla/index.d.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.

packages/excel-builder-vanilla/vite.config.mts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@ export default defineConfig({
88
build: {
99
lib: {
1010
entry: resolve(__dirname, 'src/index.ts'),
11-
formats: ['es', 'iife'],
11+
formats: ['es'],
1212
name: 'ExcelBuilder',
1313
fileName: format => {
1414
switch (format) {
1515
case 'es':
16-
return 'index.js';
1716
default:
18-
return `excel-builder.${format}.js`;
17+
return 'index.js';
1918
}
2019
},
2120
},

0 commit comments

Comments
 (0)