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 broken webpack build in browser #2752

Merged
merged 1 commit into from
Jun 25, 2021
Merged

Conversation

dapplion
Copy link
Contributor

@dapplion dapplion commented Jun 25, 2021

Motivation

Lightclient UI build emits warnings when trying to import .d.ts files with a require statement.

Failed to compile.

./node_modules/@chainsafe/lodestar-config/lib/chainConfig/presets/mainnet.d.ts 2:7
Module parse failed: Unexpected token (2:7)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| import { IChainConfig } from "../types";
> export declare const chainConfig: IChainConfig;
| //# sourceMappingURL=mainnet.d.ts.map

./node_modules/@chainsafe/lodestar-config/lib/chainConfig/presets/minimal.d.ts 2:7
Module parse failed: Unexpected token (2:7)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| import { IChainConfig } from "../types";
> export declare const chainConfig: IChainConfig;
| //# sourceMappingURL=minimal.d.ts.map

https://github.com/ChainSafe/eth2-light-client-demo/runs/2914224290

Description

Change how the config presets are imported to match lodestar-params

switch (process.env.LODESTAR_PRESET) {
case PresetName.minimal:
ACTIVE_PRESET = PresetName.minimal;
preset = minimal;
break;
case PresetName.mainnet:
default:
ACTIVE_PRESET = PresetName.mainnet;
preset = mainnet;
break;

It does not cause the warnings anymore, and does not need using a dynamic require statement.

Note that the ACTIVE_PRESET env technically arbitrary so it's a bit fishy to have a dynamic non-controlled import there when it's not strictly necessary.

@codeclimate
Copy link

codeclimate bot commented Jun 25, 2021

Code Climate has analyzed commit 755183b and detected 0 issues on this pull request.

View more on Code Climate.

...BeaconPreset.fields,
...ChainConfig.fields,
},
});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prevent running extra work that may not be needed

@dapplion dapplion force-pushed the dapplion/browser-config branch from 94739b5 to 755183b Compare June 25, 2021 15:35
Copy link
Member

@wemeetagain wemeetagain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks :)

@wemeetagain wemeetagain merged commit 3fb5bb1 into master Jun 25, 2021
@wemeetagain wemeetagain deleted the dapplion/browser-config branch June 25, 2021 17:06
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.

2 participants