|
|
# Using `@unitybase/ub-pub` with WebPack
|
|
|
|
|
|
Using the `@unitybase/ub-pub` package with WebPack has some specifics.
|
|
|
UnityBase code is not ES5, it contains ES2015 constructs, like using `const` and `let` keywords, and other. That is why it needs to be transpiled first.
|
|
|
|
|
|
But a typical WebPack configuration explicitly includes project source code, which means all content of `node_modules` does straight, not babelified.
|
|
|
That causes problems during build, because UnityBase code does use JavaScript features beyond ES5 standard.
|
|
|
|
|
|
In order to workaround that, include /@unitybase/ expression into configuration of `babel-loader`, like that:
|
|
|
```javascript
|
|
|
{
|
|
|
test: /\.js$/,
|
|
|
loader: 'babel-loader',
|
|
|
include: [
|
|
|
resolve('src'),
|
|
|
resolve('test'),
|
|
|
/@unitybase/
|
|
|
]
|
|
|
},
|
|
|
``` |