1
0
mirror of https://github.com/sasjs/adapter.git synced 2026-07-23 14:45:29 +00:00
Files
adapter/webpack.config.js
T
YuryShkoda 3d4fe304e9 fix(build): remove stale node: builtin externals breaking consumer webpack builds
The externals block for 'node:fs'/'node:path'/etc. became dead weight when
originally added, but the webpack 5.108.4 bump now canonicalizes bare builtin
requires to the node: form, matching it. That flips these modules from being
polyfilled by node-polyfill-webpack-plugin to leaking as unresolved literal
requires in the published bundle.
2026-07-21 18:03:19 +03:00

96 lines
2.1 KiB
JavaScript

const path = require('path')
const webpack = require('webpack')
const terserPlugin = require('terser-webpack-plugin')
const nodePolyfillPlugin = require('node-polyfill-webpack-plugin')
const defaultPlugins = [
new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /en/),
new webpack.SourceMapDevToolPlugin({
filename: null,
exclude: [/node_modules/],
test: /\.ts($|\?)/i
})
]
const optimization = {
minimize: false,
minimizer: [
// new terserPlugin({
// parallel: true,
// terserOptions: {}
// })
]
}
const browserConfig = {
entry: {
index: './src/index.ts',
minified_sas9: './src/minified/sas9/index.ts'
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'build'),
libraryTarget: 'umd',
library: 'SASjs'
},
mode: 'production',
optimization: optimization,
devtool: 'inline-source-map',
module: {
rules: [
{
test: /\.ts?$/,
use: 'ts-loader',
exclude: /node_modules/
}
]
},
resolve: {
extensions: ['.ts', '.js'],
fallback: { https: false, fs: false, readline: false }
},
plugins: [
...defaultPlugins,
new webpack.ProvidePlugin({
process: 'process/browser'
}),
new nodePolyfillPlugin()
]
}
const browserConfigWithDevTool = {
...browserConfig,
entry: './src/index.ts',
output: {
filename: 'index-dev.js',
path: path.resolve(__dirname, 'build'),
libraryTarget: 'umd',
library: 'SASjs'
},
devtool: 'inline-source-map'
}
const browserConfigWithoutProcessPlugin = {
entry: browserConfig.entry,
devtool: browserConfig.devtool,
mode: browserConfig.mode,
optimization: optimization,
module: browserConfig.module,
resolve: browserConfig.resolve,
output: browserConfig.output,
plugins: defaultPlugins
}
const nodeConfig = {
...browserConfigWithoutProcessPlugin,
target: 'node',
entry: './node/index.ts',
output: {
...browserConfig.output,
path: path.resolve(__dirname, 'build', 'node'),
filename: 'index.js'
}
}
module.exports = [browserConfig, browserConfigWithDevTool, nodeConfig]