Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't require @prefresh/babel-plugin #444

Closed
eostrom opened this issue Feb 20, 2022 · 5 comments
Closed

can't require @prefresh/babel-plugin #444

eostrom opened this issue Feb 20, 2022 · 5 comments

Comments

@eostrom
Copy link

eostrom commented Feb 20, 2022

I ran into this using next-plugin-preact but I believe it's an issue with @prefresh/babel-plugin.

I created a Next app using Preact:

❯ npx create-next-app --example using-preact next-preact-npm

And npm run dev gave me this error:

Error: Cannot find module '/Users/eostrom/workspace/swagleft/next-preact-npm/node_modules/@prefresh/babel-plugin/dist/src/index.js'
    at createEsmNotFoundErr (node:internal/modules/cjs/loader:960:15)
    at finalizeEsmResolution (node:internal/modules/cjs/loader:953:15)
    at resolveExports (node:internal/modules/cjs/loader:482:14)
    at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
    at Function.mod._resolveFilename (/Users/eostrom/workspace/swagleft/next-preact-npm/node_modules/next/dist/build/webpack/require-hook.js:183:28)
    at Function.Module._resolveFilename (/Users/eostrom/workspace/swagleft/next-preact-npm/node_modules/module-alias/index.js:49:29)
    at Function.resolve (node:internal/modules/cjs/helpers:108:19)
    at Object.webpack (/Users/eostrom/workspace/swagleft/next-preact-npm/node_modules/@prefresh/next/src/index.js:29:19)
    at Object.getBaseWebpackConfig [as default] (/Users/eostrom/workspace/swagleft/next-preact-npm/node_modules/next/dist/build/webpack-config.js:1411:32) {
  code: 'MODULE_NOT_FOUND',
  path: '/Users/eostrom/workspace/swagleft/next-preact-npm/node_modules/@prefresh/babel-plugin/package.json'

I don't have a deep understanding of npm, but I think the problem is in packages/babel/package.json:

  "exports": {
    ".": {
      "import": "./src/index.mjs",
      "require": "./dist/src/index.js"
    },
    "./package.json": "./package.json"
  },

The require line references a file that doesn't seem to have been installed with the package.

I have a non-Next minimal test case, which I'll upload shortly.

@eostrom
Copy link
Author

eostrom commented Feb 20, 2022

@connor4312
Copy link

connor4312 commented Feb 20, 2022

Yea, @prefresh/[email protected] seems broken. It exports dist/src/index.js, but no dist folder is present in its npm package. You can see this in the default vite setup, for example: https://vite.new/preact

@JoviDeCroock
Copy link
Member

JoviDeCroock commented Feb 20, 2022

Published a fix in 0.4.3 - thanks for the report ❤️

@connor4312
Copy link

If you haven't already (npm is still caching), @prefresh/vite will need a bump too since it depends on the exact 0.4.2 version of the babel plugin package.

@JoviDeCroock
Copy link
Member

JoviDeCroock commented Feb 20, 2022

They should have received a bump normally ce94464

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants