wevisdemo / design-systems

WeVis monorepo for design system documentation and cross-framework UI components
https://wevisdemo.github.io/design-systems/
MIT License
16 stars 2 forks source link

[React-Typescript] - Error: require() of ES Module #1

Closed Bariyard closed 1 year ago

Bariyard commented 1 year ago

Setup - repo politics-on-social

"@wevisdemo/ui": "^4.1.0"

cannot import module

import WvSharer from '@wevisdemo/ui/components/sharer';

ERROR

Server Error
Error: require() of ES Module /Users/bariyard-mothership/Developer/pu-project/politics-on-social/node_modules/@wevisdemo/ui/components/sharer.js from /Users/bariyard-mothership/Developer/pu-project/politics-on-social/.next/server/pages/index.js not supported.
Instead change the require of sharer.js in /Users/bariyard-mothership/Developer/pu-project/politics-on-social/.next/server/pages/index.js to a dynamic import() which is available in all CommonJS modules.

This error happened while generating the page. Any console logs will be displayed in the terminal window.
Call Stack
Object.@wevisdemo/ui/components/sharer
file:///Users/bariyard-mothership/Developer/pu-project/politics-on-social/.next/server/pages/index.js (273:18)
__webpack_require__
file:///Users/bariyard-mothership/Developer/pu-project/politics-on-social/.next/server/webpack-runtime.js (33:42)
eval
webpack-internal:///./pages/index.tsx (9:89)
Object../pages/index.tsx
file:///Users/bariyard-mothership/Developer/pu-project/politics-on-social/.next/server/pages/index.js (242:1)
__webpack_require__
file:///Users/bariyard-mothership/Developer/pu-project/politics-on-social/.next/server/webpack-runtime.js (33:42)
__webpack_exec__
file:///Users/bariyard-mothership/Developer/pu-project/politics-on-social/.next/server/pages/index.js (338:39)
<unknown>
file:///Users/bariyard-mothership/Developer/pu-project/politics-on-social/.next/server/pages/index.js (339:28)
Object.<anonymous>
file:///Users/bariyard-mothership/Developer/pu-project/politics-on-social/.next/server/pages/index.js (342:3)
Object.requirePage
file:///Users/bariyard-mothership/Developer/pu-project/politics-on-social/node_modules/next/dist/server/require.js (58:12)
<unknown>
file:///Users/bariyard-mothership/Developer/pu-project/politics-on-social/node_modules/next/dist/server/load-components.js (61:73)
async Object.loadComponents
file:///Users/bariyard-mothership/Developer/pu-project/politics-on-social/node_modules/next/dist/server/load-components.js (61:26)
async DevServer.findPageComponents
file:///Users/bariyard-mothership/Developer/pu-project/politics-on-social/node_modules/next/dist/server/next-server.js (555:36)
async DevServer.renderPageComponent
file:///Users/bariyard-mothership/Developer/pu-project/politics-on-social/node_modules/next/dist/server/base-server.js (891:24)
async DevServer.renderToResponse
file:///Users/bariyard-mothership/Developer/pu-project/politics-on-social/node_modules/next/dist/server/base-server.js (920:32)
async DevServer.pipe
file:///Users/bariyard-mothership/Developer/pu-project/politics-on-social/node_modules/next/dist/server/base-server.js (369:25)
async Object.fn
file:///Users/bariyard-mothership/Developer/pu-project/politics-on-social/node_modules/next/dist/server/next-server.js (743:21)
async Router.execute
file:///Users/bariyard-mothership/Developer/pu-project/politics-on-social/node_modules/next/dist/server/router.js (247:36)
async DevServer.run
file:///Users/bariyard-mothership/Developer/pu-project/politics-on-social/node_modules/next/dist/server/base-server.js (347:29)
async DevServer.run
file:///Users/bariyard-mothership/Developer/pu-project/politics-on-social/node_modules/next/dist/server/dev/next-dev-server.js (709:20)
async DevServer.handleRequest
file:///Users/bariyard-mothership/Developer/pu-project/politics-on-social/node_modules/next/dist/server/base-server.js (285:20)
Th1nkK1D commented 1 year ago

Resolved in v4.1.1

I updated the package version and moved global CSS import to _app.tsx in https://github.com/wevisdemo/politics-on-social/commit/825e571b20c9394c13aeb9fc1ac37db766bfee12

The build was passed but failed to publish on GitHub page because we don't define secrets.ACTIONS_SECRET_KEY so I changed it to use Github Token which is predefined in the workflow https://github.com/wevisdemo/politics-on-social/commit/5429e2dcbab17fdd0afd475913f18c1275b1bfe2

And now the pipeline is green!