Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jan 26, 2019. It is now read-only.

Update tsconfig to support dynamic import#115

Merged
wmonk merged 4 commits intowmonk:masterfromnicolaserny:master
Jul 27, 2017

Conversation

@nicolaserny
Copy link
Contributor

resolves#90

In order to make code splitting work, we have to set the module to esnext in tsconfig.json

adambowles reacted with hooray emoji
@nicolaserny
Copy link
ContributorAuthor

@wmonk using esnext seems to have an impact on tests (SyntaxError: Unexpected token import).
The weird part is that tests (yarn test) work on my projects created with create react app ts + changing module to esnext.
I'm not sure it's a good idea to override the tsconfig file used by jest...

@nicolaserny
Copy link
ContributorAuthor

@wmonk only a temporary fix (for jest) becauseTS_CONFIG is deprecated
https://github.com/kulshekhar/ts-jest
as we provide a tsConfigFile value, the module is not overwritten to commonjs...

@DorianGrey
Copy link
Collaborator

What about creating atsconfig.test.json which uses theextends directive and overrides the module field along with the regulartsconfig.json, and update the reference totsConfigFile accordingly? Path may be added like the current one that references the regulartsconfig.json.

I.e.:
tsconfig.test.json

{"extends":"./tsconfig.json","compilerOptions": {"module":"commonjs"  }}

Add corresponding path entries inthis file, e.g.appTsTestConfig (keep in mind that there are multiple positions to be extended, i.e.L84 andL114.
As a last step, change the variablehere to your new one.

It's a bit tricky, but differentmodule values are required under different circumstances:

  • esnext for the dynamic import call
  • commonjs to get things working on node.js

Using different config files for both situations should be the way to go here.

nicolaserny and chachaxw reacted with thumbs up emoji

Copy link
Collaborator

@DorianGreyDorianGrey left a comment

Choose a reason for hiding this comment

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

@wmonk:
Change looks good technically. Your turn now :)

@wmonkwmonk merged commita445a40 intowmonk:masterJul 27, 2017
@wmonk
Copy link
Owner

Thanks!

Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

1 more reviewer

@DorianGreyDorianGreyDorianGrey approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Dynamic import not working

3 participants

@nicolaserny@DorianGrey@wmonk

[8]ページ先頭

©2009-2025 Movatter.jp