admin管理员组文章数量:1022543
Using TypeScript with SystemJS, how can I import a JSON file using plugin-json
?
If I write System.import('myjson.json!json').then(...)
then it imports it asynchronously and not as a part of System.register([...])
.
So, how can I import a JSON file as a part of System.register([...])
and convincing TypeScript to agree to this? (without then
Promise syntax).
Note:
I'm using the tsc
flag -m system
Update:
A possible solution is to use the -m umd
option for tsc
instead of -m system
, then I can do the following:
/// <reference path="typings/requirejs/require.d.ts" />
var myJson = require('myJson.json!json')
However, still waiting for an answer regarding usage of -m system
.
Using TypeScript with SystemJS, how can I import a JSON file using plugin-json
?
If I write System.import('myjson.json!json').then(...)
then it imports it asynchronously and not as a part of System.register([...])
.
So, how can I import a JSON file as a part of System.register([...])
and convincing TypeScript to agree to this? (without then
Promise syntax).
Note:
I'm using the tsc
flag -m system
Update:
A possible solution is to use the -m umd
option for tsc
instead of -m system
, then I can do the following:
/// <reference path="typings/requirejs/require.d.ts" />
var myJson = require('myJson.json!json')
However, still waiting for an answer regarding usage of -m system
.
- Why not to download a json file via a http request? Module systems are not designed for such tasks. – shadeglare Commented Jun 21, 2015 at 9:42
-
1
@MaxFX I want to use the
plugin-json
SystemJS module so when I build everything, systemjs will embed it all to one JS file, same goes for HTML templates, when I import them (to be used as angular controller templates), I want them all to be embedded in the built minified JS file. Loading via ajax will require putting these files too on production deployments. – Alon Amir Commented Jun 21, 2015 at 9:51
1 Answer
Reset to default 5In order to do : import json = require('myJson.json!json')
You need to have some .d.ts
file with the following:
declare module 'myJson.json!json'{
var json:any;
export = json;
}
Using TypeScript with SystemJS, how can I import a JSON file using plugin-json
?
If I write System.import('myjson.json!json').then(...)
then it imports it asynchronously and not as a part of System.register([...])
.
So, how can I import a JSON file as a part of System.register([...])
and convincing TypeScript to agree to this? (without then
Promise syntax).
Note:
I'm using the tsc
flag -m system
Update:
A possible solution is to use the -m umd
option for tsc
instead of -m system
, then I can do the following:
/// <reference path="typings/requirejs/require.d.ts" />
var myJson = require('myJson.json!json')
However, still waiting for an answer regarding usage of -m system
.
Using TypeScript with SystemJS, how can I import a JSON file using plugin-json
?
If I write System.import('myjson.json!json').then(...)
then it imports it asynchronously and not as a part of System.register([...])
.
So, how can I import a JSON file as a part of System.register([...])
and convincing TypeScript to agree to this? (without then
Promise syntax).
Note:
I'm using the tsc
flag -m system
Update:
A possible solution is to use the -m umd
option for tsc
instead of -m system
, then I can do the following:
/// <reference path="typings/requirejs/require.d.ts" />
var myJson = require('myJson.json!json')
However, still waiting for an answer regarding usage of -m system
.
- Why not to download a json file via a http request? Module systems are not designed for such tasks. – shadeglare Commented Jun 21, 2015 at 9:42
-
1
@MaxFX I want to use the
plugin-json
SystemJS module so when I build everything, systemjs will embed it all to one JS file, same goes for HTML templates, when I import them (to be used as angular controller templates), I want them all to be embedded in the built minified JS file. Loading via ajax will require putting these files too on production deployments. – Alon Amir Commented Jun 21, 2015 at 9:51
1 Answer
Reset to default 5In order to do : import json = require('myJson.json!json')
You need to have some .d.ts
file with the following:
declare module 'myJson.json!json'{
var json:any;
export = json;
}
本文标签: javascriptTypeScriptSystemJS using JSON and Text pluginsStack Overflow
版权声明:本文标题:javascript - TypeScript+SystemJS using JSON and Text plugins - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745565689a2156435.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论