Skip to content
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

Expect json file comilped to es6 module. #262

Closed
underfin opened this issue Jul 16, 2020 · 3 comments
Closed

Expect json file comilped to es6 module. #262

underfin opened this issue Jul 16, 2020 · 3 comments

Comments

@underfin
Copy link

Feature Request

Expect json file support comilped to es6 module.

Current behavior

The json file will compiled to common js module even passed target: 2020 options

{
  "hello": "this is json"
}
module.exports = {
  hello: "this is json"
};

Other Feature

It is great if it can support named export.

@evanw
Copy link
Owner

evanw commented Jul 16, 2020

It will be compiled into an ES6 module if imported using an ES6 import. Can you say more about your use case? How are you compiling this? Through the API? Through the command line? With what options?

@underfin
Copy link
Author

underfin commented Jul 17, 2020

Sorry for not provider more info at first.
I want to compile json to es6 modules not inside an es6 import. The use case is here https://github.com/vitejs/vite/blob/master/src/node/server/serverPluginJson.ts#L11 and use (await startService()).transform api to do this.The options is {loader: 'json',target: 'es2020'}

@evanw
Copy link
Owner

evanw commented Jul 19, 2020

It looks like this is a duplicate of #109. This would be possible if you could pass the format option when transforming.

@evanw evanw closed this as completed Jul 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants