Skip to content
This repository has been archived by the owner on Apr 6, 2021. It is now read-only.

Use jupyterlab cli #62

Merged
merged 15 commits into from
Aug 13, 2020
Merged

Use jupyterlab cli #62

merged 15 commits into from
Aug 13, 2020

Conversation

blink1073
Copy link
Contributor

Use the new cli coming from jupyterlab/jupyterlab#8802 (relies on a new alpha release).

image

@blink1073 blink1073 changed the title [WIP[ Use 3.0a8 [WIP] Use jupyterlab cli Aug 10, 2020
@blink1073 blink1073 mentioned this pull request Aug 10, 2020
8 tasks
@blink1073
Copy link
Contributor Author

We'll need an update to jupyterlab to make the Windows build work - the file is a shell script on Windows

@blink1073
Copy link
Contributor Author

blink1073 commented Aug 12, 2020

json_package error

> @jupyterlab/example-federated@2.1.0 build:json /Users/stslve/workspace/jupyter/jupyterlab-module-federation
> jupyter labextension build ./json_package

Building jupyterlab assets (build:nobuild)
Building extension in /Users/stslve/workspace/jupyter/jupyterlab-module-federation/json_package
> node /Users/stslve/miniconda/envs/module-federation/share/jupyter/lab/staging/node_modules/webpack-cli/bin/cli.js --config /Users/stslve/miniconda/envs/module-federation/share/jupyter/lab/staging/node_modules/@jupyterlab/buildutils/lib/webpack.config.ext.js
/Users/stslve/workspace/jupyter/jupyterlab-module-federation/node_modules/webpack-cli/bin/cli.js:93
				throw err;
				^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type boolean (false)
    at validateString (internal/validators.js:121:11)
    at Object.join (path.js:1039:7)
    at Object.<anonymous> (/Users/stslve/miniconda/envs/module-federation/share/jupyter/lab/staging/node_modules/@jupyterlab/buildutils/lib/webpack.config.ext.js:60:35)
    at Module._compile (/Users/stslve/workspace/jupyter/jupyterlab-module-federation/node_modules/v8-compile-cache/v8-compile-cache.js:194:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1221:10)
    at Module.load (internal/modules/cjs/loader.js:1050:32)
    at Function.Module._load (internal/modules/cjs/loader.js:938:14)
    at Module.require (internal/modules/cjs/loader.js:1090:19)
    at require (/Users/stslve/workspace/jupyter/jupyterlab-module-federation/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
    at WEBPACK_OPTIONS (/Users/stslve/workspace/jupyter/jupyterlab-module-federation/node_modules/webpack-cli/bin/utils/convert-argv.js:114:13)
    at requireConfig (/Users/stslve/workspace/jupyter/jupyterlab-module-federation/node_modules/webpack-cli/bin/utils/convert-argv.js:116:6)
    at /Users/stslve/workspace/jupyter/jupyterlab-module-federation/node_modules/webpack-cli/bin/utils/convert-argv.js:123:17
    at Array.forEach (<anonymous>)
    at module.exports (/Users/stslve/workspace/jupyter/jupyterlab-module-federation/node_modules/webpack-cli/bin/utils/convert-argv.js:121:15)
    at /Users/stslve/workspace/jupyter/jupyterlab-module-federation/node_modules/webpack-cli/bin/cli.js:71:45
    at Object.parse (/Users/stslve/workspace/jupyter/jupyterlab-module-federation/node_modules/yargs/yargs.js:576:18)
    at /Users/stslve/workspace/jupyter/jupyterlab-module-federation/node_modules/webpack-cli/bin/cli.js:49:8
    at Object.<anonymous> (/Users/stslve/workspace/jupyter/jupyterlab-module-federation/node_modules/webpack-cli/bin/cli.js:366:3)
    at Module._compile (internal/modules/cjs/loader.js:1201:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1221:10)
    at Module.load (internal/modules/cjs/loader.js:1050:32)
    at Function.Module._load (internal/modules/cjs/loader.js:938:14)
    at Module.require (internal/modules/cjs/loader.js:1090:19)
    at require (internal/modules/cjs/helpers.js:75:18)
    at module.exports (/Users/stslve/miniconda/envs/module-federation/share/jupyter/lab/staging/node_modules/import-local/index.js:16:66)
    at /Users/stslve/miniconda/envs/module-federation/share/jupyter/lab/staging/node_modules/webpack-cli/bin/cli.js:15:6
    at Object.<anonymous> (/Users/stslve/miniconda/envs/module-federation/share/jupyter/lab/staging/node_modules/webpack-cli/bin/cli.js:366:3)
    at Module._compile (internal/modules/cjs/loader.js:1201:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1221:10)
    at Module.load (internal/modules/cjs/loader.js:1050:32) {
  code: 'ERR_INVALID_ARG_TYPE'
}
(node:71174) UnhandledPromiseRejectionWarning: Error: Command failed: node /Users/stslve/miniconda/envs/module-federation/share/jupyter/lab/staging/node_modules/webpack-cli/bin/cli.js --config /Users/stslve/miniconda/envs/module-federation/share/jupyter/lab/staging/node_modules/@jupyterlab/buildutils/lib/webpack.config.ext.js
    at checkExecSyncError (child_process.js:616:11)
    at Object.execSync (child_process.js:652:15)
    at Object.run (/Users/stslve/miniconda/envs/module-federation/share/jupyter/lab/staging/node_modules/@jupyterlab/buildutils/lib/utils.js:230:32)
    at Command.<anonymous> (/Users/stslve/miniconda/envs/module-federation/share/jupyter/lab/staging/node_modules/@jupyterlab/buildutils/lib/build-extension.js:65:13)
    at Command.listener (/Users/stslve/miniconda/envs/module-federation/share/jupyter/lab/staging/node_modules/@jupyterlab/buildutils/node_modules/commander/index.js:360:8)
    at Command.emit (events.js:314:20)
    at Command.parseArgs (/Users/stslve/miniconda/envs/module-federation/share/jupyter/lab/staging/node_modules/@jupyterlab/buildutils/node_modules/commander/index.js:801:12)
    at Command.parse (/Users/stslve/miniconda/envs/module-federation/share/jupyter/lab/staging/node_modules/@jupyterlab/buildutils/node_modules/commander/index.js:563:21)
    at Object.<anonymous> (/Users/stslve/miniconda/envs/module-federation/share/jupyter/lab/staging/node_modules/@jupyterlab/buildutils/lib/build-extension.js:67:21)
    at Module._compile (internal/modules/cjs/loader.js:1201:30)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:71174) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:71174) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
npm WARN lifecycle The node binary used for scripts is /tmp/yarn--1597196466801-0.9215942379546336/node but npm is using /Users/stslve/miniconda/envs/module-federation/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.

> @jupyterlab/example-federated@2.1.0 build:middle /Users/stslve/workspace/jupyter/jupyterlab-module-federation
> jupyter labextension build ./middle_package

Building jupyterlab assets (build:nobuild)
Building extension in /Users/stslve/workspace/jupyter/jupyterlab-module-federation/middle_package
> node /Users/stslve/miniconda/envs/module-federation/share/jupyter/lab/staging/node_modules/webpack-cli/bin/cli.js --config /Users/stslve/miniconda/envs/module-federation/share/jupyter/lab/staging/node_modules/@jupyterlab/buildutils/lib/webpack.config.ext.js
Hash: 57230b01ab91c8fb1c6a
Version: webpack 5.0.0-beta.24
Child
    Hash: 57230b01ab91c8fb1c6a
    Time: 152 ms
    Built at: 2020-08-11 20:42:11
    asset extension_js.b41666072a98013d6977.js 2.23 KiB [emitted] [immutable] 1 related asset
    asset index_js.a8257f984d7086be6360.js 1.59 KiB [emitted] [immutable] 1 related asset
    asset remoteEntry.js 24 KiB [emitted] (name: @jupyterlab/example-federated-middle) 1 related asset
    Entrypoint @jupyterlab/example-federated-middle = remoteEntry.js (remoteEntry.js.map)
    container entry 42 bytes [built]
    provide shared module (default) @jupyterlab/example-federated-middle@2.1.0 = ./index.js 42 bytes [built]
    ./index.js 339 bytes [built]
    ./extension.js 338 bytes [built]
    consume shared module (default) @lumino/coreutils@^1.4.3 (singleton) 42 bytes [built]
        + 11 hidden modules
npm WARN lifecycle The node binary used for scripts is /tmp/yarn--1597196466801-0.9215942379546336/node but npm is using /Users/stslve/miniconda/envs/module-federation/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.

@blink1073
Copy link
Contributor Author

theme_package error

> @jupyterlab/example-federated@2.1.0 build:theme /Users/stslve/workspace/jupyter/jupyterlab-module-federation
> jupyter labextension build ./theme_package

Building jupyterlab assets (build:nobuild)
[1/4] 🔍  Resolving packages...
success Already up-to-date.
Building extension in /Users/stslve/workspace/jupyter/jupyterlab-module-federation/theme_package
> node /Users/stslve/miniconda/envs/module-federation/share/jupyter/lab/staging/node_modules/webpack-cli/bin/cli.js --config /Users/stslve/miniconda/envs/module-federation/share/jupyter/lab/staging/node_modules/@jupyterlab/buildutils/lib/webpack.config.ext.js
(node:71208) [DEP_WEBPACK_MAIN_TEMPLATE_RENDER_MANIFEST] DeprecationWarning: MainTemplate.hooks.renderManifest is deprecated (use Compilation.hooks.renderManifest instead)
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:71208) [DEP_WEBPACK_CHUNK_TEMPLATE_RENDER_MANIFEST] DeprecationWarning: ChunkTemplate.hooks.renderManifest is deprecated (use Compilation.hooks.renderManifest instead)
(node:71208) [DEP_WEBPACK_MAIN_TEMPLATE_HASH_FOR_CHUNK] DeprecationWarning: MainTemplate.hooks.hashForChunk is deprecated (use JavascriptModulesPlugin.getCompilationHooks().chunkHash instead)
(node:71208) [DEP_WEBPACK_CHUNK_MODULES_ITERABLE] DeprecationWarning: Chunk.modulesIterable: Use new ChunkGraph API
(node:71208) [DEP_WEBPACK_COMPILATION_CACHE] DeprecationWarning: Compilation.cache was removed in favor of Compilation.getCache()
Hash: fc8a80408aba83abf6654570a7e7b5bca32b2f7f
Version: webpack 5.0.0-beta.24
Child
    Hash: fc8a80408aba83abf665
    Time: 145 ms
    Built at: 2020-08-11 20:42:18
    asset index_js.75f493a51497a6b42f63.js 2.03 KiB [emitted] [immutable] 1 related asset
    asset remoteEntry.js 23.9 KiB [emitted] (name: @jupyterlab/example-federated-theme) 1 related asset
    Entrypoint @jupyterlab/example-federated-theme = remoteEntry.js (remoteEntry.js.map)
    container entry 42 bytes [built]
    provide shared module (default) @jupyterlab/example-federated-theme@3.0.0-alpha.9 = ./index.js 42 bytes [built]
    ./index.js 739 bytes [built]
    consume shared module (default) @jupyterlab/apputils@^3.0.0-alpha.9 (singleton) 42 bytes [built]
        + 11 hidden modules
