No idea what causing such behavior. Used to work. Could it be any module? Tried changing code to debug but no luck.
[!] TypeError: Cannot read property 'resolveId' of undefined
TypeError: Cannot read property 'resolveId' of undefined
at /home/sz/project/next-book2/node_modules/rollup-plugin-commonjs/src/resolve-id.js:69:19
at Array.map (<anonymous>)
at Function.resolveId.setRollupOptions (/home/sz/project/next-book2/node_modules/rollup-plugin-commonjs/src/resolve-id.js:49:5)
at Object.options (/home/sz/project/next-book2/node_modules/rollup-plugin-commonjs/src/index.js:51:14)
at applyOptionHook (/home/sz/project/next-book2/node_modules/rollup/dist/rollup.js:17155:31)
at Array.reduce (<anonymous>)
at getInputOptions (/home/sz/project/next-book2/node_modules/rollup/dist/rollup.js:17176:54)
at Object.rollup (/home/sz/project/next-book2/node_modules/rollup/dist/rollup.js:17249:30)
at build (/home/sz/project/next-book2/node_modules/rollup/dist/bin/rollup:766:22)
at /home/sz/project/next-book2/node_modules/rollup/dist/bin/rollup:1340:24
Here is rollup.config.js:
import resolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs'
import { terser } from 'rollup-plugin-terser'
import sass from 'rollup-plugin-sass'
import html from 'rollup-plugin-html'
import livereload from 'rollup-plugin-livereload'
const environment = process.env.NODE_ENV || 'development';
const prod = environment === 'production';
const watch = process.env.ROLLUP_WATCH;
const WATCH_FORMAT = process.env.WATCH_FORMAT || 'umd';
const formats = ['umd', 'iife', 'cjs', 'es'];
const extension = prod ? 'min.js' : 'js';
const createOutput = (format = 'umd') => ({
sourcemap: !prod,
name: 'name',
file: `dist/${format}/index.${extension}`,
format
});
export default (watch ? [WATCH_FORMAT] : formats).map(format => ({
input: 'src/index.js',
output: createOutput(format),
plugins: [
sass({
// Filename to write all styles
output: 'dist/index.css',
options: {
importer(path) {
return { file: path.replace(/^@/, 'node_modules/@') };
}
}
}),
html({
include: 'src/**/*.html'
}),
resolve({
browser: true,
}), // tells Rollup how to find modules in node_modules
commonjs(), // converts modules to ES modules,
watch && livereload('dist'),
prod && terser(), // minify, but only in production
],
watch: {
clearScreen: false,
include: 'src/**/*'
}
}));
Ok I found what was the problem, running rollup-plugin-livereload in prod/non-watch mode caused this. Not sure why but I guess it doesn't matter cause It should be running only in watch mode.
No idea what causing such behavior. Used to work. Could it be any module? Tried changing code to debug but no luck.
Here is rollup.config.js: