Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

No transpile option #1556

Closed
cdaringe opened this issue Oct 17, 2017 · 18 comments
Closed

No transpile option #1556

cdaringe opened this issue Oct 17, 2017 · 18 comments
Labels

Comments

@cdaringe
Copy link
Contributor

cdaringe commented Oct 17, 2017

Description

  • add support for a flag/mode that skips transpilation of all files.

ava doesn't support a "no transpilation" option. a no transpile option would improve performance and, more importantly, yield a stable, easy debugging experience for those of us who don't need/want transpilation. i use ava for many of it's great features, transpilation not being one of them. transpilation+source_maps+editors frequently don't play nicely.

observe:

vscode-ava
^^ shows setting breakpoints, running ava, transpiliation happens behind the scenes, and my editor losing it's cool as it lost refs to the actual lines breakpoints were originally on, pretest

this is already a known issue without a solution--it even says so in the docs. these issues "just go away" when i can use raw node, and the runtime runs just my code, untouched!

thanks for the consideration! great work.

@sindresorhus
Copy link
Member

Yeah, I'd like to see that too. Now that Node.js 8 has native async/await, there's no longer a need for me personally to transpile. The main reason we chose to do transpilation by default initially was to get async/await.

@sindresorhus sindresorhus changed the title feature request: no transpile option No transpile option Oct 22, 2017
@sindresorhus sindresorhus reopened this Oct 22, 2017
@sindresorhus
Copy link
Member

@avajs/core Thoughts?

@novemberborn novemberborn added this to the 1.0 milestone Oct 23, 2017
@novemberborn
Copy link
Member

Yes. See also #709 (don't worry I'll clean up the issues).

Say we have a "babel': false option. Should that also imply "powerAssert": false? I'm leaning towards yes, since power-assert requires transpilation, whether via Babel or https://github.com/power-assert-js/espower-loader. But it might be an unexpected way to lose that feature. Same goes for our throws helper. Should there be an easy way to opt back in to it?

@sindresorhus
Copy link
Member

Say we have a "babel': false option. Should that also imply "powerAssert": false?

Yes, unless we can figure out a way to run it efficiently at runtime on a failure.

Should there be an easy way to opt back in to it?

I don't see how you could opt into the throws helper again without having Babel, and then using babel: false is moot.

@novemberborn
Copy link
Member

There's something to be said for separating AVA's file manipulations from syntax transforms. The babel option could refer to syntax transforms only, while we have a separate transpileEnhancements option. This would supersede the current powerAssert option.

Since we're still looking to integrate source transpilation and also support TypeScript, it makes sense (at least to me) that the enhancements are controlled separately.

