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

Deprecate td.function in favor of td.func #214

Open
3 tasks
searls opened this issue Mar 19, 2017 · 0 comments
Open
3 tasks

Deprecate td.function in favor of td.func #214

searls opened this issue Mar 19, 2017 · 0 comments

Comments

@searls
Copy link
Member

searls commented Mar 19, 2017

Terrible luck to discover this after releasing 2.0.0, but subsequent improvements to the build have made me realize that the cute way we do this:

module.exports = { function: require('./function') /*...*/ }

Just won't fly in ES module-land, where something like this:

export { function }

Will blow up because it's a reserved word. (import {function} from 'testdouble' also blows up)

We can do:

export default {
  function: tdFunction
}

But then any module/bundler like webpack/rollup/browserify is going to have that default tacked onto it, which means that our distribution will be td.default.object or whatever.

I hope we can find some workaround to use ES exports exclusively and then solve this with build cleverness using one of the bundlers, but even if we do manage, having a top-level API that's a reserved word is probably not a great long-term play.

Goals:

  • hack up some short-term win with a bundler that'll let us still get tree shaking while using a CJS export at the top level or a way to modify the bundled content to td = td.default dynamically.
  • documentation change from td.function() to td.func()
  • figure out how soon we want to think about dropping td.function with another major bump.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

1 participant