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

Loading modes on demand #113

Open
jwheare opened this issue Dec 15, 2017 · 2 comments
Open

Loading modes on demand #113

jwheare opened this issue Dec 15, 2017 · 2 comments

Comments

@jwheare
Copy link

jwheare commented Dec 15, 2017

Vanilla ace manages loading in syntax modes on demand whenever they're set, without having to specify them all up front. Our editor has a drop down to choose syntax from all the available modes and we don't want to include all the modes in our webpack bundle.

Is there a way to do this that doesn't involve something like this?

require('brace/mode/a');
require('brace/mode/b');
...
require('brace/mode/z');
@JackuB
Copy link

JackuB commented Jan 17, 2018

You could create this logic on your own using import()/require.ensure and then change Ace mode in callback.

// pseudocode solution
select.on('change', () => {
  import('brace/mode/javascript').then(() => editor.getSession().setMode('ace/mode/javascript'))
})

You could get fancy with chunk names etc.

@jwheare
Copy link
Author

jwheare commented Jan 17, 2018

Thanks, I've tried at various points to get webpack dynamic import working but I can't get my head around it alongside our existing CommonsChunkPlugin setup. I switched back to using vanilla ace outside webpack.

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