Procházet zdrojové kódy

Merge pull request #3827 from blink1073/always-fresh-yarn-lock

Never use a lock file for the build
Jason Grout před 7 roky
rodič
revize
90403b2df4

+ 6 - 3
docs/source/developer/extension_dev.rst

@@ -150,9 +150,12 @@ the CSS files) are watched by the WebPack process.
 Note that the application is built against **released** versions of the
 core JupyterLab extensions. If your extension depends on JupyterLab
 packages, it should be compatible with the dependencies in the
-``jupyterlab/static/package.json`` file. If you must install a extension
-into a development branch of JupyterLab, you have to graft it into the
-source tree of JupyterLab itself. This may be done using the command
+``jupyterlab/static/package.json`` file.  Note that building will always use the latest JavaScript packages that meet the dependency requirements of JupyterLab itself and any installed extensions.  If you wish to test against a
+specific patch release of one of the core JupyterLab packages you can
+temporarily pin that requirement to a specific version in your own
+dependencies.
+
+If you must install a extension into a development branch of JupyterLab, you have to graft it into the source tree of JupyterLab itself. This may be done using the command
 
 ::
 

+ 5 - 0
docs/source/user/extensions.rst

@@ -150,6 +150,11 @@ Building consists of:
 -  Bundling the assets
 -  Copying the bundled assets to the ``static`` directory
 
+Note that building will always use the latest JavaScript packages that meet
+the dependency requirements of JupyterLab itself and any installed extensions.
+If you wish to run JupyterLab with the set of pinned requirements that was
+shipped with the Python package, you can launch as `jupyter lab --core-mode`.
+
 JupyterLab Application Directory
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 

+ 8 - 8
jupyterlab/commands.py

@@ -726,7 +726,6 @@ class _AppHandler(object):
 
         # Look for mismatched version.
         pkg_path = pjoin(staging, 'package.json')
-        overwrite_lock = False
 
         if osp.exists(pkg_path):
             with open(pkg_path) as fid:
@@ -734,18 +733,19 @@ class _AppHandler(object):
             if data['jupyterlab'].get('version', '') != version:
                 shutil.rmtree(staging)
                 os.makedirs(staging)
-            else:
-                overwrite_lock = False
 
         for fname in ['index.js', 'webpack.config.js',
-                'webpack.prod.config.js',
-                'yarn.lock', '.yarnrc', 'yarn.js']:
+                      'webpack.prod.config.js',
+                      '.yarnrc', 'yarn.js']:
             target = pjoin(staging, fname)
-            if (fname == 'yarn.lock' and os.path.exists(target) and
-                    not overwrite_lock):
-                continue
             shutil.copy(pjoin(HERE, 'staging', fname), target)
 
+        # Remove an existing yarn.lock file
+        # Because otherwise we can end up with unwanted duplicates
+        # cf https://github.com/yarnpkg/yarn/issues/3967
+        if osp.exists(pjoin(staging, 'yarn.lock')):
+            os.remove(pjoin(staging, 'yarn.lock'))
+
         # Ensure a clean templates directory
         templates = pjoin(staging, 'templates')
         if osp.exists(templates):