@@ -85,14 +85,17 @@ const labModuleFederationConfig = {
85
85
86
86
// Export array of webpack configurations
87
87
module . exports = [
88
- // 1. Notebook extension AMD module
88
+ // 1. Notebook extension AMD module - Used by NBClassic (Jupyter Notebook < 7.0)
89
89
{
90
90
mode,
91
91
entry : "./src/extension.js" ,
92
92
output : {
93
93
filename : "extension.js" ,
94
94
path : path . resolve ( __dirname , "nbextension" ) ,
95
- libraryTarget : "amd" ,
95
+ // libraryTarget: "var" exposes the library by creating a global variable
96
+ // Example: var graph_notebook_widgets = { ... }
97
+ // This is the classic way NBClassic loads extensions through RequireJS
98
+ libraryTarget : "var" ,
96
99
library : "graph_notebook_widgets" ,
97
100
publicPath : "nbextensions/graph_notebook_widgets/" ,
98
101
} ,
@@ -104,15 +107,22 @@ module.exports = [
104
107
watchOptions,
105
108
} ,
106
109
107
- // 2. Notebook extension
110
+ // 2. Notebook extension - Used by NBClassic (Jupyter Notebook < 7.0)
108
111
{
109
112
mode,
110
113
entry : "./src/extension.ts" ,
111
114
output : {
112
115
filename : "index.js" ,
113
116
path : path . resolve ( __dirname , "nbextension" ) ,
117
+ // libraryTarget: "amd" creates an AMD module that can be loaded by RequireJS
118
+ // AMD (Asynchronous Module Definition) allows modules to be loaded asynchronously
119
+ // Example: define(['dependency'], function(dependency) { ... })
120
+ // NBClassic uses RequireJS to load extensions in this format
114
121
libraryTarget : "amd" ,
115
- library : "graph_notebook_widgets" ,
122
+ // This creates a "named define" module without a global variable
123
+ // It allows the module to be imported by name in RequireJS
124
+ // Example: define('graph_notebook_widgets', ['dependency'], function(dependency) { ... })
125
+ library : undefined ,
116
126
publicPath : "nbextensions/graph_notebook_widgets/" ,
117
127
} ,
118
128
module : { rules } ,
@@ -123,7 +133,7 @@ module.exports = [
123
133
watchOptions,
124
134
} ,
125
135
126
- // 3. Lab extension with Module Federation
136
+ // 3. Lab extension with Module Federation - Used by JupyterLab 4.x and Notebook 7+
127
137
{
128
138
mode,
129
139
entry : "./src/index.ts" ,
@@ -132,6 +142,9 @@ module.exports = [
132
142
chunkFilename : '[name].[contenthash].js' ,
133
143
path : path . resolve ( __dirname , 'labextension/static' ) ,
134
144
publicPath : 'static/' ,
145
+ // AMD format is used as the base format for JupyterLab extensions
146
+ // Module Federation builds on top of this to enable dynamic loading
147
+ // This configuration creates a JupyterLab 4.x compatible extension
135
148
libraryTarget : 'amd'
136
149
} ,
137
150
devtool : "source-map" ,
@@ -143,18 +156,21 @@ module.exports = [
143
156
resolve,
144
157
plugins : [
145
158
...basePlugins ,
159
+ // ModuleFederationPlugin enables the extension to be loaded dynamically
160
+ // by JupyterLab 4.x and Notebook 7+ which both use this architecture
146
161
new ModuleFederationPlugin ( labModuleFederationConfig ) ,
147
162
] ,
148
163
watchOptions
149
164
} ,
150
165
151
- // 4. Documentation widget bundle
166
+ // 4. Documentation widget bundle - Used for documentation examples
152
167
{
153
168
mode,
154
169
entry : "./src/index.ts" ,
155
170
output : {
156
171
filename : "embed-bundle.js" ,
157
172
path : path . resolve ( __dirname , "docs" , "source" , "_static" ) ,
173
+ // AMD format used for documentation examples to match JupyterLab format
158
174
libraryTarget : "amd" ,
159
175
} ,
160
176
module : { rules } ,
0 commit comments