Skip to content

Commit

Permalink
Default perspective-viewer to inline build due to webpack confusion
Browse files Browse the repository at this point in the history
  • Loading branch information
texodus committed Sep 28, 2021
1 parent 31f2fc7 commit 44b171e
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 12 deletions.
6 changes: 6 additions & 0 deletions packages/perspective-webpack-plugin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ class PerspectiveWebpackPlugin {
);
plugin_replace.apply(compiler);

const plugin_replace2 = new webpack.NormalModuleReplacementPlugin(
/@finos\/perspective\-viewer$/,
"@finos/perspective-viewer/dist/esm/index.js"
);
plugin_replace2.apply(compiler);

moduleOptions.rules = (moduleOptions.rules || []).concat(rules);
}
}
Expand Down
3 changes: 3 additions & 0 deletions packages/perspective-webpack-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,8 @@
"postcss-loader": "^4.1.0",
"string-replace-loader": "^3.0.1",
"worker-loader": "^3.0.7"
},
"peerDependencies": {
"webpack": "^5.0.0"
}
}
27 changes: 23 additions & 4 deletions packages/perspective/src/config/common.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,23 @@ function common({no_minify, inline} = {}) {
exclude: /node_modules\/(?!regular-table)/,
loader: "source-map-loader",
},
inline
? undefined
: {
test: /\.js$/,
exclude: /node_modules/,
use: [
{
loader: require.resolve(
"string-replace-loader"
),
options: {
search: /webpackMode:\s*?"eager"/g,
replace: "",
},
},
],
},
{
test: /\.(arrow)$/,
type: "javascript/auto",
Expand Down Expand Up @@ -108,11 +125,13 @@ function common({no_minify, inline} = {}) {
test: /editor\.worker/,
type: "javascript/auto",
loader: "worker-loader",
options: {
inline: "no-fallback",
},
options: inline
? {
inline: "no-fallback",
}
: {},
},
],
].filter((x) => !!x),
},
resolve: {
fallback: {
Expand Down
11 changes: 6 additions & 5 deletions rust/perspective-viewer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"url": "https://github.com/finos/perspective"
},
"license": "Apache-2.0",
"main": "dist/esm/index.js",
"module": "dist/esm/index.js",
"browser": "dist/esm/index.js",
"main": "dist/umd/perspective-viewer.inline.js",
"module": "dist/umd/perspective-viewer.inline.js",
"browser": "dist/umd/perspective-viewer.inline.js",
"unpkg": "dist/umd/perspective-viewer.js",
"jsdelvr": "dist/umd/perspective-viewer.js",
"files": [
Expand All @@ -21,8 +21,9 @@
"scripts": {
"build:wasm": "wasm-pack build --out-dir dist/pkg --target web && rm dist/pkg/package.json",
"build:rollup": "rollup --config rollup.config.js",
"build:webpack": "webpack --color --config webpack.config.js",
"build": "npm-run-all build:rollup build:wasm build:webpack && cpx 'src/less/*' dist/less",
"build:webpack:inline": "webpack --color --config webpack.inline.config.js",
"build:webpack:umd": "webpack --color --config webpack.config.js",
"build": "npm-run-all build:rollup build:wasm build:webpack:* && cpx 'src/less/*' dist/less",
"watch:wasm": "cargo watch -i .gitignore -i \"pkg/*\" -i \"src/js/*\" -s \"yarn build:wasm\"",
"watch:rollup": "rollup --watch --config rollup.config.js",
"watch:webpack": "webpack --watch --color --config webpack.config.js",
Expand Down
5 changes: 4 additions & 1 deletion rust/perspective-viewer/src/less/viewer.less
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@

.modal-target {
border: 1px dashed var(--inactive--color, #ccc) !important;
background-color: var(--modal-target--background, rgba(255, 255, 255, 0.5));
background-color: var(
--modal-target--background,
rgba(255, 255, 255, 0.5)
);
}

#add-expression.modal-target {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ impl ExpressionEditor {
self.props.on_init.emit(());
if let Some(expr) = self.expression.borrow_mut().take() {
editor.set_value(&expr);
} else {
self.set_default_content();
}

Ok(JsValue::UNDEFINED)
Expand Down
4 changes: 2 additions & 2 deletions rust/perspective-viewer/test/results/results.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"superstore.html/doesn't leak elements.": "d0fd18b3d4d7c183c5ed155b4bf37972",
"superstore.html/doesn't leak views when setting row pivots.": "54daaa4bbbe59f6ed4acc301ba871bab",
"superstore.html/doesn't leak views when setting filters.": "6dfc1e505f1428424c3265f0236f22fc",
"__GIT_COMMIT__": "91c222a116e1a0afeaefbbe363eefda26cbae201",
"__GIT_COMMIT__": "04ab695006097bdbf45a97b2bfad0db62d9e0246",
"blank.html/Handles reloading with a schema.": "e58c62f6e0ff16dc4d753f99e0fc39c3",
"superstore_shows_a_grid_without_any_settings_applied_": "ae1c4690d978598ca14c8669244ce604",
"superstore_Responsive_Layout_shows_horizontal_columns_on_small_vertical_viewports_": "57ba3ad341cf8a0e4df6ab96715ff2a0",
Expand Down Expand Up @@ -32,7 +32,7 @@
"superstore_filters_filters_by_a_DateTime_column": "b4b650f4a67c96a23b550c52a8f61a9d",
"superstore_filters_filters_by_an_alpha_column": "882dfb8d474600d7127f7fed09db7be9",
"superstore_filters_filters_with__in__comparator": "519e0643ff7d160eaab0d42fbb3211bc",
"Expressions_click_on_add_column_button_opens_the_expression_UI_": "0bcc6969da6a9acd3f8ef2f1ea47e112",
"Expressions_click_on_add_column_button_opens_the_expression_UI_": "ef5c3bd33fa42785eb5663117d559ee4",
"Expressions_blur_closes_the_expression_UI_": "10d1208b485425756fcc932229386b02",
"Expressions_Should_show_both_aliased_and_non-aliased_expressions_in_columns": "6da759b66b34a835f42f27a7f5e863ff",
"Expressions_An_expression_with_unknown_symbols_should_disable_the_save_button": "075ae3d2fc31640504f814f60e5ef713",
Expand Down
20 changes: 20 additions & 0 deletions rust/perspective-viewer/webpack.inline.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const path = require("path");
const common = require("@finos/perspective/src/config/common.config.js");

let idx = 0;

module.exports = common({inline: true}, (config) => {
return Object.assign(config, {
entry: {
"perspective-viewer": "./dist/esm/index.js",
},
output: {
filename: "[name].inline.js",
libraryTarget: "umd",
path: path.resolve(__dirname, "./dist/umd"),
},
experiments: {
syncWebAssembly: true,
},
});
});

0 comments on commit 44b171e

Please sign in to comment.