2023-06-30 09:50:40 +00:00
|
|
|
const fs = require('fs');
|
2020-05-20 04:50:46 +00:00
|
|
|
const MomentLocalesPlugin = require('moment-locales-webpack-plugin');
|
(core) Speed up and upgrade build.
Summary:
- Upgrades to build-related packages:
- Upgrade typescript, related libraries and typings.
- Upgrade webpack, eslint; add tsc-watch, node-dev, eslint_d.
- Build organization changes:
- Build webpack from original typescript, transpiling only; with errors still
reported by a background tsc watching process.
- Typescript-related changes:
- Reduce imports of AWS dependencies (very noticeable speedup)
- Avoid auto-loading global @types
- Client code is now built with isolatedModules flag (for safe transpilation)
- Use allowJs to avoid copying JS files manually.
- Linting changes
- Enhance Arcanist ESLintLinter to run before/after commands, and set up to use eslint_d
- Update eslint config, and include .eslintignore to avoid linting generated files.
- Include a bunch of eslint-prompted and eslint-generated fixes
- Add no-unused-expression rule to eslint, and fix a few warnings about it
- Other items:
- Refactor cssInput to avoid circular dependency
- Remove a bit of unused code, libraries, dependencies
Test Plan: No behavior changes, all existing tests pass. There are 30 tests fewer reported because `test_gpath.py` was removed (it's been unused for years)
Reviewers: paulfitz
Reviewed By: paulfitz
Subscribers: paulfitz
Differential Revision: https://phab.getgrist.com/D3498
2022-06-27 20:09:41 +00:00
|
|
|
const { ProvidePlugin } = require('webpack');
|
2020-05-20 04:50:46 +00:00
|
|
|
const path = require('path');
|
|
|
|
|
2023-02-13 20:52:17 +00:00
|
|
|
// Get path to top-level node_modules if in a yarn workspace.
|
|
|
|
// Otherwise node_modules one level up won't get resolved.
|
|
|
|
// This is used in Electron packaging.
|
|
|
|
const base = path.dirname(path.dirname(require.resolve('grainjs/package.json')));
|
|
|
|
|
2020-05-20 04:50:46 +00:00
|
|
|
module.exports = {
|
|
|
|
target: 'web',
|
|
|
|
entry: {
|
(core) Speed up and upgrade build.
Summary:
- Upgrades to build-related packages:
- Upgrade typescript, related libraries and typings.
- Upgrade webpack, eslint; add tsc-watch, node-dev, eslint_d.
- Build organization changes:
- Build webpack from original typescript, transpiling only; with errors still
reported by a background tsc watching process.
- Typescript-related changes:
- Reduce imports of AWS dependencies (very noticeable speedup)
- Avoid auto-loading global @types
- Client code is now built with isolatedModules flag (for safe transpilation)
- Use allowJs to avoid copying JS files manually.
- Linting changes
- Enhance Arcanist ESLintLinter to run before/after commands, and set up to use eslint_d
- Update eslint config, and include .eslintignore to avoid linting generated files.
- Include a bunch of eslint-prompted and eslint-generated fixes
- Add no-unused-expression rule to eslint, and fix a few warnings about it
- Other items:
- Refactor cssInput to avoid circular dependency
- Remove a bit of unused code, libraries, dependencies
Test Plan: No behavior changes, all existing tests pass. There are 30 tests fewer reported because `test_gpath.py` was removed (it's been unused for years)
Reviewers: paulfitz
Reviewed By: paulfitz
Subscribers: paulfitz
Differential Revision: https://phab.getgrist.com/D3498
2022-06-27 20:09:41 +00:00
|
|
|
main: "app/client/app",
|
|
|
|
errorPages: "app/client/errorMain",
|
(core) Improve API Console and link from Document Settings.
Summary:
Changes to building and serving:
- Remove unpkg dependencies, add npm module for swagger-ui-dist instead.
- Move apiconsole JS logic into core/app/client/apiconsole.ts, and use TypeScript.
- Add symlinks to swagger in static/ and core/static/.
- Refactor loadScript, and add loadCssFile; use these to load swagger-ui resources.
Changes to console itself:
- Support docId, workspaceId, orgId URL parameters. When present, the matching
value in dropdowns is moved to the front and marked as "(Current)".
- Fix the ordering of example values, particularly for workspaces.
- Remove unwanted example values.
- Hide confusing "Authorize" button.
- Hide API keys, and rely consistently on cookies for executing API calls.
Integration into Grist:
- Added a button to Document Settings, just under document ID in "API".
- The button opens a separate page, passing in org, workspace, and doc info for the current doc.
Test Plan: Only tested manually, no automated tests yet.
Reviewers: jarek
Reviewed By: jarek
Differential Revision: https://phab.getgrist.com/D4173
2024-01-27 04:21:34 +00:00
|
|
|
apiconsole: "app/client/apiconsole",
|
2022-08-22 19:46:25 +00:00
|
|
|
billing: "app/client/billingMain",
|
2024-02-21 19:22:01 +00:00
|
|
|
form: "app/client/formMain",
|
2023-06-30 09:50:40 +00:00
|
|
|
// Include client test harness if it is present (it won't be in
|
|
|
|
// docker image).
|
|
|
|
...(fs.existsSync("test/client-harness/client.js") ? {
|
|
|
|
test: "test/client-harness/client",
|
|
|
|
} : {}),
|
2020-05-20 04:50:46 +00:00
|
|
|
},
|
|
|
|
output: {
|
|
|
|
filename: "[name].bundle.js",
|
|
|
|
sourceMapFilename: "[file].map",
|
|
|
|
path: path.resolve("./static"),
|
|
|
|
// Workaround for a known issue with webpack + onerror under chrome, see:
|
|
|
|
// https://github.com/webpack/webpack/issues/5681
|
|
|
|
// "We use a source map plugin here with this special configuration
|
|
|
|
// because if we do not - the window.onerror function does not work properly in chrome
|
|
|
|
// and it swallows the errors because normally source maps have begin with webpack:///
|
|
|
|
// here we are changing how the module file names are created
|
|
|
|
// See this bug
|
|
|
|
// https://bugs.chromium.org/p/chromium/issues/detail?id=765909
|
|
|
|
// See this for syntax
|
|
|
|
// https://webpack.js.org/configuration/output/#output-devtoolmodulefilenametemplate
|
|
|
|
// "
|
|
|
|
devtoolModuleFilenameTemplate: "[resourcePath]?[loaders]",
|
|
|
|
crossOriginLoading: "anonymous",
|
|
|
|
},
|
|
|
|
// This creates .map files, and takes webpack a couple of seconds to rebuild while developing,
|
|
|
|
// but provides correct mapping back to typescript, and allows breakpoints to be set in
|
|
|
|
// typescript ("cheap-module-eval-source-map" is faster, but breakpoints are largely broken).
|
|
|
|
devtool: "source-map",
|
|
|
|
resolve: {
|
(core) Speed up and upgrade build.
Summary:
- Upgrades to build-related packages:
- Upgrade typescript, related libraries and typings.
- Upgrade webpack, eslint; add tsc-watch, node-dev, eslint_d.
- Build organization changes:
- Build webpack from original typescript, transpiling only; with errors still
reported by a background tsc watching process.
- Typescript-related changes:
- Reduce imports of AWS dependencies (very noticeable speedup)
- Avoid auto-loading global @types
- Client code is now built with isolatedModules flag (for safe transpilation)
- Use allowJs to avoid copying JS files manually.
- Linting changes
- Enhance Arcanist ESLintLinter to run before/after commands, and set up to use eslint_d
- Update eslint config, and include .eslintignore to avoid linting generated files.
- Include a bunch of eslint-prompted and eslint-generated fixes
- Add no-unused-expression rule to eslint, and fix a few warnings about it
- Other items:
- Refactor cssInput to avoid circular dependency
- Remove a bit of unused code, libraries, dependencies
Test Plan: No behavior changes, all existing tests pass. There are 30 tests fewer reported because `test_gpath.py` was removed (it's been unused for years)
Reviewers: paulfitz
Reviewed By: paulfitz
Subscribers: paulfitz
Differential Revision: https://phab.getgrist.com/D3498
2022-06-27 20:09:41 +00:00
|
|
|
extensions: ['.ts', '.js'],
|
2020-05-20 04:50:46 +00:00
|
|
|
modules: [
|
(core) Speed up and upgrade build.
Summary:
- Upgrades to build-related packages:
- Upgrade typescript, related libraries and typings.
- Upgrade webpack, eslint; add tsc-watch, node-dev, eslint_d.
- Build organization changes:
- Build webpack from original typescript, transpiling only; with errors still
reported by a background tsc watching process.
- Typescript-related changes:
- Reduce imports of AWS dependencies (very noticeable speedup)
- Avoid auto-loading global @types
- Client code is now built with isolatedModules flag (for safe transpilation)
- Use allowJs to avoid copying JS files manually.
- Linting changes
- Enhance Arcanist ESLintLinter to run before/after commands, and set up to use eslint_d
- Update eslint config, and include .eslintignore to avoid linting generated files.
- Include a bunch of eslint-prompted and eslint-generated fixes
- Add no-unused-expression rule to eslint, and fix a few warnings about it
- Other items:
- Refactor cssInput to avoid circular dependency
- Remove a bit of unused code, libraries, dependencies
Test Plan: No behavior changes, all existing tests pass. There are 30 tests fewer reported because `test_gpath.py` was removed (it's been unused for years)
Reviewers: paulfitz
Reviewed By: paulfitz
Subscribers: paulfitz
Differential Revision: https://phab.getgrist.com/D3498
2022-06-27 20:09:41 +00:00
|
|
|
path.resolve('.'),
|
|
|
|
path.resolve('./ext'),
|
|
|
|
path.resolve('./stubs'),
|
2023-02-13 20:52:17 +00:00
|
|
|
path.resolve('./node_modules'),
|
|
|
|
base,
|
2020-05-20 04:50:46 +00:00
|
|
|
],
|
(core) Speed up and upgrade build.
Summary:
- Upgrades to build-related packages:
- Upgrade typescript, related libraries and typings.
- Upgrade webpack, eslint; add tsc-watch, node-dev, eslint_d.
- Build organization changes:
- Build webpack from original typescript, transpiling only; with errors still
reported by a background tsc watching process.
- Typescript-related changes:
- Reduce imports of AWS dependencies (very noticeable speedup)
- Avoid auto-loading global @types
- Client code is now built with isolatedModules flag (for safe transpilation)
- Use allowJs to avoid copying JS files manually.
- Linting changes
- Enhance Arcanist ESLintLinter to run before/after commands, and set up to use eslint_d
- Update eslint config, and include .eslintignore to avoid linting generated files.
- Include a bunch of eslint-prompted and eslint-generated fixes
- Add no-unused-expression rule to eslint, and fix a few warnings about it
- Other items:
- Refactor cssInput to avoid circular dependency
- Remove a bit of unused code, libraries, dependencies
Test Plan: No behavior changes, all existing tests pass. There are 30 tests fewer reported because `test_gpath.py` was removed (it's been unused for years)
Reviewers: paulfitz
Reviewed By: paulfitz
Subscribers: paulfitz
Differential Revision: https://phab.getgrist.com/D3498
2022-06-27 20:09:41 +00:00
|
|
|
fallback: {
|
|
|
|
'path': require.resolve("path-browserify"),
|
|
|
|
},
|
2020-05-20 04:50:46 +00:00
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
(core) Speed up and upgrade build.
Summary:
- Upgrades to build-related packages:
- Upgrade typescript, related libraries and typings.
- Upgrade webpack, eslint; add tsc-watch, node-dev, eslint_d.
- Build organization changes:
- Build webpack from original typescript, transpiling only; with errors still
reported by a background tsc watching process.
- Typescript-related changes:
- Reduce imports of AWS dependencies (very noticeable speedup)
- Avoid auto-loading global @types
- Client code is now built with isolatedModules flag (for safe transpilation)
- Use allowJs to avoid copying JS files manually.
- Linting changes
- Enhance Arcanist ESLintLinter to run before/after commands, and set up to use eslint_d
- Update eslint config, and include .eslintignore to avoid linting generated files.
- Include a bunch of eslint-prompted and eslint-generated fixes
- Add no-unused-expression rule to eslint, and fix a few warnings about it
- Other items:
- Refactor cssInput to avoid circular dependency
- Remove a bit of unused code, libraries, dependencies
Test Plan: No behavior changes, all existing tests pass. There are 30 tests fewer reported because `test_gpath.py` was removed (it's been unused for years)
Reviewers: paulfitz
Reviewed By: paulfitz
Subscribers: paulfitz
Differential Revision: https://phab.getgrist.com/D3498
2022-06-27 20:09:41 +00:00
|
|
|
{
|
|
|
|
test: /\.(js|ts)?$/,
|
|
|
|
loader: 'esbuild-loader',
|
|
|
|
options: {
|
|
|
|
loader: 'ts',
|
|
|
|
target: 'es2017',
|
|
|
|
sourcemap: true,
|
|
|
|
},
|
|
|
|
exclude: /node_modules/
|
|
|
|
},
|
2020-05-20 04:50:46 +00:00
|
|
|
{ test: /\.js$/,
|
|
|
|
use: ["source-map-loader"],
|
|
|
|
enforce: "pre"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
plugins: [
|
(core) Speed up and upgrade build.
Summary:
- Upgrades to build-related packages:
- Upgrade typescript, related libraries and typings.
- Upgrade webpack, eslint; add tsc-watch, node-dev, eslint_d.
- Build organization changes:
- Build webpack from original typescript, transpiling only; with errors still
reported by a background tsc watching process.
- Typescript-related changes:
- Reduce imports of AWS dependencies (very noticeable speedup)
- Avoid auto-loading global @types
- Client code is now built with isolatedModules flag (for safe transpilation)
- Use allowJs to avoid copying JS files manually.
- Linting changes
- Enhance Arcanist ESLintLinter to run before/after commands, and set up to use eslint_d
- Update eslint config, and include .eslintignore to avoid linting generated files.
- Include a bunch of eslint-prompted and eslint-generated fixes
- Add no-unused-expression rule to eslint, and fix a few warnings about it
- Other items:
- Refactor cssInput to avoid circular dependency
- Remove a bit of unused code, libraries, dependencies
Test Plan: No behavior changes, all existing tests pass. There are 30 tests fewer reported because `test_gpath.py` was removed (it's been unused for years)
Reviewers: paulfitz
Reviewed By: paulfitz
Subscribers: paulfitz
Differential Revision: https://phab.getgrist.com/D3498
2022-06-27 20:09:41 +00:00
|
|
|
// Some modules assume presence of Buffer and process.
|
|
|
|
new ProvidePlugin({
|
|
|
|
process: 'process/browser',
|
|
|
|
Buffer: ['buffer', 'Buffer']
|
|
|
|
}),
|
2020-05-20 04:50:46 +00:00
|
|
|
// To strip all locales except “en”
|
|
|
|
new MomentLocalesPlugin()
|
|
|
|
],
|
2023-06-27 06:11:08 +00:00
|
|
|
externals: {
|
|
|
|
// for test bundle: jsdom should not be touched within browser
|
|
|
|
jsdom: 'alert',
|
|
|
|
// for test bundle: jquery will be available as jQuery
|
|
|
|
jquery: 'jQuery'
|
|
|
|
},
|
2020-05-20 04:50:46 +00:00
|
|
|
};
|