Skip to content

Commit 5a46c2d

Browse files
authored
Merge pull request #15 from vegarringdal/build-script
chore: more modules in build
2 parents e4742e5 + cb43e66 commit 5a46c2d

File tree

5 files changed

+1053
-438
lines changed

5 files changed

+1053
-438
lines changed

README.md

+24-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ At the time of the creation of this readme, the API `customElements.define(...)`
77

88
- [Codesandbox](https://codesandbox.io/s/custom-elements-hmr-polyfill-4vd3o)
99

10-
## How to install?
10+
## How to install it?
1111

1212
- `npm install custom-elements-hmr-polyfill`
1313

@@ -99,15 +99,35 @@ Polyfills for these API's must be applied *before* you apply this polyfill.
9999

100100
None. This polyfill is 100% web standard compliant.
101101

102-
The previously existing limitation of `observedAttributes` being immutable has been polyfilled using a `MutationObserver` lately.
103-
104102
For reference see: [W3C/WhatWG standard limitation of Web Component re-definition](https://github.com/w3c/webcomponents/issues/829).
105103

104+
### Distribution formats
105+
106+
The bundled npm package contains the following formats:
107+
- IIFE (`.iife.js`)
108+
- AMD (`.amd.js`)
109+
- Common JS (`.cjs.js`)
110+
- ES Module (`.mjs`)
111+
- SystemJS (`.system.js`)
112+
- UMD (`.umd.js`)
113+
114+
You can find single file outputs in `dist/custom-elements-hmr-polyfill.*`, i.e. `dist/custom-elements-hmr-polyfill.iife.js`.
115+
116+
Furthermore, multiple file outputs are available in `dist/*/**/*.js`. i.e. `dist/AMD/**/*.js`.
117+
- `AMD`
118+
- `CommonJS`
119+
- `ES6`
120+
- `ES2015`
121+
- `ESNext`
122+
- `System`
123+
- `UMD`
124+
106125
## Advanced: How to start the sample code (of this repo)?
107126

108127
- `npm run bootstrap`
109128
- `npm start`
110129

111-
## How to build a dist version of this polyfill?
130+
## How to transpile and bundle this polyfill on your own?
112131

132+
- `npm run bootstrap`
113133
- `npm build`

fuse.js

+36-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const { fusebox, sparky } = require('fuse-box');
2-
const { pluginTypeChecker } = require('fuse-box-typechecker');
2+
const { pluginTypeChecker, TypeChecker } = require('fuse-box-typechecker');
33

44
class Context {
55
getConfig() {
@@ -37,3 +37,38 @@ task('default', async ctx => {
3737
const fuse = ctx.getConfig();
3838
await fuse.runDev();
3939
});
40+
41+
const build = (target) => {
42+
const checker = require('fuse-box-typechecker').TypeChecker({
43+
tsConfigOverride: {
44+
compilerOptions: {
45+
outDir: `./dist/${target}`,
46+
rootDir: `./src/package`,
47+
target: 'es2018',
48+
module: target,
49+
lib: ['es2017', 'dom'],
50+
emitDecoratorMetadata: true,
51+
sourceMap: true,
52+
declaration: true,
53+
importHelpers: true,
54+
experimentalDecorators: true
55+
},
56+
exclude: ['dist', 'node_modules', 'src/sample']
57+
},
58+
basePath: `./`,
59+
name: `Building ${target}`
60+
});
61+
62+
checker.printSettings();
63+
let result = checker.inspectOnly();
64+
checker.printOnly(result);
65+
66+
console.log(` -> Emitting js`);
67+
const x = result.oldProgram.emit();
68+
};
69+
70+
task('build', async ctx => {
71+
['CommonJS', 'AMD', 'System', 'UMD', 'ES6', 'ES2015', 'ESNext'].forEach(target => {
72+
build(target);
73+
});
74+
});

0 commit comments

Comments
 (0)