···1212conda install -c conda-forge jupyterlab-blockly
1313```
14141515+or
1616+1717+```bash
1818+pip install jupyterlab-blockly
1919+```
2020+1521### Kernels
16221723- ipykernel
···2834conda uninstall -c conda-forge jupyterlab-blockly
2935```
30363737+or
3838+3939+```bash
4040+pip uninstall jupyterlab-blockly
4141+```
4242+3143## Development install
32443345**Note:** You will need NodeJS to build the extension package.
···3749`yarn` or `npm` in lieu of `jlpm` below.
38503951```bash
4040-micromamba create -n blockly -c conda-forge python nodejs=18 yarn pre-commit jupyterla jupyter-packaging jupyterlab-language-pack-es-ES jupyterlab-language-pack-fr-FR ipykernel xeus-python xeus-lua
5252+micromamba create -n blockly -c conda-forge python nodejs=18 yarn pre-commit jupyterla jupyterlab-language-pack-es-ES jupyterlab-language-pack-fr-FR ipykernel xeus-python xeus-lua
4153micromamba activate blockly
4254# Clone the repo to your local environment
4355# Change directory to the jupyterlab_blockly directory
+38-28
docs/other_extensions.md
···33The JupyterLab-Blockly extension is ready to be used as a base for other projects: you can register new Blocks, Toolboxes and Generators. It is a great tool for fast prototyping.
4455## Creating a new JupyterLab extension
66-You can easily create a new JupyterLab extension by using a `cookiecutter`. You can read more documentation about `cookiecutters` [here](https://cookiecutter.readthedocs.io/en/latest/), but the process is fairly straight-forward.
66+You can easily create a new JupyterLab extension by using the official `copier` template, documented [here](https://github.com/jupyterlab/extension-template).
7788-After running the following command:
88+After installing the needed plugins (mentioned in the above link) and creating an extension directory, you can run the following command:
99```
1010-cookiecutter https://github.com/jupyterlab/extension-cookiecutter-ts
1010+copier copy --trust https://github.com/jupyterlab/extension-template .
1111```
1212- the `cookiecutter` will ask for some basic information about your project. Once completed, it will create a directory containing several files, all forming the base of your project. You will mostly work in the `index.ts` file, located in the `src` folder.
1212+which will ask you to fill some basic information about your project. Once completed, the directory will be populated with several files, all forming the base of your project. You will mostly work in the `index.ts` file, located in the `src` folder.
13131414-An example of creating a simple JupyterLab extension, which also contains the instructions of how to fill the information asked by the `cookiecutter`, can be found [here](https://github.com/jupyterlab/extension-examples/tree/master/hello-world).
1414+An example of creating a simple JupyterLab extension, which also contains the instructions of how to fill the information asked by the `copier` template, can be found [here](https://github.com/jupyterlab/extension-examples/tree/master/hello-world).
151516161717## Importing JupyterLab-Blockly
···113113114114## Additional configurations
115115116116-You will need to request the `jupyterlab-blockly` package as a dependency of your extension, in order to ensure it is installed and available to provide the token `IBlocklyRegistry`. To do this, you need to add the following line to your `setup.py` file.
116116+You will need to request the `jupyterlab-blockly` package as a dependency for your extension, in order to ensure it is installed and available to provide the token `IBlocklyRegistry`. To do this, you need to add the following line to your `pyproject.toml` file.
117117118118-```python
119119-// setup.py : 57
118118+```
119119+// pyproject.toml : 26
120120121121-setup_args = dict(
122122- ...
123123- install_requires=['jupyterlab-blockly>=0.3.2,<0.4']
124124- ...
125125-)
121121+dependencies = [
122122+ "jupyterlab-blockly>=0.3.2,<0.4",
123123+ ... // add any additional dependencies needed for your extension
124124+]
126125```
127126128128-Moreover, as we are working with deduplication of dependencies and the extension you are creating requires a service identified by a token from `jupyterlab-blockly`, you need to add the following configuration to your `package.json` file.
127127+Additionally, you will need to add the webpack configuration for loading the `Blockly` source maps. You can do this, by creating the following `webpack.config.js` file inside your root directory:
128128+129129+```js
130130+// @ts-check
129131132132+module.exports = /** @type { import('webpack').Configuration } */ ({
133133+ devtool: 'source-map',
134134+ module: {
135135+ rules: [
136136+ // Load Blockly source maps.
137137+ {
138138+ test: /(blockly\/.*\.js)$/,
139139+ use: [require.resolve('source-map-loader')],
140140+ enforce: 'pre'
141141+ }
142142+ ].filter(Boolean)
143143+ },
144144+ // https://github.com/google/blockly-samples/blob/9974e85becaa8ad17e35b588b95391c85865dafd/plugins/dev-scripts/config/webpack.config.js#L118-L120
145145+ ignoreWarnings: [/Failed to parse source map/]
146146+});
130147```
131131-// package.json : 88-101
132148149149+and by connecting the `webpack` config to your `jupyterlab` instance, which entails adding the following line inside your `package.json`:
150150+151151+```json
133152"jupyterlab": {
134134- "sharedPackages": {
135135- "jupyterlab-blockly": {
136136- "bundled": false,
137137- "singleton": true
138138- },
139139- "blockly": {
140140- "bundled": false,
141141- "singleton": true
142142- }
143143- }
144144- }
145145-```
146146-This ensures your extension will get the exact same token the provider is using to identify the service and exclude it from its bundle as the provider will give a copy of the token. You can read more about deduplication of dependencies [here](https://jupyterlab.readthedocs.io/en/stable/extension/extension_dev.html#deduplication-of-dependencies), in the official *Extension Developer Guide for JupyterLab*.
153153+ ...
154154+ "webpackConfig": "./webpack.config.js"
155155+ }
156156+```