Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

170
Views
How can I load all chunks with index.js file as a package in another project?

I have made a package to use in another project. Previously this was transpiled with babel and nothing was bundled. The other application would install it as a npm package and that project would bundle everything. It worked fine.

I'm now bundling the package with Webpack to handle some tree shaking. The project includes several json files, these get chunked into their own files, or I can use a plugin to store them as json files. Everything works fine, I add it to my main project which uses this package, and when it loads it only loads the index.js, none of the chunked files are added to the main projects bundle. Is it possible to do this?

Here is my webpack.config.js

module.exports = {
  entry: './src/index.tsx',
  module: {
    rules: [
      {
        test: /\.tsx?$/,
        use: 'ts-loader',
        exclude: [/node_modules/, /\.json$/],
      },
      {
        test: /\.css$/i,
        use: ['style-loader', 'css-loader'],
      },
    ],
  },

  resolve: {
    extensions: ['.tsx', '.ts', '.js'],
    symlinks: false,
  },
  output: {
    clean: true,
    path: path.resolve(__dirname, 'dist'),
    chunkFilename: '[id].js',
    publicPath: '/',
    filename: 'index.js',
    library: {
      name: 'dummyName',
      type: 'umd',
    },
  },
  mode: 'production',
  externals: {
    react: 'react',
    'react-dom': 'react-dom',
    '@mui/material': '@mui/material',
    '@mui/styles': '@mui/styles',
  },
  plugins: [
    new CopyPlugin({
      patterns: [
        { from: './src/assets', to: 'assets' },
      ],
    }),
    new BundleAnalyzerPlugin({ analyzerMode: 'disabled' }),
  ],
};

How can I do this?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!