Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

162
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda