Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/standalone-browser-versions-of-all-libaries #774

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 60 additions & 47 deletions packages/concerto-cto/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,57 +14,70 @@

'use strict';

let path = require('path');
const path = require('path');
const webpack = require('webpack');

const packageJson = require('./package.json');

module.exports = function override(config) {
const fallback = config.resolve.fallback || {};
Object.assign(fallback, {
path: require.resolve('path-browserify'),
// Add other fallbacks as needed
});
config.resolve.fallback = fallback;

const plugins = config.plugins || [];
plugins.push(
new webpack.BannerPlugin(`Concerto CTO v${packageJson.version}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.`),
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production')
}
})
);

config.plugins = plugins;

return config;
};

// Rest of the webpack configuration
module.exports = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this just going to override the definition on line 22? Should you instead by calling the override function here like you did in concerto-util package?

entry: './index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'concerto-cto.js',
library: {
name: 'concerto-cto',
type: 'umd',
},
},
plugins: [
new webpack.BannerPlugin(`Concerto CTO v${packageJson.version}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.`),
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production')
}
}),
],
module: {
rules: [
{
test: /\.js$/,
include: [path.join(__dirname, 'lib')],
use: ['babel-loader']
},
{
test: /\.ne$/,
use: ['raw-loader']
}
]
entry: './index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'concerto-cto.js',
library: {
name: 'concerto-cto',
type: 'umd',
},
resolve: {
fallback: {
// Webpack 5 no longer polyfills Node.js core modules automatically.
// see https://webpack.js.org/configuration/resolve/#resolvefallback
// for the list of Node.js core module polyfills.
'path': 'path-browserify'
}
},
module: {
rules: [
{
test: /\.js$/,
include: [path.join(__dirname, 'lib')],
use: ['babel-loader']
},
{
test: /\.ne$/,
use: ['raw-loader']
}
]
},
resolve: {
fallback: {
'path': 'path-browserify'
}
};
}
};
137 changes: 72 additions & 65 deletions packages/concerto-util/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,75 +14,82 @@

'use strict';

let path = require('path');
const path = require('path');
const webpack = require('webpack');
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin');

const packageJson = require('./package.json');

module.exports = {
entry: './index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'concerto-util.js',
library: {
name: 'concerto-util',
type: 'umd',
},
},
plugins: [
new webpack.BannerPlugin(`Concerto Util v${packageJson.version}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.`),
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production')
}
}),
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
}),
new webpack.ProvidePlugin({
process: 'process/browser', // provide a shim for the global `process` variable
}),
new NodePolyfillPlugin(),],
module: {
rules: [
{
test: /\.js$/,
include: [path.join(__dirname, 'lib')],
use: ['babel-loader']
},
{
test: /\.ne$/,
use: ['raw-loader']
}
]
function override(config) {
const fallback = config.resolve.fallback || {};
Object.assign(fallback, {
fs: false,
tls: false,
net: false,
child_process: false,
os: false,
path: false,
// Add other fallbacks as needed
});
config.resolve.fallback = fallback;

const plugins = config.plugins || [];
plugins.push(
new webpack.BannerPlugin(`Concerto Util v${packageJson.version}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.`),
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production')
}
}),
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
}),
new webpack.ProvidePlugin({
process: 'process/browser', // provide a shim for the global `process` variable
}),
new NodePolyfillPlugin(),
);

config.plugins = plugins;

return config;
}

module.exports = override({
entry: './index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'concerto-util.js',
library: {
name: 'concerto-util',
type: 'umd',
},
resolve: {
fallback: {
// Webpack 5 no longer polyfills Node.js core modules automatically.
// see https://webpack.js.org/configuration/resolve/#resolvefallback
// for the list of Node.js core module polyfills.
'fs': false,
'tls': false,
'net': false,
'child_process': false,
'os': false,
'path': false,
// 'crypto': require.resolve('crypto-browserify'),
// 'stream': require.resolve('stream-browserify'),
// 'http': require.resolve('stream-http'),
// 'https': require.resolve('https-browserify'),
// 'zlib': require.resolve('browserify-zlib'),
// 'vm2': require.resolve('vm-browserify'),
}
},
module: {
rules: [
{
test: /\.js$/,
include: [path.join(__dirname, 'lib')],
use: ['babel-loader']
},
{
test: /\.ne$/,
use: ['raw-loader']
}
]
},
resolve: {
fallback: {
// Add other fallbacks as needed
}
};
}
});