enonic / starter-webpack

Starter for Enonic XP app built with Webpack
Other
0 stars 0 forks source link

Transpile and bundle serverside code #4

Closed ComLock closed 5 years ago

ComLock commented 5 years ago

Transpile ecmascript and typescript to javascript. Bundle node_modules. Keep Enonic XP libs as externals.

Support a bunch of common file extentions?

alansemenov commented 5 years ago

Transpile ecmascript and typescript to javascript.

Yes.

Bundle node_modules.

Mmm.... Not necessary, should be optional. I think we will describe this in the starter docs, @mta. "If you want to import an external NPM module, it has to be bundled together with the app assets, like this: ..."

Keep Enonic XP libs as externals.

Not sure what this means? They are bundled in the jar if the app has dependencies to them.

Support a bunch of common file extentions?

We cannot support all of them. Again, we need to describe this in the docs. @mta, let's add a separate section on the webpack.config.js where we describe how to expanded supported extensions.

ComLock commented 5 years ago

Webpack will fail if it discovers an import it can't find. To avoid this one can configure externals. Typically I configure a regular expression such that any import that starts with a slash is an external library.

If you use relative paths webpack will bundle the imported functions. If you use absolute paths webpack will not bundle and resolving the imports happens runtime.

ComLock commented 5 years ago

The "problem" with using externals is that if you reference a library that's not present in the jar you will get a runtime error.

You can write your own webpack resolver plugin, so it should be possible to look inside the jar files and give a build time resolve error.