Skip to content

Commit 310d54d

Browse files
authored
Merge pull request #4103 from ProjectMirador/named-export
Re-export the viewer function as a named export.
2 parents 5f72533 + 3578245 commit 310d54d

4 files changed

Lines changed: 8 additions & 5 deletions

File tree

__tests__/utils/test-utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import settings from '../../src/config/settings';
1010
import createI18nInstance from '../../src/i18n';
1111

1212
/** Mirador viewer setup for Integration tests */
13-
import Mirador from '../../src/index';
13+
import { viewer as miradorViewer } from '../../src/index';
1414

1515
export * from '@testing-library/react';
1616
export { renderWithProviders as render };
@@ -61,7 +61,7 @@ function renderWithProviders(
6161

6262
/** adds a mirador viewer to the DOM */
6363
const setupMiradorViewer = async (config, plugins) => {
64-
const viewer = Mirador.viewer({ ...config, id: undefined }, plugins);
64+
const viewer = miradorViewer({ ...config, id: undefined }, plugins);
6565

6666
render(
6767
<div

src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export * from './lib';
1010
export * from './plugins';
1111
export { default as settings } from './config/settings';
1212
export { useTranslation, withTranslation } from 'react-i18next';
13+
export { viewer } from './init';
1314

1415
export default {
1516
...init,

src/init.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import MiradorViewer from './lib/MiradorViewer';
33
/**
44
* Default Mirador instantiation
55
*/
6-
function viewer(config, pluginsOrStruct) {
6+
export function viewer(config, pluginsOrStruct) {
77
let struct;
88

99
if (Array.isArray(pluginsOrStruct)) {

vite.config.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,23 +42,25 @@ export default defineConfig({
4242
rollupOptions: {
4343
external: [
4444
...Object.keys(packageJson.peerDependencies),
45-
'react/jsx-runtime',
4645
'__tests__/*',
4746
'__mocks__/*',
4847
],
4948
output: {
5049
assetFileNames: 'mirador.[ext]',
50+
exports: 'named',
5151
globals: {
5252
react: 'React',
5353
'react-dom': 'ReactDOM',
54-
'react/jsx-runtime': 'react/jsx-runtime',
5554
},
5655
},
5756
},
5857
sourcemap: true,
5958
},
6059
}
6160
),
61+
define: {
62+
'process.env': {},
63+
},
6264
esbuild: {
6365
exclude: [],
6466
// Matches .js and .jsx in __tests__ and .jsx in src

0 commit comments

Comments
 (0)