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

how to apply code splitting? #38

Open
guoerwei opened this issue Mar 12, 2018 · 2 comments
Open

how to apply code splitting? #38

guoerwei opened this issue Mar 12, 2018 · 2 comments

Comments

@guoerwei
Copy link

�I tried dynamic import, but failed.
any examples?

@rokoroku
Copy link
Owner

Could you provide your code example here? I can help you then

@ghost
Copy link

ghost commented Mar 20, 2018

I was able to get dynamic import working with the below code and changing the target and module settings in tsconfig.json to esnext. However, something with that change breaks the production css extraction and results in an empty style.css file. Not sure what is causing that though.

Change main.tsx to:

ReactDom.render(
    <div>
        <button onClick={e => import('app/utils/print').then(module => {
            module.default();
        })}>Click me and look at the console!</button>
    </div>,
    document.getElementById('root')
);

print.ts in app/utils/print:

console.log('The print.ts module has loaded! See the network tab in dev tools...');

export default () => {
    console.log('Button Clicked: Here\'s "some text"!');
}

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

No branches or pull requests

2 participants