Skip to content

Commit 9e9c61a

Browse files
committed
Optimize webpack config for Comunica 1.14
1 parent 6f8785d commit 9e9c61a

File tree

4 files changed

+24
-56
lines changed

4 files changed

+24
-56
lines changed

.babelrc

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
presets: [
3+
["@babel/preset-env"],
4+
],
5+
env: {
6+
module: {
7+
presets: [
8+
["@babel/preset-env", { modules: false }],
9+
],
10+
},
11+
},
12+
}

.browserslistrc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Build for most browsers
2+
>2%
3+
last 2 Chrome versions
4+
last 2 Firefox versions
5+
last 2 iOS versions

package.json

-3
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,12 @@
1515
},
1616
"devDependencies": {
1717
"@babel/core": "^7.1.2",
18-
"@babel/plugin-syntax-object-rest-spread": "^7.0.0",
19-
"@babel/plugin-transform-async-to-generator": "^7.0.0",
2018
"@babel/polyfill": "^7.0.0",
2119
"@babel/preset-env": "^7.0.0",
2220
"babel-loader": "^8.0.4",
2321
"eslint": "^7.0.0",
2422
"file-loader": "^6.0.0",
2523
"pre-commit": "^1.2.2",
26-
"string-replace-webpack-plugin": "^0.1.3",
2724
"webpack": "^4.16.1",
2825
"webpack-cli": "^3.0.8",
2926
"webpack-dev-server": "^3.1.4"

webpack.config.js

+7-53
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
var path = require('path');
22
var webpack = require('webpack');
3-
var StringReplacePlugin = require('string-replace-webpack-plugin');
43

54
// Generate queries.json file
65
require('./queries-to-json');
@@ -58,77 +57,32 @@ module.exports = [
5857
{ test: /images\/*\.svg$/, use: 'file-loader' },
5958
],
6059
},
61-
optimization: {
62-
minimize: true,
63-
},
6460
},
6561
{
6662
entry: [
67-
'@babel/polyfill',
6863
'./src/ldf-client-worker.js',
6964
],
7065
output: {
7166
filename: 'scripts/ldf-client-worker.min.js',
7267
path: path.join(__dirname, '/build'),
7368
libraryTarget: 'this', // Fixes hot loading of web worker not working in Webpack
7469
},
75-
devtool: 'cheap-module-source-map',
70+
devtool: 'source-map',
7671
module: {
7772
rules: [
7873
{
79-
// This is needed because our internal graphql dependency uses .mjs files,
80-
// and Webpack's define plugin doesn't work well with it (yet).
81-
// In the future this should be removed.
82-
type: 'javascript/auto',
83-
test: /\.mjs$/,
84-
use: []
85-
},
86-
{ // This fixes a problem where the setImmediate of asynciterator would conflict with webpack's polyfill
87-
test: /asynciterator\.js$/,
88-
loader: StringReplacePlugin.replace({
89-
replacements: [
90-
{
91-
pattern: /if \(typeof process !== 'undefined' && !process\.browser\)/i,
92-
replacement: function () {
93-
return 'if (true)';
94-
},
95-
},
96-
] }),
97-
},
98-
{
99-
// Makes rdf-sink use a modularized lodash function instead of requiring lodash completely
100-
test: /rdf-sink\/index\.js$/,
101-
loader: StringReplacePlugin.replace({
102-
replacements: [
103-
{
104-
pattern: /lodash\/assign/i,
105-
replacement: function () {
106-
return 'lodash.assign';
107-
},
108-
},
109-
],
110-
}),
74+
test: /\.js$/,
75+
loader: 'babel-loader',
76+
exclude: /node_modules/,
11177
},
11278
{
113-
test: /\.js$/,
114-
use: {
115-
loader: 'babel-loader',
116-
options: {
117-
presets: ['@babel/preset-env'],
118-
plugins: [
119-
require('@babel/plugin-transform-async-to-generator'),
120-
require('@babel/plugin-syntax-object-rest-spread'),
121-
],
122-
},
123-
},
79+
test: /\.mjs$/,
80+
type: 'javascript/auto',
12481
},
12582
],
12683
},
127-
optimization: {
128-
minimize: true,
129-
},
13084
plugins: [
131-
new StringReplacePlugin(),
85+
new webpack.ProgressPlugin(),
13286
],
13387
},
13488
];

0 commit comments

Comments
 (0)