mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +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
This commit is contained in:
@@ -8,7 +8,9 @@
|
||||
|
||||
exports.loadBillingPage = () => import('app/client/ui/BillingPage' /* webpackChunkName: "BillingModule" */);
|
||||
exports.loadGristDoc = () => import('app/client/components/GristDoc' /* webpackChunkName: "GristDoc" */);
|
||||
exports.loadMomentTimezone = () => import('moment-timezone');
|
||||
// When importing this way, the module is under the "default" member, not sure why (maybe
|
||||
// esbuild-loader's doing).
|
||||
exports.loadMomentTimezone = () => import('moment-timezone').then(m => m.default);
|
||||
exports.loadPlotly = () => import('plotly.js-basic-dist' /* webpackChunkName: "plotly" */);
|
||||
exports.loadSearch = () => import('app/client/ui2018/search' /* webpackChunkName: "search" */);
|
||||
exports.loadUserManager = () => import('app/client/ui/UserManager' /* webpackChunkName: "usermanager" */);
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
/**
|
||||
* koSession offers observables whose values are tied to the browser session or history:
|
||||
*
|
||||
* sessionValue(key) - an observable preserved across history entries and reloads.
|
||||
*
|
||||
* Note: we could also support "browserValue", shared across all tabs and across browser restarts
|
||||
* (same as sessionValue but using window.localStorage), but it seems more appropriate to store
|
||||
* such values on the server.
|
||||
*/
|
||||
|
||||
/* global window, $ */
|
||||
|
||||
var _ = require('underscore');
|
||||
var ko = require('knockout');
|
||||
|
||||
/**
|
||||
* Maps a string key to an observable. The space of keys is shared for all kinds of observables,
|
||||
* and they differ only in where they store their state. Each observable gets several extra
|
||||
* properties:
|
||||
* @property {String} ksKey The key used for storage. It should be unique across koSession values.
|
||||
* @property {Object} ksDefault The default value if the storage doesn't have one.
|
||||
* @property {Function} ksFetch The method to fetch the value from storage.
|
||||
* @property {Function} ksSave The method to save the value to storage.
|
||||
*/
|
||||
var _sessionValues = {};
|
||||
|
||||
function createObservable(key, defaultValue, methods) {
|
||||
var obs = _sessionValues[key];
|
||||
if (!obs) {
|
||||
_sessionValues[key] = obs = ko.observable();
|
||||
obs.ksKey = key;
|
||||
obs.ksDefaultValue = defaultValue;
|
||||
obs.ksFetch = methods.fetch;
|
||||
obs.ksSave = methods.save;
|
||||
obs.dispose = methods.dispose;
|
||||
|
||||
// We initialize the observable before setting rateLimit, to ensure that the initialization
|
||||
// doesn't end up triggering subscribers that are about to be added (which seems to be a bit
|
||||
// of a problem with rateLimit extender, and possibly deferred). This workaround relies on the
|
||||
// fact that the extender modifies its target without creating a new one.
|
||||
obs(obs.ksFetch());
|
||||
obs.extend({deferred: true});
|
||||
|
||||
obs.subscribe(function(newValue) {
|
||||
if (newValue !== this.ksFetch()) {
|
||||
console.log("koSession: %s changed %s -> %s", this.ksKey, this.ksFetch(), newValue);
|
||||
this.ksSave(newValue);
|
||||
}
|
||||
}, obs);
|
||||
}
|
||||
return obs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an observable whose value sticks across reloads and navigation, but is different for
|
||||
* different browser tabs. E.g. it may be used to reflect whether a side pane is open.
|
||||
* The `key` isn't visible to the user, so pick any unique string name.
|
||||
*/
|
||||
function sessionValue(key, optDefault) {
|
||||
return createObservable(key, optDefault, sessionValueMethods);
|
||||
}
|
||||
exports.sessionValue = sessionValue;
|
||||
|
||||
var sessionValueMethods = {
|
||||
'fetch': function() {
|
||||
var value = window.sessionStorage.getItem(this.ksKey);
|
||||
if (!value) {
|
||||
return this.ksDefaultValue;
|
||||
}
|
||||
try {
|
||||
return JSON.parse(value);
|
||||
} catch (e) {
|
||||
return this.ksDefaultValue;
|
||||
}
|
||||
},
|
||||
'save': function(value) {
|
||||
window.sessionStorage.setItem(this.ksKey, JSON.stringify(value));
|
||||
},
|
||||
'dispose': function(value) {
|
||||
window.sessionStorage.removeItem(this.ksKey);
|
||||
}
|
||||
};
|
||||
|
||||
function onApplyState() {
|
||||
_.each(_sessionValues, function(obs, key) {
|
||||
obs(obs.ksFetch());
|
||||
});
|
||||
}
|
||||
|
||||
$(window).on('applyState', onApplyState);
|
||||
Reference in New Issue
Block a user