Comments (9)
Should be resolved in the esm
branch, however that's blocked by docs-ts: gcanti/docs-ts#59 (comment)
from fp-ts-std.
Actually in different projects I'm seeing different results. One works, the other complains about the fp-ts imports. 😒
from fp-ts-std.
I think 0.18.0-beta.3 is the first to work fully with both proper ESM and CJS.
Depending on the consuming project different packaging issues can surface, most of which don't reveal themselves when building here.
The latest surprise is that tsc requires the consuming project to be ESM to read a package's exports
field, hence the return of the typesVersions
hack.
from fp-ts-std.
Nope, spoke too soon, the fp-ts imports need updating. 😡
from fp-ts-std.
Webpack:
ERROR in ./node_modules/fp-ts-std/dist/esm/URL.js 2:0-34
Module not found: Error: Can't resolve 'fp-ts/Either' in '/path/to/repo/node_modules/fp-ts-std/dist/esm'
Did you mean 'Either.js'?
BREAKING CHANGE: The request 'fp-ts/Either' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
Similar in a Node REPL:
> await import('fp-ts-std/Array')
Uncaught:
Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import '/path/to/repo/node_modules/fp-ts/function' is not supported resolving ES modules imported from /path/to/repo/node_modules/fp-ts-std/dist/esm/Array.js
Did you mean to import fp-ts/lib/function.js?
at new NodeError (node:internal/errors:399:5)
at finalizeResolution (node:internal/modules/esm/resolve:319:17)
at moduleResolve (node:internal/modules/esm/resolve:945:10)
at defaultResolve (node:internal/modules/esm/resolve:1153:11)
at nextResolve (node:internal/modules/esm/loader:163:28)
at ESMLoader.resolve (node:internal/modules/esm/loader:838:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:77:40)
at link (node:internal/modules/esm/module_job:76:36) {
code: 'ERR_UNSUPPORTED_DIR_IMPORT',
url: 'file:///path/to/repo/node_modules/fp-ts/function'
}
From debugging in the REPL it looks like the imports need to be from lib
, not es6
.
from fp-ts-std.
^ Fixed in 0.18.0-beta.4
, however there's been some significant bundle bloat in a CJS project.
from fp-ts-std.
I'm interpreting this to mean that fp-ts-std effectively can't be ESM until fp-ts et al are.
Perhaps the bundle bloat could be resolved with some clever bundler.
from fp-ts-std.
The bundle bloat mostly goes away if the bundler is configured to rewrite fp-ts/lib
imports to fp-ts/es6
(e.g. Webpack's resolve.alias
). It doesn't entirely solve it however, and expecting non-ESM bundle-sensitive consumers to do this is a big ask.
from fp-ts-std.
The status quo makes the package effectively entirely broken for ESM projects as the subpath exports prevent you from manually importing from /cjs
. Curiously if you import a CJS module which in turn imports fp-ts-std it resolves correctly.
from fp-ts-std.
Related Issues (20)
- Index is missing new modules from 0.16 HOT 2
- IOOption type HOT 1
- Use NonEmptyString in Env HOT 1
- isInstanceOf constructor - constrain return type? HOT 1
- Enum typeclasses HOT 2
- More tuple operators HOT 1
- Unwrapping errors should always throw an `Error` object HOT 3
- fp-ts backports HOT 2
- get for struct
- Monadic memptyWhen/Unless HOT 1
- Do & apS HOT 1
- `pass` HOT 1
- `Struct.getEnum`
- `pass` doesn't widen additional type arguments HOT 1
- process module
- Many URLPath functions should exist in URL too HOT 1
- `N.fromString()` should not use `Number.parseInt()` HOT 2
- Unable to import fp-ts-std HOT 6
- URLPath origin/base can be lost HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fp-ts-std.