-
Notifications
You must be signed in to change notification settings - Fork 361
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
Wrong typescript emit path if --cwd is used #643
Comments
Ahh good point about external - we should be pre-populating the name when generating entry point externals but we aren't! |
Ah I found the cwd issue - we pass the package.json |
|
Fixed by #646 🎉 |
@marvinhagemeister Did you see my comment: #643 (comment) ? There is actually one topic in this issue that wasnt fixed by my pr: #643 (comment) 😅 |
@katywings oh I acted too quickly here. Sorry, that's on me 🙈 |
@katywings I wonder - would it be possible for Microbundle to just generate that proxy types file with the correct name? I'd love to keep things as close to zero-config as possible. |
@developit The problem is that typescript emits the types based on the structure of the source files including tsconfig path based "aliases". Say you have a structure like this:
Then the emit will be like
Because tsc tries to account for the ".." things I cannot think of a non over-engineering solution which could automatically account for the different possible file structures 🤔 Edit: This is how I automatically created type proxies in witney before the large microbundle rework. But such an automatism only works if you force the consumers into a specific lib file structure ^^. |
I kept thinking about what microbundle would need to do, to get correct dist types in all situations, but as I mentioned it, this is a very over engineered solution:
I hope its clear what I mean, let me know otherwise xD. |
Little update from my side: This is how I now handle the type proxies in my projects:
|
@developit I think I now understand, why Line 428 in 65df3c1
Normally the externals are directly passed into globals, but this regex pattern [a-z0-9_$] doesn't accept the dash - character and so microbundle-test will not be included in the globals :D. What do you think about adding - to the regex as valid character?
|
@katywings the trick there is that when something ends up in import test from 'microbundle-test';
+
globals['microbundle-test'] = 'microbundle-test'; ...will output: (function(factory, global) {
if (typeof define=='function' && define.amd) define(['microbundle-test'], factory);
else if (typeof module != 'undefined') module.exports = factory(require('microbundle-test'));
else global.foo = factory(global['microbundle-test']);
})(function(test){
}, this) Most libraries use |
@developit The only thing still "open" in this thread is the topic about typescript proxies (#643 (comment)) Since I think that this would need a lot over engineering, I gonna close this issue :) - you can reopen if you think this really should be worked out in microbundle. |
IS: If you use the cli cwd option to build a nested package
xyz
, the types are emitted into./dist/
.SHOULD: Types should be emitted into the dist folder
xyz/dist
of the nested package.DEMO:
npm install && ./scripts/build-devtools.js
dist/devtools/lib/main.d.ts
instead ofdevtools/dist/main.d.ts
REMARKS:
dist/main.d.ts
--external
cli option "freaks out" if the external has a dash character:microbundle
prints:No name was provided for external module 'microbundle-test' in output.globals – guessing 'microbundleTest'
. Doing the exact same bundle but naming the global "microbundletest" doesnt print this warning. (P.S. if you try this you also have to change the tsconfig.json path alias from microbundle-test to microbundletest)The text was updated successfully, but these errors were encountered: