question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cloudflare with esbuild broken with v0.3.56

See original GitHub issue

Hi,

Since the latest version I get the following warning when trying to build with esbuild:

▲ [WARNING] Import “createPageRenderer” will always be undefined because the file “…/…/node_modules/vite-plugin-ssr/dist/esm/client/node.js” has no exports

worker/index.ts:1:9:
  1 │ import { createPageRenderer } from 'vite-plugin-ssr'
    ╵          ~~~~~~~~~~~~~~~~~~

When I ignore this warning, miniflare throws this error at me:

MiniflareCoreError [ERR_MOUNT]: Error mounting “project” […] { code: ‘ERR_MOUNT’, cause: Error: [vite-plugin-ssr@0.3.56][Wrong Usage] The module vite-plugin-ssr cannot be imported in the browser. Did you mean to import the module vite-plugin-ssr/client instead? at …/…/node_modules/vite-plugin-ssr/dist/esm/client/node.js (/…/dist/worker.js:197:5) at __init (/…dist/worker.js:9:56) at /…/dist/worker.js:47083:1

My `build.js` file which builds the worker
import esbuild from 'esbuild'
import { NodeModulesPolyfillPlugin } from '@esbuild-plugins/node-modules-polyfill'

esbuild
  .build({
    external: ['__STATIC_CONTENT_MANIFEST'],
    entryPoints: ['./worker/index.ts'],
    sourcemap: false,
    outfile: './dist/worker.js',
    logLevel: 'info',
    platform: 'browser',
    plugins: [NodeModulesPolyfillPlugin()],
    format: 'esm',
    target: 'es2020',
    bundle: true,
  })
  .then(() => console.log(`Successfully built worker.`))

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
brilloutcommented, Mar 13, 2022

Try this:

The main problem is that esbuild resolves the wrong value of package.json#exports. But I’m just seeing the conditions config; that should do the trick.

From https://github.com/evanw/esbuild/issues/1189.

0reactions
dan-leecommented, Mar 16, 2022

@brillout Great suggestion! I’ve just opened a PR for this

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error when deploying a website on Cloudflare Pages
Error arises during build stage on Cloudflare Pages. The website I am trying to deploy is made using astro-build.
Read more >
res.dcsr.txt - Debian
... filetea 0.1.18-1 OK [REASONS_NOT_COMPUTED] filezilla 3.56.0-1 OK ... golang-github-cloudflare-cfssl 1.2.0+git20160825.89.7fb22c8-3.1 OK ...
Read more >
vite-plugin-ssr - bytemeta
Cloudflare with esbuild broken with v0.3.56. frog-o. frog-o OPEN · Updated 7 months ago · Add docs about page keeping auto refreshing. kamui....
Read more >
Nuxt.js 3 x Histoire x Vitest x VitePress x Turbo (pnpm)
chore(deps): update dependency vitest to v0.24.3 ... (3.56 kB) (599 B gzip) @myturborepo/web:build: Σ Total size: 5.93 MB (1.51 MB gzip) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found