Skip to content

Commit

Permalink
Reformat app/webpack.config.js
Browse files Browse the repository at this point in the history
  • Loading branch information
jitseniesen committed Apr 24, 2023
1 parent 1fe669d commit e3cd09f
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions spyder_notebook/server/app/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ const webpack = require('webpack');
const merge = require('webpack-merge').default;
const Handlebars = require('handlebars');
const { ModuleFederationPlugin } = webpack.container;
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer')
.BundleAnalyzerPlugin;
const BundleAnalyzerPlugin =
require('webpack-bundle-analyzer').BundleAnalyzerPlugin;

const Build = require('@jupyterlab/builder').Build;
const baseConfig = require('@jupyterlab/builder/lib/webpack.config.base');

const data = require('./package.json');

const names = Object.keys(data.dependencies).filter(name => {
const names = Object.keys(data.dependencies).filter((name) => {
const packageData = require(path.join(name, 'package.json'));
return packageData.jupyterlab !== undefined;
});
Expand All @@ -38,32 +38,32 @@ const { mimeExtensions, plugins } = data.jupyterlab;

// Create the list of extension packages from the package.json metadata
const extensionPackages = new Set();
Object.keys(plugins).forEach(page => {
Object.keys(plugins).forEach((page) => {
const pagePlugins = plugins[page];
Object.keys(pagePlugins).forEach(name => {
Object.keys(pagePlugins).forEach((name) => {
extensionPackages.add(name);
});
});

Handlebars.registerHelper('json', function(context) {
Handlebars.registerHelper('json', function (context) {
return JSON.stringify(context);
});

// custom help to check if a page corresponds to a value
Handlebars.registerHelper('ispage', function(key, page) {
Handlebars.registerHelper('ispage', function (key, page) {
return key === page;
});

// custom helper to load the plugins on the index page
Handlebars.registerHelper('list_plugins', function() {
Handlebars.registerHelper('list_plugins', function () {
let str = '';
const page = this;
Object.keys(this).forEach(extension => {
Object.keys(this).forEach((extension) => {
const plugin = page[extension];
if (plugin === true) {
str += `require(\'${extension}\'),\n `;
} else if (Array.isArray(plugin)) {
const plugins = plugin.map(p => `'${p}',`).join('\n');
const plugins = plugin.map((p) => `'${p}',`).join('\n');
str += `
require(\'${extension}\').default.filter(({id}) => [
${plugins}
Expand All @@ -79,7 +79,7 @@ const source = fs.readFileSync('index.template.js').toString();
const template = Handlebars.compile(source);
const extData = {
notebook_plugins: plugins,
notebook_mime_extensions: mimeExtensions
notebook_mime_extensions: mimeExtensions,
};
const indexOut = template(extData);
fs.writeFileSync(path.join(buildDir, 'index.js'), indexOut);
Expand Down Expand Up @@ -110,7 +110,7 @@ function createShared(packageData) {
for (let pkg of extensionPackages) {
if (!shared[pkg]) {
shared[pkg] = {
requiredVersion: require(`${pkg}/package.json`).version
requiredVersion: require(`${pkg}/package.json`).version,
};
}
}
Expand All @@ -123,7 +123,7 @@ function createShared(packageData) {
let pkgShared = {};
let {
dependencies = {},
jupyterlab: { sharedPackages = {} } = {}
jupyterlab: { sharedPackages = {} } = {},
} = require(`${pkg}/package.json`);
for (let [dep, requiredVersion] of Object.entries(dependencies)) {
if (!shared[dep]) {
Expand Down Expand Up @@ -214,19 +214,19 @@ module.exports = [
path: path.resolve(__dirname, '..', 'static/'), // Spyder: change path
library: {
type: 'var',
name: ['_JUPYTERLAB', 'CORE_OUTPUT']
name: ['_JUPYTERLAB', 'CORE_OUTPUT'],
},
filename: 'bundle.js'
filename: 'bundle.js',
},
plugins: [
new ModuleFederationPlugin({
library: {
type: 'var',
name: ['_JUPYTERLAB', 'CORE_LIBRARY_FEDERATION']
name: ['_JUPYTERLAB', 'CORE_LIBRARY_FEDERATION'],
},
name: 'CORE_FEDERATION',
shared: createShared(data)
})
]
})
shared: createShared(data),
}),
],
}),
].concat(extras);

0 comments on commit e3cd09f

Please sign in to comment.