-
Notifications
You must be signed in to change notification settings - Fork 12.2k
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
Replaces the default module index resolver with '/index' instead of '' when handling internal routing for dts bundles #39277
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new test looks good and it doesn't break any old tests.
However, you should probably also get signoff from @rbuckton or @weswigham since they understand emit issues better than I do.
Rough gist: the module names are wrong, not the import Chatted with @weswigham - when you have commonjs set as the target, you basically never want a .d.ts which would look like this - the core issue is in the declared module names (nothing in the generated .d.ts here is portable) without either:
declare module "packagename/nested/shared" {
export class B {
}
}
declare module "packagename/nested/base" {
import { B } from "packagename/nested/shared";
export function f(): B;
}
declare module "packagename/nested/derived" {
export function g(): import("packagename/nested").B;
}
declare module "packagename/nested" {
export * from "packagename/nested/base";
export * from "packagename/nested/derived";
export * from "packagename/nested/shared";
}
declare module "packagename" {
export * from "packagename/nested";
} Which could come from a compiler option. (an implicit look up wouldn't work in all cases) - Wes feels this is worth it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, looks basically good, but I'd like to see the output of the test that's missing baselines, and I have a follow-up question for @weswigham 's suggestion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont think adding new option is right thing to do here.
If i read the original issue, the chosen module name isnt correct. It is either chosing incorrect file to import or transformation of name of that importing file to what it means in d.ts is incorrect . And i think fixing that is the right thing to do.
@sheetalkamat The chosen module name is not incorrect. It is applying node module resolution, which is what was selected by the user. What wasn't happening was generating module names that actually make sense under node module resolution because, again, until the |
Like, nobody actually wants their root module named |
Co-authored-by: Wesley Wigham <wwigham@gmail.com>
Now that I've got this updated, and the are in baselines too, I feel like I want to dig into some of these baselines to make sure we're not over-reporting on this. |
Alright, I've updated this PR and tests are green - I'm a little unsure how to get the final part passed because I can't add |
@sheetalkamat @weswigham can you take another look and decide whether the updated PR is good? (I've somewhat arbitrarily assigned the PR to @sheetalkamat because I want to have a single assignee). |
I helped design/write this one, so I'm biased anyway~ (and think this is pretty good) |
OK, I've made changes to the tsconfigs in this repo to negate the error instead 👍🏻 |
I think this ended up being is a breaking change for people who were using post-processors to make non-module code work with modules (like our team). var _chai: typeof import("chai") = require("chai") |
const fromPaths = paths && tryGetModuleNameFromPaths(removeFileExtension(relativeToBaseUrl), importRelativeToBaseUrl, paths); | ||
const bundledPkgReference = bundledPackageName ? combinePaths(bundledPackageName, relativeToBaseUrl) : relativeToBaseUrl; | ||
const importRelativeToBaseUrl = removeExtensionAndIndexPostFix(bundledPkgReference, ending, compilerOptions); | ||
const fromPaths = paths && tryGetModuleNameFromPaths(removeFileExtension(bundledPkgReference), importRelativeToBaseUrl, paths); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm late to the party here, but I don't think it's right to pass the bundled package reference to tryGetModuleNameFromPaths
. These values get tested for equality with the values in the paths
value arrays (with *
substitutions applied), which are absolute paths. bundledPkgReference
will presumably not be an absolute path, so this will prevent paths
from ever being used to generate a module specifier in tandem with bundledPackageName
. Or, maybe that's the intent? I can't totally wrap my mind around how/why these options would ever be used together.
Coming back to this issue, I really want to revisit @sheetalkamat's concern here. I don't think I would have anticipated this option nor this break would go in without some design meeting discussion. I also feel uneasy about the naming - why would we call this |
It actually does affect |
Restores #1313. Also: New changes: - Changed build scripts to ensure amd.js is included in `decentraland-ecs/artifacts` folder. That was causing a regression. - Enabled scene logs in `preview` mode - typescript property `useDefineForClassFields` must be false to work with the ECS decorators [more info here](arduz-online/ulla@8ccf73f) For future PR: when Typescript 4.1 reaches GA, we should implement this automatic configuration for libraries only: - [Blog post](https://devblogs.microsoft.com/typescript/announcing-typescript-4-1-beta/#declaration-and-outfile-requires-a-package-name-root) - microsoft/TypeScript#39277 Co-authored-by: pablitar <pablo@decentraland.org> Co-authored-by: Pablo de Haro <pablitar@gmail.com>
* Reverts microsoft#39277 * Bring back modeyule resolution for the test runner
Fixes #31280
Previously when bundled:
Would convert to:
Which is kinda weird:
Now, it would raise a compiler error:
Which requires you to add a new tsconfig option for the name of your package:
Old PR
Would have turning into:
But now that type
import
looks like:Which actually exists.