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

Build two client bundles — ES5 and ES6 #855

Merged
merged 6 commits into from
Mar 3, 2022
Merged
Show file tree
Hide file tree
Changes from 5 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
39 changes: 39 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@


module.exports = (api) => {
api.cache(true);
return {
passPerPreset: true,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This helps with VisualizationManifest class which only has fileds declaration within constructor.

plugins: [
"@babel/plugin-proposal-class-properties"
],
presets: [
"@babel/preset-typescript",
["@babel/preset-react", {
development: false,
useBuiltIns: true,
}]
],
env: {
legacy: {
presets: [
["@babel/preset-env", {
modules: false,
targets: "> 0.25%, last 2 versions, Firefox ESR",
}],
],
},
modern: {
presets: [
["@babel/preset-env", {
modules: false,
targets: {
esmodules: true,
},
bugfixes: true,
}],
],
}
}
}
}
32 changes: 6 additions & 26 deletions config/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,6 @@ const path = require("path");

const MiniCssExtractPlugin = require("mini-css-extract-plugin");

const babelLoader = {
loader: "babel-loader",
options: {
presets: [
["@babel/preset-env", {
modules: false
}]
]
}
};

module.exports = {
devtool: "source-map",
output: {
Expand All @@ -49,23 +38,14 @@ module.exports = {
test: /\.js$/,
use: ["source-map-loader"]
},
{
test: /\.js?$/,
use: [
babelLoader
]
},
{
test: /\.tsx?$/,
use: [
babelLoader,
{
loader: "ts-loader",
options: {
configFile: "src/client/tsconfig.json"
}
use: [{
loader: "babel-loader",
options: {
envName: "modern"
}
]
}]
},
{
test: /\.css$/,
Expand All @@ -89,7 +69,7 @@ module.exports = {
// Returns a data-url (data:font/woff;charset=utf-8;base64,...)
// if the file is smaller than a byte limit.
limit: 8192,
},
}
},
{
test: /\.svg$/,
Expand Down
4 changes: 2 additions & 2 deletions config/webpack.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
* limitations under the License.
*/

const common = require("./webpack.common");
const commonConfig = require("./webpack.common");
const merge = require("webpack-merge");
const webpack = require('webpack');
const hotMiddlewareScript = 'webpack-hot-middleware/client';

module.exports = merge.smart(common, {
module.exports = merge.smart(commonConfig, {
mode: 'development',
entry: {
main: [hotMiddlewareScript, "./src/client/main.tsx"]
Expand Down
30 changes: 27 additions & 3 deletions config/webpack.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
* limitations under the License.
*/

const common = require('./webpack.common');
const commonConfig = require('./webpack.common');
const merge = require('webpack-merge');
const webpack = require('webpack');
const TerserPlugin = require('terser-webpack-plugin');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');

module.exports = merge.smart(common, {
const prodConfig = {
name: "client-modern",
mode: "production",
entry: {
main: "./src/client/main.tsx",
Expand All @@ -35,4 +36,27 @@ module.exports = merge.smart(common, {
'process.env.NODE_ENV': JSON.stringify('production')
}),
]
});
};

const es5Config = {
module: {
rules: [{
test: /\.tsx?$/,
use: [{
loader: "babel-loader",
options: {
envName: "legacy",
},
}],
}]
},
name: "client-legacy",
output: {
filename: "[name].es5.js",
}
};

module.exports = [
merge.smart(commonConfig, prodConfig),
merge.smart(commonConfig, prodConfig, es5Config),
]
6 changes: 3 additions & 3 deletions cypress/integration/scatterplot.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ context("Scatterplot", () => {
})

it('should render rectangles', () => {
rectangles().should("have.length", 77);
rectangles().should("have.length", 154);
})
});

Expand All @@ -75,7 +75,7 @@ context("Scatterplot", () => {
});

it("should load ticks on X axis", () => {
xAxis().find(".tick").should("have.length", 8);
xAxis().find(".tick").should("have.length", 15);
});

it("should load ticks on Y axis", () => {
Expand All @@ -90,7 +90,7 @@ context("Scatterplot", () => {
});

it("should load ticks on X axis", () => {
xAxis().find(".tick").should("have.length", 4);
xAxis().find(".tick").should("have.length", 8);
});

it("should load ticks on Y axis", () => {
Expand Down
Loading