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 29, 2021
1 parent 4c40bf6 commit e7e6b46
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 9 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
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 e7e6b46

Please sign in to comment.