create-react-library
create-react-library copied to clipboard
Object Spread not work properly on build mode
Object spread not work properly on build, but work fine on watch mode.
snippet from my redux-saga function
function* loginByEmailWorker(action) {
try {
const response = yield call(loginByPassword, ...action.payload);
yield put({ type: constants.AUTH_RECEIVE_LOGIN_BY_EMAIL, payload: response });
} catch (error) {
yield put({ type: constants.AUTH_RECEIVE_LOGIN_BY_EMAIL, payload:error });
}
}
action.payload that I spread is an array. it spread correctly when I use npm run start but not spread when I use npm run build.
theres no error, it just not spreading. it behave like Im not giving spread operator
I use the default config from this libary.
Any help ? Thanks
I have a similar problem with index.modern.js. During the "watch"
const d = new Set([1, 2, 3]); const e = [...d];
but after the build
var d = new Set([1, 2, 3]); var e = [].concat(d);
which is not the same at all.
I am also using the default config.
@mcapkovic This is caused by a problem in microbundle when exporting modules alongside cjs. In my case, when exporting a modern and cjs module. It was reported in the microbundle repo: https://github.com/developit/microbundle/issues/560 and was supposedly fixed back in June.
The problem is that create-react-library uses a fork of microbundle called microbundle-crl, which hasn't been updated with these fixes.
I'm also trying to find a sensible workaround for this right now.
It's probably also worth noting that swapping out microbundle-crl for microbundle did not help, it caused more problems.
@mcapkovic For now I'm just generating modern versions of my package:
"scripts": {
"build": "microbundle-crl --no-compress --format modern",
"start": "microbundle-crl watch --no-compress --format modern",
}
@PButcher Thank you.