Child
    Hash: 4570a7e7b5bca32b2f7f
    Time: 430 ms
    Built at: 2020-08-11 20:42:18
    1 asset
    Entrypoint index = index.js
    ./style/index.css 39 bytes [built] [failed] [1 error]
        + 1 hidden module

    ERROR in ./style/index.css
    Module build failed (from ../../../../miniconda/envs/module-federation/share/jupyter/lab/staging/node_modules/mini-css-extract-plugin/dist/loader.js):
    TypeError: The 'compilation' argument must be an instance of Compilation
        at Function.getCompilationHooks (/Users/stslve/miniconda/envs/module-federation/share/jupyter/lab/staging/node_modules/webpack/lib/javascript/JavascriptModulesPlugin.js:116:10)
        at /Users/stslve/miniconda/envs/module-federation/share/jupyter/lab/staging/node_modules/webpack/lib/node/NodeTemplatePlugin.js:40:42
        at Hook.eval [as call] (eval at create (/Users/stslve/workspace/jupyter/jupyterlab-module-federation/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:9:1)
        at Hook.CALL_DELEGATE [as _call] (/Users/stslve/workspace/jupyter/jupyterlab-module-federation/node_modules/tapable/lib/Hook.js:14:14)
        at Compiler.newCompilation (/Users/stslve/workspace/jupyter/jupyterlab-module-federation/node_modules/webpack/lib/Compiler.js:909:30)
        at /Users/stslve/workspace/jupyter/jupyterlab-module-federation/node_modules/webpack/lib/Compiler.js:951:29
        at Hook.eval [as callAsync] (eval at create (/Users/stslve/workspace/jupyter/jupyterlab-module-federation/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
        at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/Users/stslve/workspace/jupyter/jupyterlab-module-federation/node_modules/tapable/lib/Hook.js:18:14)
        at Compiler.compile (/Users/stslve/workspace/jupyter/jupyterlab-module-federation/node_modules/webpack/lib/Compiler.js:946:28)
        at Compiler.runAsChild (/Users/stslve/workspace/jupyter/jupyterlab-module-federation/node_modules/webpack/lib/Compiler.js:473:8)
        at Object.pitch (/Users/stslve/miniconda/envs/module-federation/share/jupyter/lab/staging/node_modules/mini-css-extract-plugin/dist/loader.js:126:17)

(node:71207) UnhandledPromiseRejectionWarning: Error: Command failed: node /Users/stslve/miniconda/envs/module-federation/share/jupyter/lab/staging/node_modules/webpack-cli/bin/cli.js --config /Users/stslve/miniconda/envs/module-federation/share/jupyter/lab/staging/node_modules/@jupyterlab/buildutils/lib/webpack.config.ext.js
    at checkExecSyncError (child_process.js:616:11)
    at Object.execSync (child_process.js:652:15)
    at Object.run (/Users/stslve/miniconda/envs/module-federation/share/jupyter/lab/staging/node_modules/@jupyterlab/buildutils/lib/utils.js:230:32)
    at Command.<anonymous> (/Users/stslve/miniconda/envs/module-federation/share/jupyter/lab/staging/node_modules/@jupyterlab/buildutils/lib/build-extension.js:65:13)
    at Command.listener (/Users/stslve/miniconda/envs/module-federation/share/jupyter/lab/staging/node_modules/@jupyterlab/buildutils/node_modules/commander/index.js:360:8)
    at Command.emit (events.js:314:20)
    at Command.parseArgs (/Users/stslve/miniconda/envs/module-federation/share/jupyter/lab/staging/node_modules/@jupyterlab/buildutils/node_modules/commander/index.js:801:12)
    at Command.parse (/Users/stslve/miniconda/envs/module-federation/share/jupyter/lab/staging/node_modules/@jupyterlab/buildutils/node_modules/commander/index.js:563:21)
    at Object.<anonymous> (/Users/stslve/miniconda/envs/module-federation/share/jupyter/lab/staging/node_modules/@jupyterlab/buildutils/lib/build-extension.js:67:21)
    at Module._compile (internal/modules/cjs/loader.js:1201:30)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:71207) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:71207) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
