I encountered strange issue that I believe happens only to me for whatever reason I want to understand.
I have a banch of (16) F# projects in my solution. Now I also added a SAFE project and included
domain file via <Compile Include="domain.fs" />
In Visual Studio all compiles fine but not in the fake command:
Can't resolve 'core-js/modules/es.array.find
Can't resolve 'core-js/modules/es.array.some
Can't resolve 'core-js/modules/es.function.name
It blames only the domain file , if I use the same array functions in the Client.fs that is obviously fine .
It looks like Webpack cannot find the "node_modules" folder from "domain.fs". This usually happens if the .fs file is outside the directory hierarchy where package.json.
I guess you're putting the package.json file within the "src/Client" folder or similar? In that case, can you please try putting it in the repository root so "domain.fs" is included in its directory hierarchy?
You can keep other files like webpack.config.js in src/Client if you want (but be careful to use fully qualified paths if you invoke webpack from a different directory).
That is true that domain.fs is somewhere else: it comes from different project in the solution so the real path is like..\..\..\domain.fs.
But it is plain backend logic so the project for domain.fs has no node-modules or package.json itself
I haven't touch the SAFE file locations as well so the package.json is still in the main SAFE folder, not src or src\Client
The easiest way to make it work for me is to copy all necessary files to src/Client but it is a lot of burden to do it for every change and I expect my core logic to evolve a lot
Take into account that for Webpack, "domain.fs" is just another JS file. When another file in your client app references domain.fs, Webpack will ask fable-loader to translate the F# to JS. In this process, some JS imports can be injected to the translated file, for example to reference utilities in Fable JS library. In your case, it seems Babel is injecting core-js polyfills.
When Webpack finds a reference to a JS module, it will look for the "node_modules" folder in that specific file directory or its ancestors. I'm not entirely sure, but maybe you can override this behavior by adding the following to your webpack config:
```js
module.exports = {
// ... other config options
resolve: {
modules: [path.join(__dirname, "node_modules")] // If package.json is next to webpack.config.js
}
};
yees, the proposed override solved it! :)
And thanks for all the explanations
Most helpful comment
yees, the proposed override solved it! :)
And thanks for all the explanations