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

Fixed fable-compiler-js includes #3825

Merged
merged 1 commit into from
May 24, 2024
Merged

Conversation

ncave
Copy link
Collaborator

@ncave ncave commented May 23, 2024

  • Fixed fable-compiler-js includes.

@MangelMaxime This fixes the incorrect fable-compiler-js includes.
Can you please push a new fable-compiler-js version with this fix, if you agree with it? Thanks!

@MangelMaxime
Copy link
Member

Sure I am with the changes, I think the @fable-org/fable-standalone is relic of the past because fable-library was perhaps not distributed in the compiler package.

However, I think there is still an issue with the path of the fableLib because when looking into the package structure on NPM we have

CleanShot 2024-05-24 at 15 04 17

Note that the fable-library-js is under /@fable-org/fable-compiler-js/dist/.

So I suppose we should use return Path.join(Path.dirname(require.resolve("@fable-org/fable-compiler-js")), "dist", "fable-library-js"); no ?

@ncave
Copy link
Collaborator Author

ncave commented May 24, 2024

@MangelMaxime

Note that the fable-library-js is under /@fable-org/fable-compiler-js/dist/.

Yes, but I think require.resolve("@fable-org/fable-compiler-js") does that for you, i.e. it resolved to node_modules/@fable-org/fable-compiler-js/dist. So adding another /dist/ would break it, no?

Anyway, that's just a quick fix to make the already released compiler work at least for JS.
You are correct that we should be bundling other libraries too, thanks for opening an issue for it.

@MangelMaxime
Copy link
Member

Yes, but I think require.resolve("@fable-org/fable-compiler-js") does that for you, i.e. it resolved to node_modules/@fable-org/fable-compiler-js/dist. So adding another /dist/ would break it, no?

I didn't know about that. I will make a release and if this is not enough we can investigate more.

@MangelMaxime MangelMaxime merged commit 1169740 into fable-compiler:main May 24, 2024
19 checks passed
@MangelMaxime
Copy link
Member

MangelMaxime commented May 24, 2024

I think require.resolve("@fable-org/fable-compiler-js") resolve to the package folder and not the dist folder.

import { printf, toConsole } from "/home/vscode/.npm/_npx/bfa75a35966fbb71/node_modules/@fable-org/fable-compiler-js/fable-library-js/String.js";

toConsole(printf("Hello wolrd!"));

When I try to run this code, it fails to import the module.

If I manually add dist to the path it is all good.

Reproduction:

  1. Create a test.fsx file with printfn "Hello" in it
  2. npx @fable-org/fable-compiler-js test.fsx
  3. node test.fs.js

Note

I am asking to confirm I am not missing something

@ncave
Copy link
Collaborator Author

ncave commented May 24, 2024

@MangelMaxime You are right, sorry about that.
I got fooled by the previous resolving to fable-standalone.

@MangelMaxime
Copy link
Member

@ncave No problem, I will update it and make a new release.

@ncave
Copy link
Collaborator Author

ncave commented May 24, 2024

@MangelMaxime Now I'm not sure how it works either.
Using fable-compiler-js 1.2.0 results in /node_modules/@fable-org/fable-standalone/dist/fable-library-ts/String.js, so resolve must be doing something different for @fable-org/fable-standalone.

@MangelMaxime
Copy link
Member

Using fable-compiler-js 1.2.0 results in /node_modules/@fable-org/fable-standalone/dist/fable-library-ts/String.js, so resolve must be doing something different for @fable-org/fable-standalone.

I suspect this is because of where the entry point of the package is located:

  • @fable-org/fable-standalone -> "main": "./dist/bundle.min.js",
  • @fable-org/fable-compiler-js -> "main": "./index.js",

I made a new release for @fable-org/fable-compiler-js and according to my test above it is working.

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

Successfully merging this pull request may close these issues.

2 participants