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

Import errors in node #17

Open
TylorS opened this issue Oct 26, 2017 · 7 comments
Open

Import errors in node #17

TylorS opened this issue Oct 26, 2017 · 7 comments
Labels

Comments

@TylorS
Copy link
Owner

TylorS commented Oct 26, 2017

TypeError: prelude_1.prop is not a function

@TylorS TylorS added the bug label Oct 26, 2017
@Frikki
Copy link
Collaborator

Frikki commented Oct 26, 2017

selection_002

@marcusradell
Copy link

I tried using Maybe's for the first time in my life, and wanted to do a simple console.log. I got a similar result with ap via @typed/prelude:
https://github.com/marcusnielsen/mostjs-labs/blob/master/src/index.ts#L11

 const log = (maybe) => prelude_1.ap(prelude_1.toMaybe(console.log), maybe);
TypeError: prelude_1.ap is not a function

I was guessing it's my fault since I've never used ap, Maybe, or this framework before. But seeming this issue, maybe it's the same bug? Any advice for moving forward?

@TylorS
Copy link
Owner Author

TylorS commented Oct 26, 2017

Hey @marcusnielsen there seems to be some sort of issue with the way TypeScript compiles ES2015 modules to commonjs. If you're interested in Maybe in particular, I'd suggest using @typed/maybe directly until we can figure out this issue here.

EDIT: Heres a webpackbin doing what is in your error message.
https://www.webpackbin.com/bins/-KxPOhHcGP9jecQJZ6Ot

@TylorS
Copy link
Owner Author

TylorS commented Oct 26, 2017

Additionally if you're using something like webpack to bundle your application, you can add module or jsnext:main to resolve.mainFields to use the ES2015 build instead and avoid this bug.

@marcusradell
Copy link

Using @typed/maybe worked out well! (I'm using tsc without webpack.)

Thanks for the help, I just did my first Maybe and ap , and it feels awesome 🎉

@TylorS
Copy link
Owner Author

TylorS commented Dec 31, 2017

I'm thinking that going forward we could just have yarn add @typed/prelude be a convenient shortcut for yarn add @typed/either @typed/functions @typed/lenses @typed/list @typed/logic @typed/math @typed/maybe @typed/objects @typed/strings but not re-export these packages from itself, but instead requiring explicit imports from the other @typed/* packages.

What do you think?

@Frikki
Copy link
Collaborator

Frikki commented Jan 9, 2018

I am much in favor of explicit imports. A convenient shortcut using @typed/prelude is preferable to re-exports.

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

No branches or pull requests

3 participants