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

Webpack has been initialised using a configuration object that does not match the API schema #55

Open
phGitHubAcnt opened this issue Nov 17, 2023 · 1 comment

Comments

@phGitHubAcnt
Copy link

phGitHubAcnt commented Nov 17, 2023

Hi all! I'm just starting with react-native. I installed a repo on all the instructions. However, when starting
PS C:\Projects\react-native-universal-monorepo-master> yarn web:start
An error arises:

Failed to compile.
Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.

  • configuration.module.rules[1].oneOf[2].include should be one of these:
    RegExp | string | function | [(recursive)] | object { and?, exclude?, include?, not?, or?, test? } | [RegExp |
    string | function | [(recursive)] | object { and?, exclude?, include?, not?, or?, test? }]
    -> One or multiple rule conditions
    Details:
    • configuration.module.rules[1].oneOf[2].include[1]: The provided value "C:/Projects/react-native-universal-monorepo-master/packages/app/" is not an absolute path!
    • configuration.module.rules[1].oneOf[2].include[2]: The provided value "C:/Projects/react-native-universal-monorepo-master/packages/browser-ext/" is not an absolute path!
    • configuration.module.rules[1].oneOf[2].include[3]: The provided value "C:/Projects/react-native-universal-monorepo-master/packages/electron/" is not an absolute path!
    • configuration.module.rules[1].oneOf[2].include[4]: The provided value "C:/Projects/react-native-universal-monorepo-master/packages/macos/" is not an absolute path!
    • configuration.module.rules[1].oneOf[2].include[5]: The provided value "C:/Projects/react-native-universal-monorepo-master/packages/mobile/" is not an absolute path!
    • configuration.module.rules[1].oneOf[2].include[6]: The provided value "C:/Projects/react-native-universal-monorepo-master/packages/next/" is not an absolute path!
    • configuration.module.rules[1].oneOf[2].include[7]: The provided value "C:/Projects/react-native-universal-monorepo-master/packages/tv/" is not an absolute path!
    • configuration.module.rules[1].oneOf[2].include[8]: The provided value "C:/Projects/react-native-universal-monorepo-master/packages/web/" is not an absolute path!
    • configuration.module.rules[1].oneOf[2].include[9]: The provided value "C:/Projects/react-native-universal-monorepo-master/packages/windows/" is not an absolute path!
    • configuration.module.rules[1].oneOf[2].include[1]: The provided value "C:/Projects/react-native-universal-monorepo-master/packages/app/" is not an absolute path!
    • configuration.module.rules[1].oneOf[2].include[2]: The provided value "C:/Projects/react-native-universal-monorepo-master/packages/browser-ext/" is not an absolute path!
    • configuration.module.rules[1].oneOf[2].include[3]: The provided value "C:/Projects/react-native-universal-monorepo-master/packages/electron/" is not an absolute path!
    • configuration.module.rules[1].oneOf[2].include[4]: The provided value "C:/Projects/react-native-universal-monorepo-master/packages/macos/" is not an absolute path!
    • configuration.module.rules[1].oneOf[2].include[5]: The provided value "C:/Projects/react-native-universal-monorepo-master/packages/mobile/" is not an absolute path!
    • configuration.module.rules[1].oneOf[2].include[6]: The provided value "C:/Projects/react-native-universal-monorepo-master/packages/next/" is not an absolute path!
    • configuration.module.rules[1].oneOf[2].include[7]: The provided value "C:/Projects/react-native-universal-monorepo-master/packages/tv/" is not an absolute path!
    • configuration.module.rules[1].oneOf[2].include[8]: The provided value "C:/Projects/react-native-universal-monorepo-master/packages/web/" is not an absolute path!
    • configuration.module.rules[1].oneOf[2].include[9]: The provided value "C:/Projects/react-native-universal-monorepo-master/packages/windows/" is not an absolute path!

I could not find solutions myself. Perhaps the solution is somewhere here?:

file get-webpack-tools.js :
const workspaces = getWorkspaces({ cwd });
function enableWorkspacesResolution(webpackConfig) {
const babelLoader = webpackConfig.module.rules[1].oneOf.find((rule) =>
rule.loader.includes("babel-loader")
);
babelLoader.include = Array.isArray(babelLoader.include)
? babelLoader.include
: [babelLoader.include];
for (const workspace of workspaces) {
babelLoader.include.push(workspace);
}

file get-workspaces.js :
const monorepoRoot = getMonorepoRoot({ cwd });
const packageJson = require(path.join(monorepoRoot, "package.json"));

Thanks!

@msridar
Copy link

msridar commented Mar 17, 2024

Any update on this issue ?

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

2 participants