Skip to content

Commit

Permalink
Fix critical dependency warning in webpack config
Browse files Browse the repository at this point in the history
Fixes facebookresearch#777

Replace `require` statements with `import` statements in Webpack configuration files to resolve the critical dependency warning and blank page issue.

* **`demo/configs/webpack/common.js`**
  - Replace `require` statements with `import` statements.
  - Update `module.exports` to `export default`.

* **`demo/configs/webpack/dev.js`**
  - Replace `require` statements with `import` statements.
  - Update `module.exports` to `export default`.

* **`demo/configs/webpack/prod.js`**
  - Replace `require` statements with `import` statements.
  - Update `module.exports` to `export default`.
  • Loading branch information
HendricksJudy committed Oct 21, 2024
1 parent dca509f commit ca16ddc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 34 deletions.
20 changes: 8 additions & 12 deletions demo/configs/webpack/common.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.
// All rights reserved.
import { resolve } from "path";
import HtmlWebpackPlugin from "html-webpack-plugin";
import FriendlyErrorsWebpackPlugin from "friendly-errors-webpack-plugin";
import CopyPlugin from "copy-webpack-plugin";
import webpack from "webpack";

// This source code is licensed under the license found in the
// LICENSE file in the root directory of this source tree.

const { resolve } = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const FriendlyErrorsWebpackPlugin = require("friendly-errors-webpack-plugin");
const CopyPlugin = require("copy-webpack-plugin");
const webpack = require("webpack");

module.exports = {
const config = {
entry: "./src/index.tsx",
resolve: {
extensions: [".js", ".jsx", ".ts", ".tsx"],
Expand Down Expand Up @@ -82,3 +76,5 @@ module.exports = {
}),
],
};

export default config;
15 changes: 5 additions & 10 deletions demo/configs/webpack/dev.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.
// All rights reserved.
import { merge } from "webpack-merge";
import commonConfig from "./common";

// This source code is licensed under the license found in the
// LICENSE file in the root directory of this source tree.

// development config
const { merge } = require("webpack-merge");
const commonConfig = require("./common");

module.exports = merge(commonConfig, {
const devConfig = merge(commonConfig, {
mode: "development",
devServer: {
hot: true, // enable HMR on the server
Expand All @@ -23,3 +16,5 @@ module.exports = merge(commonConfig, {
},
devtool: "cheap-module-source-map",
});

export default devConfig;
19 changes: 7 additions & 12 deletions demo/configs/webpack/prod.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.
// All rights reserved.
import { merge } from "webpack-merge";
import { resolve } from "path";
import Dotenv from "dotenv-webpack";
import commonConfig from "./common";

// This source code is licensed under the license found in the
// LICENSE file in the root directory of this source tree.

// production config
const { merge } = require("webpack-merge");
const { resolve } = require("path");
const Dotenv = require("dotenv-webpack");
const commonConfig = require("./common");

module.exports = merge(commonConfig, {
const prodConfig = merge(commonConfig, {
mode: "production",
output: {
filename: "js/bundle.[contenthash].min.js",
Expand All @@ -20,3 +13,5 @@ module.exports = merge(commonConfig, {
devtool: "source-map",
plugins: [new Dotenv()],
});

export default prodConfig;

0 comments on commit ca16ddc

Please sign in to comment.