Comments (4)
suppose the issue is it potentially implies (falsely) that the src/ is part of the API contract of the package? And you want to restrict the surface area to the compiled source only?
Yes, exactly. I can extend on this reasoning, but this is exactly the point.
Ok, I will craft a PR. Thank you 😊
from create-universal-package.
So you are suggesting appending a .flow
file extension suffix to each file in src
before publishing?
The tricky thing is I think then paths/imports would have to be rewritten. I'm curious to learn more about why publishing the original source be an issue, can you elaborate?
from create-universal-package.
@rtsao , I see what you mean. I guess your strategy is a bit different here. Since you create a brand new index.js.flow
file that references the src folder. I am actually not exactly sure why did you got that route...
What I have seen people do is they provide untouched raw js.flow files alongside with compiled ones.
So currently the structure cup generates looks like this for example:
- dist-node-cjs
-- client.js [transpiled]
-- index.js [transpiled]
-- index.js.flow [export * from "../src/index.js";]
- src
-- index.js [raw]
-- client.js [raw]
What I have seen libs do is the following:
- dist-node-cjs
-- client.js [transpiled]
-- client.js.flow [raw client.js]
-- index.js [transpiled]
-- index.js.flow [raw index.js]
Then you shouldn't need to do anything about paths, and you avoid exposing your raw code to the consumers (ie it is not accessible via js require\import
).
There is a util to do this. Baseweb has a custom script
Here is github discussion about the best strategies to expose flow types for a lib
from create-universal-package.
I see, thanks. I think the original reasoning for the current design is twofold:
- Less copying (only a single extra file needs to be created)
- Less ambiguity if there is explicit type definitions, (e.g. there is both
src/foo.js
andsrc/foo.js.flow
)
I felt like the current approach is the simplest implementation. I think your suggestion would also work fine though. If you wanted to put up a PR, I'd be happy to review!
Would you help me understand the motivation behind hiding the original source? If consumers are importing that directly, isn't that their prerogative?
I suppose the issue is it potentially implies (falsely) that the src/
is part of the API contract of the package? And you want to restrict the surface area to the compiled source only?
from create-universal-package.
Related Issues (15)
- Compatibility with yarn create command
- support for UMD build HOT 1
- Output flow type annotations
- Reconsider test build process HOT 1
- Enforce package.json "files" field is set to "dist" HOT 1
- Configuration file
- Flow and named export problem HOT 1
- Consider replacing Rollup w/ sideEffects: false
- Add rollup-plugin-json HOT 1
- RFC: create-universal-package v4
- Fails to build saying "Unexpected token, expected "," " when it hits React context component HOT 2
- Watch-build mode HOT 2
- Better stdout on CI HOT 2
- Don't hardcode babel-preset-env exclusions for ES2015 bundles
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 create-universal-package.