Note: This repo uses pnpm, but you can use npm or yarn if desired.
ssh
git clone git@github.com:inspiraller/webpack-and-microbundle.git
https
git clone https://github.com/inspiraller/webpack-and-microbundle.git
cd mymicrobundle
pnpm i
npm run dev
cd ../webpack-loads-microbundle
pnpm i
npm run dev
Hello
Session = some session value
done !
(Disclaimer:- This does not allow loading in of umd format. Will support common js and esm though.) ** webpack.config.js**
resolve: {
...
alias: {
// vanillia example of loading in a barebones microbundle
'@mymicrobundle': path.resolve(__dirname, '../mymicrobundle/dist'),
// This is a peer dependency of the main app,
// Force 'react' and 'react-dom' to load from this repo
react: path.resolve('./node_modules/react'),
'react-dom': path.resolve('./node_modules/react-dom'),
// example missing module - fixes - Cannot find module 'p-queue/dist'
'p-queue/dist': path.resolve('../mymicrobundle/dist')
},
},
(This allows loading in of umd format, ie node_modules format.)
- The target of modules: ['node_modules', path.resolve(__dirname, '../mymicrobundle')], Allows all npm references declared in the package.json to honour the file:../
resolve: {
...
modules: ['node_modules', path.resolve(__dirname, '../mymicrobundle')],
alias: {
// This is a peer dependency of the main app,
// Force 'react' and 'react-dom' to load from this repo
react: path.resolve('./node_modules/react'),
'react-dom': path.resolve('./node_modules/react-dom'),
// fixes - Cannot find module 'p-queue/dist'
'p-queue/dist': path.resolve('../mymicrobundle/'),
},
},