Initial implementation of frontend plugins

Uses webpack 5 module federation to dynamically load code based on a JS file URL.
This commit is contained in:
David Joy
2021-02-09 17:21:34 -05:00
parent 3a7c455bb3
commit 76a85224b8
5 changed files with 2920 additions and 5232 deletions

28
webpack.dev.config.js Normal file
View File

@@ -0,0 +1,28 @@
const { createConfig } = require('@edx/frontend-build');
// eslint-disable-next-line import/no-extraneous-dependencies
const { ModuleFederationPlugin } = require('webpack').container;
module.exports = createConfig('webpack-dev', {
plugins: [
new ModuleFederationPlugin({
name: 'learning',
shared: {
react: {
import: 'react', // the "react" package will be used a provided and fallback module
shareKey: 'react', // under this name the shared module will be placed in the share scope
shareScope: 'default', // share scope with this name will be used
singleton: true, // only a single version of the shared module is allowed
eager: true,
},
'react-dom': {
singleton: true, // only a single version of the shared module is allowed
eager: true,
},
'@edx/frontend-platform': {
singleton: true,
eager: true,
},
},
}),
],
});