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

Deno.emit() with check: false does not support module compiler option #50

Open
kitsonk opened this issue Jun 21, 2021 · 1 comment
Open
Labels
bug Something isn't working cli public API

Comments

@kitsonk
Copy link
Contributor

kitsonk commented Jun 21, 2021

The following code does not work as expected:

const { diagnostics, files, ignoredOptions, stats } = await Deno.emit(
  "/foo.ts",
  {
    check: false,
    compilerOptions: {
      module: "amd",
      sourceMap: false,
    },
    sources: { "/foo.ts": `export const foo = "foo";` },
  },
);

It simply outputs and ESM module. Where as if check is true it will output an AMD module.

If swc doesn't support AMD, CommonJS, System and UMD we should throw here with invalid options, if it does, we should implement the functionality.

@kitsonk kitsonk added bug Something isn't working cli public API labels Jun 21, 2021
@kitsonk
Copy link
Contributor Author

kitsonk commented Jun 21, 2021

Here is a specific test case that can be added to cli/tests/compiler_api_test.ts the demonstrates the issue. It should pass:

Deno.test({
  name: "Deno.emit() - no check - supports other module formats",
  async fn() {
    const { diagnostics, files, ignoredOptions, stats } = await Deno.emit(
      "/foo.ts",
      {
        check: false,
        compilerOptions: {
          module: "amd",
          sourceMap: false,
        },
        sources: { "/foo.ts": `export const foo = "foo";` },
      },
    );
    assertEquals(diagnostics.length, 0);
    assert(!ignoredOptions);
    assertEquals(stats.length, 12);
    const keys = Object.keys(files);
    assertEquals(keys.length, 1);
    const key = keys[0];
    assert(key.endsWith("/foo.ts.js"));
    assert(files[key].startsWith("define("));
  },
});

@bartlomieju bartlomieju transferred this issue from denoland/deno Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cli public API
Projects
None yet
Development

No branches or pull requests

1 participant