Skip to content

Commit

Permalink
build: webpack config for jupyuter lite
Browse files Browse the repository at this point in the history
  • Loading branch information
echarles committed Jan 13, 2024
1 parent 9e02af1 commit fbac679
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@
"extension": "./lib/jupyterlab/index.js",
"outputDir": "datalayer/labextension",
"schemaDir": "schema",
"webpackConfig": "./webpack.lab-config.js",
"sharedPackages": {
"@jupyter/docprovider": {
"bundled": true,
Expand Down
23 changes: 23 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,29 @@ module.exports = {
test: /\.(png|jpg|jpeg|gif|ttf|woff|woff2|eot)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
use: [{ loader: 'url-loader', options: { limit: 10000 } }],
},
// Ship the JupyterLite service worker.
{
resourceQuery: /text/,
type: 'asset/resource',
generator: {
filename: '[name][ext]',
},
},
// Rule for pyodide kernel
{
test: /pypi\/.*/,
type: 'asset/resource',
generator: {
filename: 'pypi/[name][ext][query]',
},
},
{
test: /pyodide-kernel-extension\/schema\/.*/,
type: 'asset/resource',
generator: {
filename: 'schema/[name][ext][query]',
},
}
]
},
plugins: [
Expand Down
40 changes: 40 additions & 0 deletions webpack.lab-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (c) 2021-2023 Datalayer, Inc.
*
* MIT License
*/

module.exports = {
module: {
rules: [
// Rule to deal with the service-worker.ts file
// It will include the transpiled file as a text file named `[name][ext]`
// That file is available from the static folder of this extension. That
// requires to overwrite the `workerUrl` in '@datalayer/jupyter-kernels:browser-service-worker'
// see https://github.com/jupyterlite/jupyterlite/blob/1a1bbcaab83f3c56fde6747a8c9b83d3c2a9eb97/packages/server/src/tokens.ts#L5
{
resourceQuery: /text/,
type: 'asset/resource',
generator: {
// Must match the filename in jupyter_kernels/handlers/service_worker/handler.py
filename: 'lite-[name][ext]',
},
},
// Rules for pyodide kernel assets
{
test: /pypi\/.*/,
type: 'asset/resource',
generator: {
filename: 'pypi/[name][ext][query]',
},
},
{
test: /pyodide-kernel-extension\/schema\/.*/,
type: 'asset/resource',
generator: {
filename: 'schema/[name][ext][query]',
},
},
],
},
};

0 comments on commit fbac679

Please sign in to comment.