✨  Done in 71.97s.

@jasongrout
Copy link
Contributor

json_package error

Fixed by jupyterlab/jupyterlab#8819

@blink1073
Copy link
Contributor Author

blink1073 commented Aug 12, 2020

Note from the theme_package output: we use mini-css-extract-plugin in @jupyterlab/buildutils/lib/build.js

@blink1073
Copy link
Contributor Author

Okay, it looks like we do need extensions to have a devDependency on @jupyterlab/buildutils. We should check for a compatible version in the extension package. Here's why:

As is, the webpack build is running in theme_package as the cwd, which means it is able to find imports like @jupyterlab/example-federated-theme/style/index.css. However, that means that it is using whichever webpack and loaders are available in theme_package, except for Build.EnsureAssets, which is explicitly using mini-css-extract-plugin from staging, causing the traceback above because there are two different versions of webpack.

If we change the cwd of the process to share/jupyter/lab/staging, then we use the webpack and loaders from staging, but we can't find @jupyterlab/example-federated-theme/style/index.css:

    ERROR in index
    Module not found: Error: Can't resolve '@jupyterlab/example-federated-theme/style/index.css' in '/Users/stslve/miniconda/envs/module-federation/share/jupyter/lab/staging/node_modules/@jupyterlab/buildutils/lib'

Another option would be to install theme_package in staging and use staging as the cwd.

@blink1073
Copy link
Contributor Author

Suggested change in jupyterlab: _ensure_builder is given the ext_path and the core_path and checks for a dependency or devDependency on @jupyterlab/buildutils that is compatible with the one in core_path. It should still return:

osp.join(ext_path, 'node_modules', '@jupyterlab', 'buildutils', 'lib', 'build-extension.js')

for Windows compatibility (on Windows the node_modules/.bin/build-labextension file is a bash script instead of a node script).

@blink1073
Copy link
Contributor Author

After a release with the above change, here we would bump all the Python and JS dependencies and it should all work.

@jasongrout
Copy link
Contributor

Just curious, is the webpack context configuration option useful here?

@blink1073
Copy link
Contributor Author

As in a feature of webpack? the problem is that we need a single context either way I think, for loaders, webpack instance, etc.

@jasongrout
Copy link
Contributor

This repo seems to work now in this branch and with jlab 3.0a10

@jasongrout jasongrout changed the title [WIP] Use jupyterlab cli Use jupyterlab cli Aug 13, 2020
@jasongrout jasongrout merged commit 055598b into master Aug 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants