66import * as glob from 'glob' ;
77import * as path from 'path' ;
88import { TsconfigPathsPlugin } from 'tsconfig-paths-webpack-plugin' ;
9- import * as webpack from 'webpack' ;
9+ import { Configuration , ContextReplacementPlugin } from 'webpack' ;
1010import { ExtensionRootDir } from '../constants' ;
1111import { getDefaultPlugins } from './common' ;
1212
@@ -22,7 +22,7 @@ function getListOfExistingModulesInOutDir() {
2222 return files . map ( filePath => `./${ filePath . slice ( 0 , - 3 ) } ` ) ;
2323}
2424
25- const config : webpack . Configuration = {
25+ const config : Configuration = {
2626 mode : 'production' ,
2727 target : 'node' ,
2828 entry : {
@@ -37,13 +37,22 @@ const config: webpack.Configuration = {
3737 rules : [
3838 {
3939 // JupyterServices imports node-fetch using `eval`.
40- test : / @ j u p y t e r l a b \/ s e r v i c e s \/ .* j s $ / ,
40+ test : / @ j u p y t e r l a b [ \\ \/ ] s e r v i c e s [ \\ \/ ] .* j s $ / ,
4141 use : [
4242 {
4343 loader : path . join ( __dirname , 'loaders' , 'fixEvalRequire.js' )
4444 }
4545 ]
4646 } ,
47+ {
48+ // Do not use __dirname in getos when using require.
49+ test : / g e t o s [ \\ \/ ] i n d e x .j s $ / ,
50+ use : [
51+ {
52+ loader : path . join ( __dirname , 'loaders' , 'fixGetosRequire.js' )
53+ }
54+ ]
55+ } ,
4756 {
4857 test : / \. t s $ / ,
4958 use : [
@@ -69,7 +78,8 @@ const config: webpack.Configuration = {
6978 ...existingModulesInOutDir
7079 ] ,
7180 plugins : [
72- ...getDefaultPlugins ( 'extension' )
81+ ...getDefaultPlugins ( 'extension' ) ,
82+ new ContextReplacementPlugin ( / g e t o s / , / l o g i c \/ .* .j s / )
7383 ] ,
7484 resolve : {
7585 extensions : [ '.ts' , '.js' ] ,
0 commit comments