Closed larsenwork closed 6 years ago
Eagle.js currently only has ES6 dist file. By default Nuxt would expect all your node_modules
files have CommonJS modules. So the ES6 module would fail.
You can add the following to your nuxt.config.js, inside build
-> extend
:
config.module.rules.push({
test: /\.(js)$/,
loader: 'babel-loader',
include: /(node_modules\/eagle.js)/
})
@yaodingyd thanks for the reply — tried the above and also stuff like
const babelLoader = config.module.rules.find(
rule => rule.loader === 'babel-loader'
)
babelLoader.exclude = /node_modules\/(?!eagle.js)/
but still get the same error. Any ideas?
You can go to node_modules/eagle.js/dist/eagle.js
and change all ES6 module to CommonJS module, namely:
import { throttle } from 'lodash';
import hljs from 'highlight.js';
...
// at the end of of file
export default main;
to
const throttle = require('lodash').throttle;
const hljs = require('highlight.js').default;
...
// at the end of of file
module.export = main;
Cheers, should anybody else be interested I ended up just using a subset like this (bundle size was initially very big): https://github.com/Zulko/eagle.js/compare/master...larsenwork:master#diff-1c90ff38a08209f9ebd4d05d1e43358e
And then changing rollup config to cjs https://github.com/Zulko/eagle.js/compare/master...larsenwork:master#diff-6928d5da7f63eff413032c5c409ba617
Reopen this for tracking CommonJS build
Cool, should be fairly easy with something like https://github.com/jonathantneal/postcss-lab-function/blob/master/.rollup.js#L6-L7 and then this in pkg json: https://github.com/jonathantneal/postcss-lab-function/blob/master/package.json#L10-L11
0.2.0
is out now :-)
Using it with Nuxt (with server side rendering turned off for the plugin) and I'm getting this error when I reload a page:
The vue file looks like this:
and I'm registering the plugin like this
and then like this in nuxt config