Gentype / Bucklescript clean
Coobaha opened this issue · comments
I am publishing packages to npm to be consumed by TS users. Common file structure for this is to have js files and definitions/types alongside.
After bsc/gentype
build is done I am running tsc to output index.js
, index.gen.js
and index.gen.d.ts
for TS consumers
index.gen.d.ts # tsc artifact
index.re
index.bs.js # bsc artifact
index.gen.js # tsc artifact
index.gen.js.map # tsc artifact
index.gen.tsx # gentype artifact
I can't just publish raw JS output from reason/tsc, because package depends on other reason packages. So bsb -make-world
with dependency to my package should be called on consumer side... if clean is called it removes index.gen.js
and the only way to get it back is to reinstall package from npm.
Can bucklescript be aware of what files are generated by gentype and remove only them? For example based on gentypeConfig.language
setting (if it is set to "typescript"
- only index.gen.tsx
will be removed). Current behaviour is to remove all index.gen.{js,tsx,flow}
ping @bobzhang @cristianoc
Not sure where this issue should be opened, might be that Bucklescript is more correct place for it.
original and incorrect assumption about issue
Currently `bsb -clean-world` is removing genType generated files from `node_modules`, but `bsb -make-world` is not re-creating them. Should clean/build process be aligned in one of ways:- not cleaning
node_modules
genType generated files bsb -make-world
also generates types fromnode_modules
Second option is way trickier and hard to get it right? I will be happy with the first option.
@Coobaha the generated files in node_modules
: how did they get there in the first place?
They are published alongside with reason source. Consumers are using them as TS modules published to npm. As I mentioned in more context part I cant just publish JS artifacts because of transitive reason dependencies that are fetched from npm too.
What about .bs.js
artifacts: are they also published alongside? And what happens to them: are they removed on -clean-world
and re-created on -make-world
.
Just asking whether there is a distinction on how different kinds of artifacts are generated, so we can look into why.
Actually it is removing *.gen.js
files (which i am generating before publishing with tsc
from *.gen.tsx
)
before bsb -clean-world -make-world
index.re
index.bs.js
index.gen.js
index.gen.js.map
index.gen.tsx
after
index.re
index.bs.js
index.gen.js.map
index.gen.tsx
@Coobaha are .bs.js
files never removed? Or are they removed and re-built?
@cristianoc they are removed on -clean-world
, gentype files are recreated again but obviously index.bs.js
is not there because it is generated outside of bsb context. Probably Bucklescript should remove files based on gentypeConfig.language
setting. For example if it is set to typescript
- only index.gen.tsx
will be removed?
@Coobaha I'm still unclear why .gen.js
files are generated, as it appears they are not produced by genType. Could you use another extension, just to unblock this?
And yes, bsb clean could be a bit more specific (it makes sense to create and issue on this in the bucklescript repo).
I've updated issue description to be more clear. I can also come up with repro repo if needed
Not sure if i can, will check tsc
options
rescript-lang/rescript-compiler#4417 created new issue in the bucklescript repo
tsc
is not allowing this, the only option is to concatenate output to one file but it has drawbacks more details
Got it thanks.
I had no idea that ts generates .gen.js.