Skip to content

Commit

Permalink
Merge pull request #25 from iadvize/NO-TICKET-bundle-for-script
Browse files Browse the repository at this point in the history
feat: Bundle for <script>
  • Loading branch information
DavidBonnemaison authored May 11, 2023
2 parents e1d7001 + 366e3b4 commit 9edb95c
Show file tree
Hide file tree
Showing 7 changed files with 220 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules/
esm/
dist/
web/
coverage/
gh-pages-content/
.eslintcache
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.1.0]

### Changed

- Add a Web bundle for <script> consumers
## [1.0.1]

### Fixed
Expand Down
196 changes: 194 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"sideEffects": false,
"files": [
"dist",
"esm"
"esm",
"web"
],
"scripts": {
"build": "rm -rf dist esm && rollup -c",
Expand All @@ -35,6 +36,7 @@
"@iadvize-oss/eslint-config": "^4.0.0",
"@iadvize-oss/eslint-config-jest": "^2.0.0",
"@rollup/plugin-commonjs": "^24.1.0",
"@rollup/plugin-terser": "^0.4.1",
"@types/jest": "^29.5.1",
"@typescript-eslint/parser": "^5.59.1",
"eslint": "^8.39.0",
Expand Down
6 changes: 6 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import commonjs from '@rollup/plugin-commonjs';
import typescript from 'rollup-plugin-typescript2';
import terser from '@rollup/plugin-terser';

export default [
{
Expand All @@ -15,6 +16,11 @@ export default [
dir: 'esm',
format: 'es',
},
{
dir: 'web',
format: 'iife',
plugins: [terser()]
}
],
},
];
6 changes: 6 additions & 0 deletions src/host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,9 @@ export function initIAdvizeHost(sandboxId: string): void {
resizeIFrame(iAdvizeSandbox, e.data);
});
}

// Expose function to consume in <script>
if (window) {
// @ts-expect-error: global export
window.initIAdvizeHost = initIAdvizeHost;
}
5 changes: 5 additions & 0 deletions src/iframe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,8 @@ export function initIAdvizeIframe(
script.src = `//${platform}.iadvize.com/iadvize.js`;
document.body.appendChild(script);
}
// Expose function to consume in <script>
if (window) {
// @ts-expect-error: global export
window.initIAdvizeIframe = initIAdvizeIframe;
}

0 comments on commit 9edb95c

Please sign in to comment.