insin / nwb

A toolkit for React, Preact, Inferno & vanilla JS apps, React libraries and other npm modules for the web, with no configuration (until you need it)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

webpack.resolve.extensions: ❌ webpack = 'resolve' Unexpected prop in webpack config

SilentFlute opened this issue · comments

This issue is a:

  • Question / support request

These checks might help you diagnose whether something is wrong with nwb or your setup:

Is the version of nwb you're using installed globally or locally?
locally

Which versions of Node.js, npm and nwb are you using (if using it globally)?
globally:
nodejs: v14.17.6
npm: 6.14.15
yarn: 1.22.11(i dont like npm, so i use yarn instead)

locally:
nwb: ^0.25.2

os:
macOS: 10.15.7

Which modules are installed in your project?

my package.json:

{
  "name": "profile-cards-primitives",
  "private": true,
  "skpm": {
    "main": "profile-cards-primitives.sketchplugin",
    "manifest": "src/manifest.json"
  },
  "scripts": {
    "build": "skpm-build",
    "watch": "skpm-build --watch",
    "render": "skpm-build --watch --run",
    "render:once": "skpm-build --run",
    "dist": "npm run build && skpm-link",
    "web": "nwb react run src/web.js"
  },
  "author": "Jon Gold <jon.gold@airbnb.com>",
  "license": "MIT",
  "dependencies": {
    "nwb": "^0.25.2",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-native": "^0.66.0",
    "react-primitives": "^0.8.1",
    "react-sketchapp": "^3.2.6",
    "react-test-renderer": "^17.0.2"
  },
  "devDependencies": {
    "@skpm/builder": "^0.8.0"
  }
}

nwb.config.js:

module.exports = {
  webpack: {
    resolve: {
      // look for .web.js first
      extensions: ['.web.js', '.js', '.json'],
    },
  },
};

im in a project which use react-sketchapp to render react to sketch, the design software sketch, and when i run nwb react run src/web.js try to see the result in the browser, i got error:

Error

✖ webpack = 'resolve'
  Unexpected prop in webpack config - see https://github.com/insin/nwb/blob/master/docs/Configuration.md#webpack-configuration for supported config. If you were trying to add extra Webpack config, try putting it in webpack.extra instead

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

but when i delete the config, i got a error as well:

Failed to compile with 2 errors.

 ERROR  in ./node_modules/react-primitives/lib/injection/react-native-web.js
Module not found: Error: Can't resolve 'react-native-web' in '/Users/kunmingcn/Documents/code/react-sketchapp/examples/profile-cards-primitives/node_modules/react-primitives/lib/injection'
 @ ./node_modules/react-primitives/lib/injection/react-native-web.js 1:287-314
 @ ./node_modules/react-primitives/lib/index.js
 @ ./node_modules/react-primitives/index.js
 @ ./src/components/Profile.js
 @ ./src/web.js
 @ ./node_modules/nwb/lib/react/renderShim.js
 @ multi ./node_modules/nwb/node_modules/@pmmmwh/react-refresh-webpack-plugin/src/runtime/ReactRefreshEntry.js (webpack)-dev-server/client?/ ./node_modules/nwb/node_modules/@pmmmwh/react-refresh-webpack-plugin/src/runtime/ErrorOverlayEntry.js (webpack)/hot/only-dev-server.js ./node_modules/nwb/lib/react/renderShim.js

 ERROR  in ./node_modules/react-primitives/lib/injection/react-native-web.js
Module not found: Error: Can't resolve 'react-native-web/dist/cjs/exports/StyleSheet/createStyleResolver' in '/Users/kunmingcn/Documents/code/react-sketchapp/examples/profile-cards-primitives/node_modules/react-primitives/lib/injection'
 @ ./node_modules/react-primitives/lib/injection/react-native-web.js 1:664-739
 @ ./node_modules/react-primitives/lib/index.js
 @ ./node_modules/react-primitives/index.js
 @ ./src/components/Profile.js
 @ ./src/web.js
 @ ./node_modules/nwb/lib/react/renderShim.js
 @ multi ./node_modules/nwb/node_modules/@pmmmwh/react-refresh-webpack-plugin/src/runtime/ReactRefreshEntry.js (webpack)-dev-server/client?/ ./node_modules/nwb/node_modules/@pmmmwh/react-refresh-webpack-plugin/src/runtime/ErrorOverlayEntry.js (webpack)/hot/only-dev-server.js ./node_modules/nwb/lib/react/renderShim.js

it mentioned can't resolve 'react-native-web', react-native-web is a file in the /node_modules/react-primitives/lib/injection/react-native-web.js, as far as i know, webpack.resolve.extension will fix this, but in the above, webpack.resolve.extension doesn't work at all, so any suggestions?

finally, i don't use nwb, i find another way to solve my problem, here is the detail: airbnb/react-sketchapp#531