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

Implement compiler options #29

Closed
kitsonk opened this issue May 20, 2022 · 3 comments · Fixed by #113
Closed

Implement compiler options #29

kitsonk opened this issue May 20, 2022 · 3 comments · Fixed by #113
Labels
enhancement New feature or request

Comments

@kitsonk
Copy link
Contributor

kitsonk commented May 20, 2022

Currently the compiler options are ignored (or not available). They need to be passed to Rust and affect the emit just like with CLI.

@kitsonk kitsonk added the enhancement New feature or request label May 20, 2022
@johnspurlock
Copy link

johnspurlock commented Jun 16, 2022

Any update on this? Looking to support specifying a target as we used to be able to with Deno.emit (#44 (comment))

Can't even use deno bundle as a workaround, since target is not one of the compilerOptions that can be configured with a custom deno config.

I guess I'll need to use esbuild or something in the meantime - feels like we've lost so much since deno v1.21.3.

(update) was able to use the esbuild Deno x module to bundle with a custom target, which runs an esbuild binary under the hood

@johnspurlock
Copy link

johnspurlock commented Jun 16, 2022

Hmm, I'm also stuck trying to find a replacement for old Deno.emit code that used:

compilerOptions: { 
    declaration: true,
    emitDeclarationOnly: true,
    removeComments: false,
}

It seems there is no upgrade path for me.

  • deno bundle does not support those compilerOptions
  • esbuild does not deal with types at all
  • swc does not do this (yet)
  • tsc supports those options in a tsconfig but does not work on Deno source files (different import style, and tsc has no import map support)

Any ideas?

@dylanmcdiarmid
Copy link

I also don't understand the reason for including compilerOptions in the types and then not passing them through. Modifying mod.ts's bundle function to simply grab compilerOptions out of options and pass it as the fifth argument to jsBundle allowed me to compile without source maps as well as modify the jsxFactory and jsxFragmentFactory, which is necessary if you are compiling something other than React. It seems to work fine in simple tests.

export async function bundle(
  root: string | URL,
  options: BundleOptions = {},
): Promise<BundleEmit> {
  const {
    imports,
    load,
    cacheSetting,
    cacheRoot,
    allowRemote,
    compilerOptions
  } = options;
  let bundleLoad = load;
  if (!bundleLoad) {
    const cache = createCache({ root: cacheRoot, cacheSetting, allowRemote });
    bundleLoad = cache.load;
  }
  root = root instanceof URL ? root : toFileUrl(resolve(root));
  const { bundle: jsBundle } = await instantiate();
  console.log('got compiler options', compilerOptions)
  return jsBundle(
    root.toString(),
    bundleLoad,
    JSON.stringify(imports),
    undefined,
    compilerOptions,
  );
}

yacinehmito added a commit to yacinehmito/deno_emit that referenced this issue Apr 4, 2023
Since the initial release, the bundle type, the compiler options and the
imports were not properly forwarded from JS to Rust.

We now forward them, and added some tests to verify this behaviour.

Closes denoland#83, denoland#69, denoland#29.
yacinehmito added a commit to yacinehmito/deno_emit that referenced this issue Apr 9, 2023
Since the initial release, the bundle type, the compiler options and the
imports were not properly forwarded from JS to Rust.

We now forward them, and added some tests to verify this behaviour.

Closes denoland#83, denoland#69, denoland#29.
yacinehmito added a commit to yacinehmito/deno_emit that referenced this issue Apr 25, 2023
Since the initial release, the bundle type, the compiler options and the
imports were not properly forwarded from JS to Rust.

We now forward them, and added some tests to verify this behaviour.

Closes denoland#83, denoland#69, denoland#29.
yacinehmito added a commit to yacinehmito/deno_emit that referenced this issue Apr 26, 2023
Since the initial release, the bundle type, the compiler options and the
imports were not properly forwarded from JS to Rust.

We now forward them, and added some tests to verify this behaviour.

Closes denoland#83, denoland#69, denoland#29.
dsherret pushed a commit that referenced this issue Apr 26, 2023
Forward arguments from JS to Rust

Since the initial release, the bundle type, the compiler options and the
imports were not properly forwarded from JS to Rust.

We now forward them, and added some tests to verify this behaviour.

Closes #83, #69, #29.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
3 participants