From e62e42b724cd14dfd1fbcb91a41df59a3864645a Mon Sep 17 00:00:00 2001 From: Ihor Dykhta Date: Tue, 23 Jul 2024 22:22:38 +0300 Subject: [PATCH 1/2] babel-loader for probe.gl Signed-off-by: Ihor Dykhta --- examples/webpack.config.local.js | 58 +++++++++++++++++++------------- 1 file changed, 35 insertions(+), 23 deletions(-) diff --git a/examples/webpack.config.local.js b/examples/webpack.config.local.js index be2a4df263..be06de3232 100644 --- a/examples/webpack.config.local.js +++ b/examples/webpack.config.local.js @@ -115,7 +115,11 @@ function makeLocalDevConfig(env, EXAMPLE_DIR = LIB_DIR, externals = {}) { test: /\.(js|ts|tsx)$/, use: ['source-map-loader'], enforce: 'pre', - exclude: [/node_modules\/react-palm/, /node_modules\/react-data-grid/] + exclude: [ + /node_modules\/react-palm/, + /node_modules\/react-data-grid/, + /node_modules\/@probe\.gl/ + ] }, // for compiling apache-arrow ESM module { @@ -130,6 +134,28 @@ function makeLocalDevConfig(env, EXAMPLE_DIR = LIB_DIR, externals = {}) { }; } +const BABEL_LOADER_OPTIONS = { + presets: ['@babel/preset-env', '@babel/preset-react', '@babel/preset-typescript'], + plugins: [ + ['@babel/plugin-transform-typescript', {isTSX: true, allowDeclareFields: true}], + '@babel/plugin-proposal-class-properties', + '@babel/plugin-proposal-optional-chaining', + '@babel/plugin-proposal-export-namespace-from', + '@babel/plugin-transform-runtime', + [ + 'search-and-replace', + { + rules: [ + { + search: '__PACKAGE_VERSION__', + replace: KeplerPackage.version + } + ] + } + ] + ] +}; + function makeBabelRule(env, exampleDir) { return { // Compile source using babel @@ -159,27 +185,7 @@ function makeBabelRule(env, exampleDir) { env.deck || env.deck_src ? [/node_modules\/(?!(@deck\.gl|@luma\.gl|@probe\.gl|probe.gl|@loaders\.gl)\/).*/] : [/node_modules/], - options: { - presets: ['@babel/preset-env', '@babel/preset-react', '@babel/preset-typescript'], - plugins: [ - ['@babel/plugin-transform-typescript', {isTSX: true, allowDeclareFields: true}], - '@babel/plugin-proposal-class-properties', - '@babel/plugin-proposal-optional-chaining', - '@babel/plugin-proposal-export-namespace-from', - '@babel/plugin-transform-runtime', - [ - 'search-and-replace', - { - rules: [ - { - search: '__PACKAGE_VERSION__', - replace: KeplerPackage.version - } - ] - } - ] - ] - } + options: BABEL_LOADER_OPTIONS }; } @@ -220,7 +226,13 @@ function addBabelSettings(env, config, exampleDir) { ...config.module, rules: [ ...config.module.rules.filter(r => r.loader !== 'babel-loader'), - makeBabelRule(env, exampleDir) + makeBabelRule(env, exampleDir), + { + test: /\.(js|ts)$/, + loader: 'babel-loader', + options: BABEL_LOADER_OPTIONS, + include: [/node_modules\/@probe.gl/] + } ] } }; From 73d90ed1c17f5e9e1928ab9382686ec3cd811227 Mon Sep 17 00:00:00 2001 From: Ihor Dykhta Date: Thu, 25 Jul 2024 13:57:14 +0300 Subject: [PATCH 2/2] add loaders to babel-loader processing Signed-off-by: Ihor Dykhta --- examples/webpack.config.local.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/webpack.config.local.js b/examples/webpack.config.local.js index be06de3232..ccdf727b82 100644 --- a/examples/webpack.config.local.js +++ b/examples/webpack.config.local.js @@ -118,7 +118,8 @@ function makeLocalDevConfig(env, EXAMPLE_DIR = LIB_DIR, externals = {}) { exclude: [ /node_modules\/react-palm/, /node_modules\/react-data-grid/, - /node_modules\/@probe\.gl/ + /node_modules\/@probe\.gl/, + /node_modules\/@loaders\.gl/ ] }, // for compiling apache-arrow ESM module @@ -231,7 +232,7 @@ function addBabelSettings(env, config, exampleDir) { test: /\.(js|ts)$/, loader: 'babel-loader', options: BABEL_LOADER_OPTIONS, - include: [/node_modules\/@probe.gl/] + include: [/node_modules\/@probe\.gl/, /node_modules\/@loaders\.gl/] } ] }