From 2290b1b1a8cc0d397e34d6e2be01c5d72474b582 Mon Sep 17 00:00:00 2001 From: literat Date: Wed, 24 Jan 2024 11:16:51 +0100 Subject: [PATCH] Chore(web-react): Fix resolving parent id while building CJS bundle * 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 --- packages/web-react/config/rollup.config.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/web-react/config/rollup.config.js b/packages/web-react/config/rollup.config.js index 9b7296e97e..84737a97c3 100644 --- a/packages/web-react/config/rollup.config.js +++ b/packages/web-react/config/rollup.config.js @@ -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'; @@ -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}`; @@ -86,8 +88,10 @@ function prepareCJS(input, output) { externalLiveBindings: false, }, plugins: [ + resolve(), replace({ 'process.env.NODE_ENV': JSON.stringify('development'), + preventAssignment: true, }), ], };