Skip to content

Commit

Permalink
Chore(web-react): Fix resolving parent id while building CJS bundle
Browse files Browse the repository at this point in the history
  * first parent id given is `undefined` because it is a starting point
  * use `resolve` plugin to find directory indexes (index.js)
  * set `preventAssignment` to true because it will be the default in
    the next Rollup release
  • Loading branch information
literat committed Feb 20, 2024
1 parent 3e8b6fc commit e01c6a8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/web-react/config/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import resolve from '@rollup/plugin-node-resolve';
import replace from '@rollup/plugin-replace';
import path from 'path';
import { terser as minify } from 'rollup-plugin-terser';
Expand Down Expand Up @@ -45,7 +46,8 @@ function isExternal(id, parentId, entryPointsAreExternal = true) {
let absoluteId = id;
if (path.isAbsolute(id)) {
const posixId = toPosixPath(id);
const posixParentId = toPosixPath(parentId);
// parentId of the first entry point is undefined, because there is nothing abowe starting point
const posixParentId = parentId ? toPosixPath(parentId) : '';
absoluteId = path.posix.relative(path.posix.dirname(posixParentId), posixId);
if (!absoluteId.startsWith('.')) {
absoluteId = `./${absoluteId}`;
Expand Down Expand Up @@ -86,8 +88,10 @@ function prepareCJS(input, output) {
externalLiveBindings: false,
},
plugins: [
resolve(),
replace({
'process.env.NODE_ENV': JSON.stringify('development'),
preventAssignment: true,
}),
],
};
Expand Down

0 comments on commit e01c6a8

Please sign in to comment.