eloquence added a commit to eloquence/lib.reviews that referenced this issue Nov 5, 2017
With the new Node LTS as our baseline we don't really have to
do extra transpilation. ava still does its own but it does so
inconsistently ( avajs/ava#1319 ),
so we've switched back from import to require(). Indeed ava
might get an option to turn off transpilation altogether
( avajs/ava#1556 ), which we
may end up using if it doesn't come with bad tradeoffs.
@sholladay
Copy link

sholladay commented Nov 16, 2017

I would use this a lot and it would have helped me today. 😃

At the moment, transpiling is breaking valid code that runs on LTS versions of Node.

See: 37c9122#commitcomment-25662855

@avajs avajs deleted a comment from blitzbohne Dec 1, 2017
novemberborn added a commit that referenced this issue Jan 26, 2018
This new option controls whether the @ava/transform-test-files preset is
used at all. Disabling will be one of the things necessary to side-step
Babel altogether.

Removes support for the `--no-power-assert` CLI flag, without a
replacement.

Refs #1556.
novemberborn added a commit that referenced this issue Jan 26, 2018
Set babel=false to disable AVA's default test compilation. *Also* set
compileEnhancements=false to disable the Babel pipeline altogether.

Fixes #1556.
@novemberborn
Copy link
Member

#1608 includes a compileEnhancements option. If set to false, and babel is also set to false, then the Babel pipeline is skipped in its entirety.

novemberborn added a commit that referenced this issue Jan 27, 2018
This new option controls whether the @ava/transform-test-files preset is
used at all. Disabling will be one of the things necessary to side-step
Babel altogether.

Removes support for the `--no-power-assert` CLI flag, without a
replacement.

Refs #1556.
novemberborn added a commit that referenced this issue Jan 27, 2018
Set babel=false to disable AVA's default test compilation. *Also* set
compileEnhancements=false to disable the Babel pipeline altogether.

Fixes #1556.
novemberborn added a commit that referenced this issue Jan 27, 2018
Fixes #1598. Switches AVA's Babel implementation to use Babel 7. This applies to test and helper file compilation.

Adds a `compileEnhancements` option which can be set to `false` to disable Power Assert and our `t.throws()` helper.

Changes the Babel configuration. If you had this before:

```json
"ava": {
  "babel": {
    "plugins": []
  }
}
```

You'll now need:

```json
"ava": {
  "babel": {
    "testOptions": {
      "plugins": []
    }
  }
}
```

`ava.babel.testOptions.babelrc` now defaults to `true`. You can disable our stage-4 preset by adding `["ava/stage-4", false]` to `ava.babel.testOptions.presets`. Set `ava.babel` to `false` to disable AVA's test file compilation, **whilst still compiling enhancements**. If `compileEnhancements` is *also* set to `false` then Babel is skipped completely.

Fixes #1225, #1488 and #1556.
@cdaringe
Copy link
Contributor Author

@novemberborn, you're an 👼 . can't wait to test this out!

@cdaringe
Copy link
Contributor Author

Hmm...

  • i installed the latest commit directly from github,
  • ran yarn (observed the request hit GH, though the gif below is too fast moving :))
  • configured ava
  • and ran the test
// package.json
  "ava": {
    "options": {
      "compileEnhancements": false
    }
  }

sure enough, breakpoints still jump around, leading me to think something is still being transpiled (or built, run, and sourcemapped at least)

still-transpiling mov

@novemberborn
Copy link
Member

@cdaringe that's not how AVA's options are set. You'll also still need to disable the regular Babel compilation that AVA applies:

"ava": {
  "babel": false,
  "compileEnhancements": false
}

@sholladay
Copy link

What would this do?

"ava": {
  "babel": false,
  "compileEnhancements": true
}

Would the false be ignored? I'm wondering if it should imply "compileEnhancements" : false.

@novemberborn
Copy link
Member

@sholladay AVA won't apply the stage-4 preset, but power-assert will keep working, and we'd detect t.throws(throw new Error()).

Whilst those last two features are currently provided through a Babel preset I think that's an implementation detail. We could change the compiler we use, and when we add native support for TypeScript we may still want to add those features to test files written in TypeScript.

@cdaringe
Copy link
Contributor Author

hey @novemberborn, whoops, sorry for that!

even with

"ava": {
  "babel": false,
  "compileEnhancements": false
}

i'm still seeing the jumpiness. is the file still being meddled with or source mapped somehow?

@novemberborn
Copy link
Member

@cdaringe are you per chance applying nyc in your test run? Feel free to pop in on https://gitter.im/avajs/ava so we can hash this out more directly (assuming our time zones have some overlap).

@cdaringe
Copy link
Contributor Author

hi @novemberborn, thx for the continued support. indeed, i was using nyc. after removing nyc, however, the issue persists. sorry i was late to see this message. im out for a few days for surgery but will be back soon. i'll try and reach out to you on gitter then.

@cdaringe
Copy link
Contributor Author

OR, here's a teeny tiny reproduction: https://github.com/cdaringe/vscode-ava-no-transpile-party-time

it's wired up per instruction. clone, npm i/yarn, then readme steps!

@novemberborn
Copy link
Member

@cdaringe aha! profile.js doesn't skip compilation. It's a bit of an odd duck. Nice catch!

@StarpTech
Copy link

StarpTech commented Sep 5, 2019

Is this issue with vscode really a vscode issue? When I add a breakpoint in a jest file with es modules and inside an async function it works fine! Do we provide sourcemaps in ava?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants