Skip to content

Commit d209eea

Browse files
mfranzkeMaximilian Franzke
and
Maximilian Franzke
authored
build: bundling (#96)
* feat(modules): introduced other js module formats * refactor: updated dependencies * chore: code optimization * chore: added use strict again * chore(structure): moved that file back to the root * refactor: providing a better sounding and differentiable method * fix: missed to export the correct variable the latest * docs(api): mentioning the public method * refactor(browserlist): dropping IE8 * refactor: regenerated the JS files * chore: removed previous build tools config * test(xo): integrated some valid feedback * test(xo): integrated some valid feedback * chore: regenerated package-lock.json file * chore: regenerated package-lock.json * refactor: changed this to the new husky format * chore: regenerated the package-lock file * refactor(prettier): added relevant configuration * refactor: regenerated the dist files * chore: regenerated package-lock.json * build: rebuild the distributed files * build: prepared the next beta release Co-authored-by: Maximilian Franzke <[email protected]>
1 parent daa09dd commit d209eea

23 files changed

+27793
-14850
lines changed

Diff for: .browserslistrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
> 0.1%, IE >= 9

Diff for: .gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
node_modules
2-
config.codekit3

Diff for: .npmignore

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
demo
22
webdriverio-tests
33
.gitignore
4-
.huskyrc
5-
config.codekit3
4+
.husky
65
commitlint.config.js
76
wdio.conf-crossbrowsertesting.js
87
.github

Diff for: .prettierignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
*.min.js
1+
dist
22
package-lock.json

Diff for: .prettierrc.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"trailingComma": "es5"
3+
}

Diff for: CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77
And the commit messages from [Conventional Commits](https://conventionalcommits.org) are being used.
88

9+
## [2.0.0-beta.1] - 2021-03-04
10+
11+
### Changed
12+
13+
- BREAKING CHANGE: Even also generate JS modules from now on supported by [microbundle](https://npmjs.com/microbundle), added the relevant property entries within the `package.json` directing to those files, that are now stored within the `dist/` folder (see [migration guide](MIGRATION.md) [#19](https://github.com/mfranzke/loading-attribute-polyfill/issues/19), [#87](https://github.com/mfranzke/loading-attribute-polyfill/pull/87), [#39](https://github.com/mfranzke/loading-attribute-polyfill/pull/39))
14+
915
## [2.0.0-beta.0] - 2021-03-04
1016

1117
### Fixed

Diff for: MIGRATION.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Migration guidelines
22

3-
## 2.0.0 migration guide
3+
## 2.0.0-beta.1 migration guide
4+
5+
We've switched from previously only providing the source and a minified version of the JS, to additionally provide the different relevant JavaScript formats especially regarding modules supported by [microbundle](https://npmjs.com/microbundle). Thatfor we even also changed the location of the generated files as well as pointed the relevant property entries within the `package.json` to those files. Please find all the relevant generated files in the `dist/` folder from now on.
6+
7+
## 2.0.0-beta.0 migration guide
48

59
You'll need to wrap the `<picture>` tag instead of the included HTML tags with `<noscript>`.
610

Diff for: README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,11 @@ And the images are still displaying an error in the demo on IE9, as most likely
138138

139139
## API
140140

141-
Nothing really, just integrate it as shown within the "installation" section, and it ~~will~~ should work out of the box.
141+
In case that you're dynamically adding HTML elements within the browser, you could call the following method with an included [HTMLElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement) object, like e.g.:
142+
143+
```JavaScript
144+
loadingAttributePolyfill.prepareElement(document.querySelector('main noscript.loading-lazy'));
145+
```
142146

143147
## Demo
144148

Diff for: bower.json

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
"webdriverio-tests",
3434
".gitignore",
3535
".huskyrc",
36-
"config.codekit3",
3736
"commitlint.config.js",
3837
"wdio.conf-crossbrowsertesting.js"
3938
]

Diff for: demo/index.html

+3-1
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,12 @@
161161
integrity="sha384-0lS88tVtaG/wFBGhLbltQH+YsokYzFR53GbESKurNNjMEVpukFjECmLmebK9aMIf"
162162
crossorigin="anonymous"
163163
></script>
164+
<script type="module" src="index.js"></script>
164165
<!-- Even though that it's recommended to omit the type on the following script tag, we're keeping it for older browser compatibility -->
165166
<script
166167
type="text/javascript"
167-
src="../loading-attribute-polyfill.min.js"
168+
src="../dist/loading-attribute-polyfill.umd.js"
169+
nomodule
168170
></script>
169171
</body>
170172
</html>

Diff for: demo/index.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import loadingAttributePolyfill from '../dist/loading-attribute-polyfill.module.js';
2+
3+
// Test for dynamically inserted images
4+
window.setTimeout(() => {
5+
let child = document.createElement('div');
6+
child.innerHTML = '<noscript class="loading-lazy"></noscript>';
7+
child = child.firstChild;
8+
9+
let imageElement = document.createElement('img');
10+
imageElement.setAttribute('src', 'https://via.placeholder.com/300');
11+
imageElement.setAttribute('loading', 'lazy');
12+
imageElement.setAttribute('alt', '..');
13+
imageElement.setAttribute('width', '250');
14+
imageElement.setAttribute('height', '150');
15+
child.appendChild(imageElement);
16+
document
17+
.getElementsByTagName('main')[0]
18+
.insertBefore(child, document.getElementsByTagName('main')[0].firstChild);
19+
20+
loadingAttributePolyfill.prepareElement(document.querySelector('main noscript.loading-lazy'));
21+
}, 5000);

Diff for: dist/loading-attribute-polyfill.js

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: dist/loading-attribute-polyfill.js.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)