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

Fix sourcemaps by refactoring the build system #11843

Merged
merged 24 commits into from
Jan 15, 2020
Merged

Conversation

turt2live
Copy link
Member

@turt2live turt2live commented Jan 13, 2020

Fixes #8880

Requires matrix-org/matrix-react-sdk#3839
Requires matrix-org/matrix-js-sdk#1151

All the commits before 3b688aa have been reviewed already. This PR just needs the checkmark for 3b688aa and beyond.


Developer info: Migration guide

New developers to the project can just follow the existing instructions in the README - these are unchanged. Existing developers may find themselves unable to compile Riot after this PR and its associates land.

Existing developers: Cancel your existing webpack dev server if it is running then pull the latest develop. In each layer, yarn install then yarn build to regenerate some of the project's files (component index, etc). There are faster ways, but this is the easiest to write down. After all 3 layers have been installed and built, feel free to run yarn start in riot-web again and notice that the app looks exactly the same. Your development process is the same as it was before: start the day with yarn start and hack away.

Oh, also your sourcemaps should be working now.

New development practices

The build system is shiny and new, but overall not terribly exciting. Along the way some decisions have been made about our development practices that you may or may not notice:

  1. MatrixClientPeg is no longer a default export. Import it with import {MatrixClientPeg} from "./MatrixClientPeg";
  2. The react-sdk should be imported with import * as sdk from "./index"; instead of import sdk from "./index";
  3. Always import from the source directory where possible. For example, import {Room} from "matrix-js-sdk/src/models/room";
  4. Avoid require() in the imports like the plague.
  5. In the js-sdk, do not use export default and remember to add things to the index.ts file.
  6. In the react-sdk/riot-web, always export default components but avoid export default for utilities and not-components.
  7. Throughout the layers, do not use module.exports unless you have to (like in the end-to-end tests which are run by Node directly).
  8. TypeScript is possible for not-components across all 3 layers - use it for new code where possible/reasonable. TypeScript support for components is coming later.
  9. There's a boatload more CI jobs - these are mostly sanity checks. If they pass, you're good. If they don't, well, at least they're narrowly scoped.
  10. When not using TypeScript, use ES6 where reasonable.

#riot-dev is the best place to question any of these decisions, though many of them are just riot-web being thrust forward by 3-4 years in terms of ecosystem support.

Remove now-retired package.json property
This moves the babel and postcss configs into the webpack config for ease of maintenance (and because we need variations of them). The typescript config is left outside the webpack config for IDEs to pick it up.
We compile directly for accuracy of sourcemaps.
Import from src/ for the react-sdk and js-sdk
For reasons described within this diff.
We have to convert *something* to TypeScript so it doesn't complain that there's nothing to compile, so this converts the easiest utility library.

Many of the scripts are copied from the react-sdk.
Make the webpack config work for us
Sourcemaps: develop -> feature branch
We previously ignored this whole directory, and it's a bit of wishful thinking that we'll have these delinted as a result.

Switching to Jest should fix most of the problems anyways, so we can enable the linter when we get there.
There's a bunch of generated files that webpack relies on to work, and Karma works off webpack. To make both happy we've added
a new `build:genfiles` script which takes care of this for us. We also have to install and build our other layers to get the
same effect (like generating the react-sdk's component index, while we still have one).

This commit also fixes all the imports in the tests because they were just wrong. They should have been caught in the ES6ification
earlier, but were missed.
@turt2live turt2live marked this pull request as ready for review January 14, 2020 03:40
@turt2live turt2live requested a review from a team January 14, 2020 03:40
electron_app/src/updater.js Outdated Show resolved Hide resolved
@turt2live turt2live requested a review from dbkr January 14, 2020 17:03
@turt2live turt2live merged commit 599b263 into develop Jan 15, 2020
@turt2live turt2live deleted the travis/sourcemaps branch January 15, 2020 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Source maps seem to be invalid, breakpoints don't work
2 participants