11// Copyright (c) Microsoft Corporation.
22// Licensed under the MIT License.
3- 'use strict' ;
43
5- const { EOL } = require ( 'os' ) ;
6- const colors = require ( 'colors/safe' ) ;
7- const fs = require ( 'fs-extra' ) ;
8- const path = require ( 'path' ) ;
9- const constants = require ( '../constants' ) ;
10- const common = require ( '../webpack/common' ) ;
11- const { downloadZMQ } = require ( '@vscode/zeromq' ) ;
4+ import { EOL } from 'node:os' ;
5+ import colors from 'colors/safe.js' ;
6+ import fs from 'fs-extra' ;
7+ import path from 'node:path' ;
8+ import { ExtensionRootDir } from '../constants.js' ;
9+ import { getBundleConfiguration , bundleConfiguration } from '../webpack/common.js' ;
10+ import { downloadZMQ } from '@vscode/zeromq' ;
11+ import { fileURLToPath } from 'node:url' ;
12+ import { dirname } from 'node:path' ;
13+
14+ const __filename = fileURLToPath ( import . meta. url ) ;
15+ const __dirname = dirname ( __filename ) ;
1216
1317function fixVariableNameInKernelDefaultJs ( ) {
1418 var relativePath = path . join ( 'node_modules' , '@jupyterlab' , 'services' , 'lib' , 'kernel' , 'default.js' ) ;
15- var filePath = path . join ( constants . ExtensionRootDir , relativePath ) ;
19+ var filePath = path . join ( ExtensionRootDir , relativePath ) ;
1620 if ( ! fs . existsSync ( filePath ) ) {
1721 throw new Error (
1822 "Jupyter lab default kernel not found '" + filePath + "' (Jupyter Extension post install script)"
@@ -32,7 +36,7 @@ function fixVariableNameInKernelDefaultJs() {
3236}
3337function removeUnnecessaryLoggingFromKernelDefault ( ) {
3438 var relativePath = path . join ( 'node_modules' , '@jupyterlab' , 'services' , 'lib' , 'kernel' , 'default.js' ) ;
35- var filePath = path . join ( constants . ExtensionRootDir , relativePath ) ;
39+ var filePath = path . join ( ExtensionRootDir , relativePath ) ;
3640 if ( ! fs . existsSync ( filePath ) ) {
3741 throw new Error (
3842 "Jupyter lab default kernel not found '" + filePath + "' (Jupyter Extension post install script)"
@@ -61,7 +65,7 @@ function makeVariableExplorerAlwaysSorted() {
6165 'case g.NONE:e=r?g.DESC:g.ASC;break;case g.ASC:e=r?g.NONE:g.DESC;break;case g.DESC:e=r?g.ASC:g.NONE' ;
6266 for ( const fileName of fileNames ) {
6367 var relativePath = path . join ( 'node_modules' , 'react-data-grid' , 'dist' , fileName ) ;
64- var filePath = path . join ( constants . ExtensionRootDir , relativePath ) ;
68+ var filePath = path . join ( ExtensionRootDir , relativePath ) ;
6569 if ( ! fs . existsSync ( filePath ) ) {
6670 throw new Error ( "react-data-grid dist file not found '" + filePath + "' (pvsc post install script)" ) ;
6771 }
@@ -134,7 +138,8 @@ exports.javascript = {
134138 * See comments here build/webpack/moment.js
135139 */
136140function verifyMomentIsOnlyUsedByJupyterLabCoreUtils ( ) {
137- const packageLock = require ( path . join ( __dirname , '..' , '..' , 'package-lock.json' ) ) ;
141+ const packageLockPath = path . join ( __dirname , '..' , '..' , 'package-lock.json' ) ;
142+ const packageLock = JSON . parse ( fs . readFileSync ( packageLockPath , 'utf8' ) ) ;
138143 const packagesAllowedToUseMoment = [ 'node_modules/@jupyterlab/coreutils' , '@jupyterlab/coreutils' ] ;
139144 const otherPackagesUsingMoment = [ ] ;
140145 [ 'packages' , 'dependencies' ] . forEach ( ( key ) => {
@@ -167,7 +172,7 @@ function verifyMomentIsOnlyUsedByJupyterLabCoreUtils() {
167172 }
168173}
169174async function downloadZmqBinaries ( ) {
170- if ( common . getBundleConfiguration ( ) === common . bundleConfiguration . web ) {
175+ if ( getBundleConfiguration ( ) === bundleConfiguration . web ) {
171176 // No need to download zmq binaries for web.
172177 return ;
173178 }
0 commit comments