-
Notifications
You must be signed in to change notification settings - Fork 36
Description
I have a react app with jest configuration already.
I am trying to setup netflix safe test. I changed my app as per instructions in this repo.
I am facing some issue with: import_meta.webpackContext undefined.
import React from 'react';
import { createRoot } from 'react-dom/client';
import { bootstrap } from 'safetest/react';
import App from './App.jsx';
const container = document.getElementById('app');
const root = createRoot(container);
const isDev = process.env.NODE_ENV !== 'production';
bootstrap({
container,
element: (
<React.StrictMode>
<App />
</React.StrictMode>
),
webpackContext:
isDev &&
import.meta.webpackContext('.', {
recursive: true,
regExp: /\.safetest$/,
mode: 'lazy',
}),
render: (element) => root.render(element),
});
When I load the app - I am seeing following error:
index.jsx:20 Uncaught TypeError: import_meta.webpackContext is not a function at eval (index.jsx:20:1) at 98963 (app.js:2978:1) at __webpack_require__ (app.js:9773:42) at app.js:9988:89 at __webpack_require__.O (app.js:9815:23) at webpackJsonpCallback (app.js:9974:40) at vendor.js:9:79
webpack version: 5.94.0 Node.js version: 18.20.2
I am wondering what is causing this issue and why my app is not loading: Is webpack loader is causing this?
Webpack configuration
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
loader: 'esbuild-loader',
options: {
loader: 'jsx',
jsx: 'automatic',
},
},
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
I even tried using require.context (still didnt work)
Any help will be appreciated, thank you!!