fable-compiler / Fable

F# to JavaScript, TypeScript, Python, Rust and Dart Compiler
http://fable.io/
MIT License
2.9k stars 296 forks source link

`Module not found` for relative ProjectReference #2373

Closed absolutejam closed 3 years ago

absolutejam commented 3 years ago

Description

I added in an open statement to a module in a project that is a relative import,

<ProjectReference Include="..\RealmWeaver.Common.General\RealmWeaver.Common.General.fsproj" />

and attempted to use the type in my Fable code, but I got an error as below:

ERROR in ../RealmWeaver.Common.General/src/Types/WorldBuilding/RealmReadModels.fs.js
Module not found: Error: Can't resolve 'core-js/modules/es.object.get-prototype-of.js' in '/Users/james/Documents/realmweaver-fsharp/src/RealmWeaver.Common.General/src/Types/WorldBuilding'
 @ ../RealmWeaver.Common.General/src/Types/WorldBuilding/RealmReadModels.fs.js 3:0-55
 @ ./src/Pages/LocationList/Types.fs.js
 @ ./src/Pages/LocationList/View.fs.js
 @ ./src/Routing.fs.js
 @ ./src/App/View.fs.js
 @ ./src/Program.fs.js
 @ multi ./src/Program.fs.js

ERROR in ../RealmWeaver.Common.General/src/Types/WorldBuilding/RealmReadModels.fs.js
Module not found: Error: Can't resolve 'core-js/modules/es.object.set-prototype-of.js' in '/Users/james/Documents/realmweaver-fsharp/src/RealmWeaver.Common.General/src/Types/WorldBuilding'
 @ ../RealmWeaver.Common.General/src/Types/WorldBuilding/RealmReadModels.fs.js 4:0-55
 @ ./src/Pages/LocationList/Types.fs.js
 @ ./src/Pages/LocationList/View.fs.js
 @ ./src/Routing.fs.js
 @ ./src/App/View.fs.js
 @ ./src/Program.fs.js
 @ multi ./src/Program.fs.js

I wasn't sure if Fable 3 would automatically follow the project reference, so I went into the project directory and ran fable to transpile it.

My directory layout is:

realmweaver
    \_ src
        \_ RealmWeaver.Client
        \_ RealmWeaver.Common.General
        \_ ...

Attempting to run fable watch again (Using fable watch . --sourceMaps --run webpack-dev-server via fake, which runs the above command inside the Client directory) and this time, I have the following errors:

(Just showing a few of the errors)

ERROR in ../RealmWeaver.Common.General/.fable/fable-library.3.1.2/Util.js
Module not found: Error: Can't resolve 'core-js/modules/es.symbol.js' in '/Users/james/Documents/realmweaver-fsharp/src/RealmWeaver.Common.General/.fable/fable-library.3.1.2'
 @ ../RealmWeaver.Common.General/.fable/fable-library.3.1.2/Util.js 1:0-38
 @ ../RealmWeaver.Common.General/.fable/fable-library.3.1.2/Types.js
 @ ../RealmWeaver.Common.General/src/Types/WorldBuilding/RealmReadModels.fs.js
 @ ./src/Pages/LocationList/Types.fs.js
 @ ./src/Pages/LocationList/View.fs.js
 @ ./src/Routing.fs.js
 @ ./src/App/View.fs.js
 @ ./src/Program.fs.js
 @ multi ./src/Program.fs.js

ERROR in ../RealmWeaver.Common.General/.fable/fable-library.3.1.2/Util.js
Module not found: Error: Can't resolve 'core-js/modules/es.weak-map.js' in '/Users/james/Documents/realmweaver-fsharp/src/RealmWeaver.Common.General/.fable/fable-library.3.1.2'
 @ ../RealmWeaver.Common.General/.fable/fable-library.3.1.2/Util.js 25:0-40
 @ ../RealmWeaver.Common.General/.fable/fable-library.3.1.2/Types.js
 @ ../RealmWeaver.Common.General/src/Types/WorldBuilding/RealmReadModels.fs.js
 @ ./src/Pages/LocationList/Types.fs.js
 @ ./src/Pages/LocationList/View.fs.js
 @ ./src/Routing.fs.js
 @ ./src/App/View.fs.js
 @ ./src/Program.fs.js
 @ multi ./src/Program.fs.js

