Skip to content

Commit 97b1b2d

Browse files
committed
feat: update configuration options, and use umd for cdn bundle
1 parent 08a5e52 commit 97b1b2d

File tree

6 files changed

+244
-85
lines changed

6 files changed

+244
-85
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ _For now this CDN bundle is only accessible in the form of a UMD bundle, through
230230
<body>
231231
<h1>My PDF Viewer</h1>
232232
<div id="root"></div>
233-
<script src="https://cdn.jsdelivr.net/npm/react-adobe-embed/dist/react-adobe-embed.cdn.js"></script>
233+
<script src="https://cdn.jsdelivr.net/npm/react-adobe-embed/lib/bundle.js"></script>
234234
<script>
235235
/**
236236
* @type {React} ReactCDN
@@ -268,7 +268,7 @@ _For now this CDN bundle is only accessible in the form of a UMD bundle, through
268268
* loaded via CDN from the above script tag
269269
* via jsdelivr.net
270270
*/
271-
const ReactViewAdobeCDN = window.ReactViewAdobe;
271+
const ReactViewAdobeCDN = window.ReactAdobeEmbed.ReactViewAdobe;
272272
273273
/**
274274
* @type { import('react-adobe-embed').ReactViewAdobeProps }

canary/routes/CDN.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default function CDN() {
1111

1212
// Create new script element to load cdn
1313
const script = document.createElement('script');
14-
script.src = 'https://ziping-liu-corporation.github.io/react-adobe-embed/dist/react-adobe-embed.cdn.js';
14+
script.src = 'https://ziping-liu-corporation.github.io/react-adobe-embed/lib/bundle.js';
1515
script.async = true;
1616
script.onload = () => {
1717
setComponentDidUpdate(true);

package-lock.json

Lines changed: 29 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-adobe-embed",
3-
"version": "12.0.2",
3+
"version": "13.0.0",
44
"homepage": "https://ziping-liu-corporation.github.io/react-adobe-embed/#/home",
55
"repository": {
66
"type": "git",
@@ -50,8 +50,8 @@
5050
"module": "./lib/bundle.esm.mjs",
5151
"main": "./lib/bundle.cjs.js",
5252
"umd:main": "./lib/bundle.js",
53-
"browser": "./dist/react-adobe-embed.cdn.js",
54-
"jsdelivr": "./dist/react-adobe-embed.cdn.js",
53+
"browser": "./lib/bundle.js",
54+
"jsdelivr": "./lib/bundle.js",
5555
"exports": {
5656
".": {
5757
"require": "./lib/bundle.cjs.js",
@@ -76,13 +76,13 @@
7676
"scripts": {
7777
"clean": "rm -rf ./build && rm -rf ./lib && rm -rf ./dist && rm -rf ./types",
7878
"test": "jest",
79-
"build:canary": "npm run build:roll:canary && rsync -rhv --progress ./public/* ./build && cp ./README.md ./build && npm run build:roll:cdn && rsync -rhv --progress ./dist ./build/ && cp ./LICENSE.md ./build && npm run build:public",
79+
"build:canary": "npm run build:roll:canary && rsync -rhv --progress ./public/* ./build && cp ./README.md ./build && npm run build:roll && rsync -rhv --progress ./lib ./build/ && cp ./LICENSE.md ./build && npm run build:public",
8080
"build:public": "node ./scripts/public.js",
8181
"build:roll:canary": "rimraf build && rollup --bundleConfigAsCjs -c rollup.config.canary.js",
8282
"predeploy": "npm run build:roll:canary",
8383
"prepare": "husky install",
8484
"lint": "eslint --ext .js,.jsx,.ts,.tsx ./src ./canary",
85-
"build": "npm run build:roll && npm run build:roll:cdn",
85+
"build": "npm run build:roll",
8686
"deploy": "gh-pages -d build",
8787
"build:roll": "rimraf lib && tsc -p tsconfig.build.json && rollup --bundleConfigAsCjs -c rollup.config.js",
8888
"build:roll:cdn": "rimraf dist && tsc -p tsconfig.build.json && rollup --bundleConfigAsCjs -c rollup.config.cdn.js"
@@ -101,6 +101,7 @@
101101
"@rollup/plugin-node-resolve": "^15.2.3",
102102
"@rollup/plugin-replace": "^5.0.5",
103103
"@rollup/plugin-terser": "^0.4.4",
104+
"@rollup/plugin-typescript": "^11.1.6",
104105
"@testing-library/react": "^14.0.0",
105106
"@types/jest": "^29.5.11",
106107
"@types/react": "^18.2.33",
@@ -123,6 +124,5 @@
123124
"rollup-plugin-typescript2": "^0.34.1",
124125
"ts-jest": "^29.1.1",
125126
"typescript": "^4.9.5"
126-
127127
}
128128
}

rollup.config.js

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const outputCommonConf = {
1818
exports: 'named',
1919
globals: {
2020
react: 'React',
21-
'react-dom/client': 'ReactDOM'
21+
'react-dom': 'ReactDOM'
2222
}
2323
};
2424

@@ -31,26 +31,35 @@ export default [
3131
{
3232
file: packageJson['umd:main'],
3333
format: 'umd',
34-
name: 'ReactScriptTag',
35-
...outputCommonConf
34+
name: 'ReactAdobeEmbed',
35+
exports:"named",
36+
extend: true,
37+
sourcemap: true,
38+
globals: {
39+
react: 'React',
40+
'react-dom': 'ReactDOM'
41+
},
3642
},
3743
{
3844
file: packageJson.main,
45+
name: 'ReactAdobeEmbed',
3946
format: 'cjs',
4047
...outputCommonConf
4148
},
4249
{
4350
file: packageJson.module,
44-
format: 'es',
45-
...outputCommonConf
51+
52+
format: 'esm',
53+
54+
4655
},
4756
],
4857
plugins: [
4958
peerDepsExternal(),
5059
localResolve(),
5160
babel({ exclude: 'node_modules/**, src/tests/**' ,
5261

53-
babelHelpers: 'external',
62+
babelHelpers: "bundled",
5463
presets: [
5564
"@babel/preset-env",
5665
"@babel/preset-react",
@@ -95,11 +104,13 @@ export default [
95104

96105
filesize(),
97106
],
98-
external: ["react", "react-dom", "styled-components"]
107+
external: ['react', 'react-dom'], // Marking React and ReactDOM as external
108+
99109
},
100110
{
101111
input: "types/index.d.ts",
102112
output: [{ file: "lib/bundle.esm.d.ts", format: "esm" }],
103113
plugins: [dts()],
104114
},
115+
105116
];

0 commit comments

Comments
 (0)