preactjs / wmr

šŸ‘©ā€šŸš€ The tiny all-in-one development tool for modern web apps.
https://wmr.dev/
MIT License
4.92k stars 109 forks source link

npm registry lookup failed for "@npm/object-assign": Package doesn't exist. #919

Closed Aloento closed 2 years ago

Aloento commented 2 years ago

Describe the bug After compiling, at the top of @npm/prop-types, there're

import require$$0 from '/@npm/react-is'; // sometime is wrong with "./@npm/react-is"
import require$$1 from './@npm/object-assign';

the original prop-types.js file is:

var ReactIs = require('react-is');
var assign = require('object-assign');

Then, './@npm/object-assign' is /@npm/@npm/object-assign, which is incorrect path.

object-assign required by prop-types required by react-helmet-async

To Reproduce yarn create wmr & yarn add react-helmet-async

index.js

export function App() {
  return (
    <LocationProvider>
+      <HelmetProvider>
        <div class="app">
          <Header />
          <ErrorBoundary>
            <Router>
              <Route path="/" component={Home} />
              <Route path="/about" component={About} />
              <Route default component={NotFound} />
            </Router>
          </ErrorBoundary>
        </div>
+      </HelmetProvider>
    </LocationProvider>
  );
}

Does anybody know how to fix this path?

rschristian commented 2 years ago

WMR doesn't have great support of pure CJS dependencies, which does limit some of the React ecosystem.

We use hoofd in the docs for this repo, which I can recommend in its place, but it is a different API.

developit commented 2 years ago

Yes - just to clarify, WMR has some CommonJS support, but packages published by the React team use a complex CommonJS setup that is very difficult (and in some cases impossible) to handle on-the-fly.

developit commented 2 years ago

I'm going to dedupe this with #903 (thanks for pointing to that issue @Aloento!)