-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Targetting ES2015 modules for current browsers not possible (ts:import "name" -> js:import "./name.js") #21389
Comments
Yes, I work with tsc 2.6.2 and the common case works. I am actually left with a problem when using the preact library. For preact I hacked a preact.js with exports, such that the browser has an es2015 module. In addition, I use the preact.d.ts file provided by the preact author. For the latter, "./preact.js" does not work. Could you hint me on how I can deal with that? (now using string-replace on emitted js files, which I would like to get rid of asap) |
You could use path mapping. import preact = require("preact");
export = preact; |
Success! Have to figure out the mechanisms going on behind the scenes. Added suggested preact.d.ts with
With that in place, import "./preact.js" fails with
Added a preact.ts with the contents of preact.d.ts .
By trials and accident found that the existence of the very same file with any arbitrary name, like p_r_e_act.ts, makes it working! Looks like files are scanned and exhibit effects based on their contents alone. A somewhat mystic but comfortable solution. Thank you so much for your thoughts and time, very helpful and highly appreciated! |
That can't be right, are you sure? Can you get a repro? |
The |
You are right, turns out that my above statements are not correct. Looks like some caching effects disturbed observations. I continue my trials. Thx for the additional input. |
I want to emit javascript with ES2015 modules. My tsconfig is
Problem: Typescript expects
In my js files I need however
Maybe might origin from partial browser implementations. At least I could not find any way to work with import "preact" in typesript and emitting import "./preact.js" in js.
Is there a way to get the "./name.js" for into emitted import statements?
If not, are there plans to appraoch the problem?
The text was updated successfully, but these errors were encountered: