Skip to content

Commit

Permalink
fix: webpack dynamic import (#1509)
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
mofojed authored Sep 12, 2023
1 parent 1283a34 commit 1e8bb72
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/jsapi-bootstrap/src/ApiBootstrap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ export function ApiBootstrap({
useEffect(() => {
async function loadApi() {
try {
// Using a string template around `apiUrl` to avoid a warning with webpack: https://stackoverflow.com/a/73359606
const dh: DhType = (await import(/* @vite-ignore */ `${apiUrl}`))
.default;
const dh: DhType =
// Ignore the warning about dynamic import in both Vite and Webpack.
// We use Vite, but some clients may use Webpack.
(await import(/* @vite-ignore */ /* webpackIgnore: true */ apiUrl))
.default;
log.info('API bootstrapped from', apiUrl);
setApi(dh);
if (setGlobally) {
Expand Down

0 comments on commit 1e8bb72

Please sign in to comment.