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

Imports for FSX files have wrong extension. #3753

Open
MattMS opened this issue Feb 12, 2024 · 2 comments
Open

Imports for FSX files have wrong extension. #3753

MattMS opened this issue Feb 12, 2024 · 2 comments

Comments

@MattMS
Copy link

MattMS commented Feb 12, 2024

Description

When loading a FSX script inside another, it is found and transpiled correctly, but the import statement generated uses the fsx extension instead of the correct .fs.js extension.

Repro code

Contents of a.fsx:

let a v = v + 1

Contents of main.fsx:

#load "a.fsx"
open A

let b v = a v + 1

Build with the following:

fable main.fsx --run "esbuild --bundle --outfile=main.bundle.js main.fs.js"

Output in main.fs.js (with incorrect import):

import { a } from "./a.fsx";

export function b(v) {
    return a(v) + 1;
}

ESBuild fails with the following:

No loader is configured for ".fsx" files: a.fsx

Expected and actual results

Output in main.fs.js should have the correct .fs.js extension:

import { a } from "./a.fs.js";

Related information

  • Fable version: 4.11.0 (installed globally)
  • Operating system: Windows 11 22H2 (22621.3007)
@MattMS
Copy link
Author

MattMS commented Feb 12, 2024

I can see some extension handling in https://github.com/fable-compiler/Fable/blob/main/src/fable-compiler-js/src/app.fs

Within member _.MakeImportPath(path) in interface Fable.Standalone.IWriter of SourceWriter:

if path.EndsWith(".fs") then

Maybe fixed as the following:

if path.EndsWith(".fs") || path.EndsWith(".fsx") then

@MangelMaxime
Copy link
Member

Files in fable-compiler-js is when using the fable-compiler-js NPM package it is not what most people use.

Most people consume Fable via .NET which code is located in src/Fable.CLI, src/ Fable.Compiler, src/Fable.Transforms, etc.

So I don't think the file linked will be what is needed to fix your problem.

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