Skip to content

Commit 1e8bb72

Browse files
authored
fix: webpack dynamic import (#1509)
- Use webpackIgnore to disable url resolving: https://webpack.js.org/loaders/css-loader/#disable-url-resolving-using-the--webpackignore-true--comment - Tested with https://github.com/deephaven-examples/deephaven-react-app-enterprise/tree/cra-light-dashboard. No warning was emitted from the webpack build step. - Tested `npm start` still loaded correctly
1 parent 1283a34 commit 1e8bb72

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

packages/jsapi-bootstrap/src/ApiBootstrap.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@ export function ApiBootstrap({
4040
useEffect(() => {
4141
async function loadApi() {
4242
try {
43-
// Using a string template around `apiUrl` to avoid a warning with webpack: https://stackoverflow.com/a/73359606
44-
const dh: DhType = (await import(/* @vite-ignore */ `${apiUrl}`))
45-
.default;
43+
const dh: DhType =
44+
// Ignore the warning about dynamic import in both Vite and Webpack.
45+
// We use Vite, but some clients may use Webpack.
46+
(await import(/* @vite-ignore */ /* webpackIgnore: true */ apiUrl))
47+
.default;
4648
log.info('API bootstrapped from', apiUrl);
4749
setApi(dh);
4850
if (setGlobally) {

0 commit comments

Comments
 (0)