Skip to content

Commit

Permalink
Use custom package.json props to load src tree
Browse files Browse the repository at this point in the history
See diff for rationale
  • Loading branch information
turt2live committed Dec 23, 2019
1 parent 8b72d99 commit a1c9551
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ module.exports = (env, argv) => ({
},

resolve: {
// We define an alternative import path so we can safely use src/ across the react-sdk
// and js-sdk. We already import from src/ where possible to ensure our source maps are
// extremely accurate (and because we're capable of compiling the layers manually rather
// than relying on partially-mangled output from babel), though we do need to fix the
// package level import (stuff like `import {Thing} from "matrix-js-sdk"` for example).
// We can't use the aliasing down below to point at src/ because that'll fail to resolve
// the package.json for the dependency. Instead, we rely on the package.json of each
// layer to have our custom alternate fields to load things in the right order. These are
// the defaults of webpack prepended with `matrix_src_`.
mainFields: ['matrix_src_browser', 'matrix_src_main', 'browser', 'main'],
aliasFields: ['matrix_src_browser', 'browser'],

// We need to ensure we can resolve TS files, but that also means we need to define
// every single extension we might see, ever.
extensions: [
Expand Down

0 comments on commit a1c9551

Please sign in to comment.