ERROR in ../RealmWeaver.Common.General/.fable/fable-library.3.1.2/Types.js
Module not found: Error: Can't resolve 'core-js/modules/web.dom-collections.iterator.js' in '/Users/james/Documents/realmweaver-fsharp/src/RealmWeaver.Common.General/.fable/fable-library.3.1.2'
 @ ../RealmWeaver.Common.General/.fable/fable-library.3.1.2/Types.js 20:0-57
 @ ../RealmWeaver.Common.General/src/Types/WorldBuilding/RealmReadModels.fs.js
 @ ./src/Pages/LocationList/Types.fs.js
 @ ./src/Pages/LocationList/View.fs.js
 @ ./src/Routing.fs.js
 @ ./src/App/View.fs.js
 @ ./src/Program.fs.js
 @ multi ./src/Program.fs.js

ERROR in ../RealmWeaver.Common.General/.fable/fable-library.3.1.2/Util.js
Module not found: Error: Can't resolve 'core-js/modules/web.dom-collections.iterator.js' in '/Users/james/Documents/realmweaver-fsharp/src/RealmWeaver.Common.General/.fable/fable-library.3.1.2'
 @ ../RealmWeaver.Common.General/.fable/fable-library.3.1.2/Util.js 26:0-57
 @ ../RealmWeaver.Common.General/.fable/fable-library.3.1.2/Types.js
 @ ../RealmWeaver.Common.General/src/Types/WorldBuilding/RealmReadModels.fs.js
 @ ./src/Pages/LocationList/Types.fs.js
 @ ./src/Pages/LocationList/View.fs.js
 @ ./src/Routing.fs.js
 @ ./src/App/View.fs.js
 @ ./src/Program.fs.js
 @ multi ./src/Program.fs.js

Repro code

I'll see if I can make a super simple 2-project solution that emulates this a bit later.

Expected and actual results

Please provide the expected and actual results.

Related information

macOS mojave

My webpack config is:

webpack ```js // Template for webpack.config.js in Fable projects // Find latest version in https://github.com/fable-compiler/webpack-config-template // In most cases, you'll only need to edit the CONFIG object (after dependencies) // See below if you need better fine-tuning of Webpack options // Dependencies. Also required: core-js, fable-loader, fable-compiler, @babel/core, // @babel/preset-env, babel-loader, css-loader, style-loader, file-loader, resolve-url-loader var path = require('path'); var webpack = require('webpack'); var HtmlWebpackPlugin = require('html-webpack-plugin'); var CopyWebpackPlugin = require('copy-webpack-plugin'); var MiniCssExtractPlugin = require('mini-css-extract-plugin'); var serverPort = process.env.SERVER_PROXY_PORT || 8085; var serverHost = (process.env.DOTNET_RUNNING_IN_CONTAINER === true) ? "server" : "localhost"; var serverUri = `http://${serverHost}:${serverPort}`; var CONFIG = { // The tags to include the generated JS and CSS will be automatically injected in the HTML template // See https://github.com/jantimon/html-webpack-plugin indexHtmlTemplate: 'index.html', fsharpEntry: 'src/Program.fs.js', cssEntry: 'css/tailwind-source.css', outputDir: 'out', assetsDir: 'public', devServerPort: 9090, // When using webpack-dev-server, you may need to redirect some calls // to a external API server. See https://webpack.js.org/configuration/dev-server/#devserver-proxy devServerProxy: { // redirect requests that start with /api/ to the server on port 8085 '/api/**': { target: serverUri, changeOrigin: true }, // redirect websocket requests that start with /socket/ to the server on the port 8085 '/socket/**': { target: serverUri, ws: true } }, // Use babel-preset-env to generate JS compatible with most-used browsers. // More info at https://babeljs.io/docs/en/next/babel-preset-env.html babel: { presets: [ ['@babel/preset-env', { modules: false, // This adds polyfills when needed. Requires core-js dependency. // See https://babeljs.io/docs/en/babel-preset-env#usebuiltins // Note that you still need to add custom polyfills if necessary (e.g. whatwg-fetch) useBuiltIns: 'usage', corejs: 3 }] ], } } // If we're running the webpack-dev-server, assume we're in development mode var isProduction = !process.argv.find(v => v.indexOf('webpack-dev-server') !== -1); console.log("\n\n") console.log('Bundling for ' + (isProduction ? 'production' : 'development') + '...'); console.log('Proxying to backend: ' + serverUri); console.log("\n\n") // The HtmlWebpackPlugin allows us to use a template for the index.html page // and automatically injects Githubissues.
  • Githubissues is a development platform for aggregating issues.