Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import React, { FC } from 'react'
import dynamic from 'next/dynamic'

const ReactViewer = dynamic(
() => import('react-viewer'),
() => import('react-viewer').then((mod) => mod.default),
{ ssr: false }
)

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

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

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-viewer",
"version": "3.2.3",
"version": "3.2.4",
"description": "react image viewer",
"main": "dist/index",
"scripts": {
Expand All @@ -10,9 +10,10 @@
"build": "webpack --config webpack.config.prop.js && npm run build:types",
"build:types": "node -e \"require('fs-extra').removeSync('lib')\" && tsc -p tsconfig.build.json",
"build:ssr": "npm --prefix ssr-test ci --ignore-scripts && npm --prefix ssr-test run build",
"check:package-export": "node scripts/check-package-export.js",
"build:analyze": "ANALYZE=true webpack --config webpack.config.prop.js",
"doc": "webpack --config webpack.config.doc.js",
"verify": "npm test -- --runInBand && npm run lint && npm run build && npm run doc && npm run build:ssr && npm pack --dry-run",
"verify": "npm test -- --runInBand && npm run lint && npm run build && npm run check:package-export && npm run doc && npm run build:ssr && npm pack --dry-run",
"pub": "npm publish",
"prepublishOnly": "npm run build",
"predeploy": "npm run doc",
Expand Down Expand Up @@ -68,6 +69,7 @@
"jest-environment-jsdom": "^23.4.0",
"jest-environment-jsdom-global": "^1.1.0",
"jest-static-stubs": "0.0.1",
"jsdom": "^11.12.0",
"less": "^3.10.3",
"less-loader": "^5.0.0",
"merge2": "^1.3.0",
Expand Down
18 changes: 18 additions & 0 deletions scripts/check-package-export.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const assert = require('assert');
const { JSDOM } = require('jsdom');

const dom = new JSDOM('<!doctype html><html><head></head><body></body></html>');
global.window = dom.window;
global.document = dom.window.document;
global.navigator = dom.window.navigator;

const Viewer = require('../dist');
assert.strictEqual(
typeof Viewer,
'function',
'The CommonJS package entry must export the Viewer component directly'
);

console.log('Package default export is a component.');
dom.window.close();
process.exit(0);
1 change: 1 addition & 0 deletions webpack.config.prop.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ if (fs.existsSync(distPath)) {

config.output.merge({
library: 'react-viewer',
libraryExport: 'default',
libraryTarget: 'umd',
globalObject: 'this'
});
Expand Down