Categories
Mastering Development

How do I get an appropriate loader to handle this file type in Django?

I have just started a django and react project. Whenever I try and load some css be it plain css or from bootstrap I get the following error: I followed the following tutorial: https://www.valentinog.com/blog/drf/ I move my .bablrc and my webpack.config.js into my project root folder. Previously it was inside the frontend app folder. Please […]

Categories
Mastering Development

Error: Cannot find module ‘ejs’, webpack does not compile the ejs module in the bundle.js file made through webpack.server.js

I keep getting the not found module for ejs and tried bunch of solutions. I am not sure why the ejs module does not compile to the file webpack builds. this is the error: Error: Failed to lookup view “pages/index” in views directory “/views” at Function.y.render (/Users/”user name”/projects/project-node-test/build/bundle.js:277:4330) package.json: “name”: “project-node”, “version”: “1.0.0”, “description”: “”, […]

Categories
Mastering Development

‘$’ is undefined error in react app running in IE 11

how do i get rid of error ‘$’ is undefined in IE 11 ? I am using react with typescript (traget es2015). Babel configuration in webpack config looks like this test: /\.(tsx|ts)$/, loader: “awesome-typescript-loader”, exclude: /node_modules/, options: { “useBabel”: true, “babelOptions”: { “babelrc”: false, /* Important line */ “presets”: [ ‘@babel/preset-env’, “@babel/preset-react” ], “plugins”: [ […]

Categories
Development

Compiling React projects in MonoRepo failing

I’m trying to setup yarn workspaces with my docker instance. This is my directory structure: /monorepo/ /node_modules/ @libs/common @services/common @services/project-A …OTHER DEPS… package.json /services/ /common/ index.jsx package.json /project-A/ webpack.config.js **REACT project with babel, webpack, etc** /libs/ /tools/ /common/ index.jsx package.json To simplify my docker setup I just configured this volume within my docker compose that […]

Categories
Development

Hot reloading not being trigger – component malformed?

This has been baffling me for a few hours now & I can’t seem to work out why. My original theory was that react-router/redux was causing this issue but I have now stripped them out & hot reloading still does not occur. My original file structure is below: index.js import ‘@babel/polyfill’ import React from ‘react’ […]

Categories
Development

babel-plugin-rewire with mocha and react not working

I have an interesting situation: I am using babel-plugin-rewire in my mocha tests like so: // given MySystemUnderTest.__Rewire__(“ChildComponent”, ({ prop }) => { return <div>{prop}</div>; }); const mockProps = { prop: “hello, world!” }; // when const { getByText } = render(<MySystemUnderTest {…mockProps} />); // then await waitForElement(() => getByText(“hello, world!”)); MySystemUnderTest.__ResetDependency__(“ChildComponent”); I have been […]

Categories
Development Plugins

External Library using Rollup.JS with Formik doesn’t respect named exports

I am using Rollup to put together a shared library of form components which uses Formik as the base layer. I’m currently getting the following compile error for ‘scheduler’ which is used under the hood by Formik. I’ve tried installing it manually as a separate npm dependency, but still get the following error. [!] Error: […]

Categories
Development Plugins

Babel 7.7 – replace babel/polyfill with core-js@3

Since @babel/polyfill was deprecated in 7.4.0, I am trying to directly add core-js and setting the version via the corejs option as decribed in the Babel documentation.. I am getting errors related to polyfill when trying this approach, though. 「(°ヘ°) The app compiles, but never renders – the console logs error “can’t access lexical declaration […]

Categories
CSS Development Plugins

Computed Properties not working with Babel preset-env

I’m trying to use computed properties in my Material UI style object, but I’ve getting an unexpected token error. Below is the code snippet, error, and babel-webpack config. const useStyles = makeStyles(theme => { root: { [desktop]: { width: “80%”, } } }); //webpack.config.babel.js … const config = { entry: [‘@babel/polyfill’, ‘./src/components/index.js’], resolve: { extensions: […]

Categories
Chrome Development Plugins

Why can’t webpack tree-shake lodash when using “import * as _”?

I am learning about tree-shaking with a webpack 4/React application that uses Lodash. At first, my Lodash usage looked like this: import * as _ from “lodash”; _.random(… I soon learned, via the BundleAnalyzerPlugin, that the entirety of Lodash was being included in both dev and prod builds (527MB). After googling around I realized that […]