ricokahler / next-plugin-preval

Pre-evaluate async functions during builds and import them like JSON
MIT License
255 stars 12 forks source link

isn't working with next dev (workspaces?) #5

Closed Maxastuart closed 3 years ago

Maxastuart commented 3 years ago

When executing next dev, I keep getting Error: Next Plugin Preval could not find webpack rules. This may be an unsupported version of Next.js.

I have a feeling this is due to the Yarn Workspaces set up in my repo, but it could be something else.

web/package.json:

{
  "name": "sanity-marketing-web",
  "private": true,
  "version": "1.0.12",
  "engines": {
    "node": ">=0.14"
  },
  "scripts": {
    "build": "next build && next export",
    "dev": "next",
    "start": "next start",
  },
  "dependencies": {
    "@emotion/babel-plugin": "^11.1.2",
    "@emotion/cache": "^11.1.3",
    "@emotion/react": "^11.1.5",
    "@emotion/server": "^11.0.0",
    "@emotion/styled": "^11.1.5",
    "@material-ui/core": "^5.0.0-alpha.24",
    "@sanity/block-content-to-react": "^2.0.7",
    "@sanity/client": "^2.2.6",
    "@sanity/image-url": "^0.140.22",
    "groq": "^2.2.6",
    "next": "^10.0.6",
    "next-plugin-preval": "^1.0.0-alpha.12",
    "next-sanity": "^0.1.8",
    "next-seo": "^4.19.0",
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "react-inlinesvg": "^2.2.2",
    "sitemap": "^6.3.5"
  },
  "devDependencies": {
    "@types/node-fetch": "^2.5.8",
    "node-fetch": "^2.6.1",
    "sanity-codegen": "^0.8.3",
    "ts-node": "^9.1.1",
    "typescript": "^4.1.3"
  }
}

web/next.config.js:

const createNextPluginPreval = require('next-plugin-preval/config');
const withNextPluginPreval = createNextPluginPreval();

module.exports = withNextPluginPreval({});

package.json (root):

{
  "name": "sanity-marketing",
  "private": true,
  "version": "1.0.12",
  "engines": {
    "node": ">=0.14"
  },
  "workspaces": {
    "packages": [
      "studio",
      "web"
    ]
  },
  "scripts": {
    "build": "concurrently \"yarn build:studio\" \"yarn build:web\"",
    "build:studio": "cd studio && yarn build",
    "build:web": "cd web && yarn build",
    "clean": "yarn clean:build && yarn clean:nm && yarn clean:npmlock",
    "clean:all": "yarn clean:build && yarn clean:nm && yarn clean:lock",
    "clean:build": "yarn workspaces run clean",
    "clean:lock": "find . -type f \\( -name *.lock -o -name *-lock.json \\) -delete",
    "clean:nm": "find . -type d -name \"node_modules\" -exec rm -rf \"{}\" +",
    "clean:npmlock": "find . -type f -name \"*-lock.json\" -delete",
    "dev": "concurrently \"yarn dev:studio\" \"yarn dev:web\"",
    "dev:studio": "cd studio && yarn dev",
    "dev:web": "cd web && yarn dev",
    "format": "prettier-eslint --write . \"!.next/**\" \"!node_modules/**\" \"!out/**\"",
    "lint": "eslint .",
    "test": "concurrently \"yarn test:studio\" \"yarn test:web\"",
    "test:studio": "cd studio && yarn test",
    "test:web": "cd web && yarn test"
  },
  "devDependencies": {
    "@babel/core": "^7.12.13",
    "@babel/eslint-parser": "^7.12.13",
    "@babel/preset-typescript": "^7.12.13",
    "@sanity/cli": "^2.2.6",
    "@types/node": "^14.14.25",
    "@types/react": "^17.0.1",
    "@typescript-eslint/eslint-plugin": "^4.14.2",
    "@typescript-eslint/parser": "^4.14.2",
    "concurrently": "^5.3.0",
    "eslint": "^7.19.0",
    "eslint-config-airbnb": "^18.2.1",
    "eslint-config-airbnb-typescript": "^12.3.1",
    "eslint-config-prettier": "^7.2.0",
    "eslint-config-react-app": "^6.0.0",
    "eslint-plugin-compat": "^3.9.0",
    "eslint-plugin-flowtype": "^5.2.0",
    "eslint-plugin-import": "^2.22.1",
    "eslint-plugin-jsx-a11y": "^6.4.1",
    "eslint-plugin-node": "^11.1.0",
    "eslint-plugin-promise": "^4.2.1",
    "eslint-plugin-react": "^7.22.0",
    "eslint-plugin-react-hooks": "^4.2.0",
    "eslint-plugin-sort-keys-fix": "^1.1.1",
    "eslint-plugin-typescript-sort-keys": "^1.5.0",
    "prettier": "^2.2.1",
    "prettier-eslint-cli": "^5.0.0",
    "sanity-codegen": "^0.8.3",
    "ts-node": "^9.1.1",
    "typescript": "^4.1.3"
  }
}
ricokahler commented 3 years ago

This was actually a bug due to how I was handling the case of no provided webpack config function. Thanks for catching it!

github-actions[bot] commented 3 years ago

:tada: This issue has been resolved in version 1.0.0-alpha.13 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] commented 3 years ago

:tada: This issue has been resolved in version 1.0.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: