Debian Codegraph @

util/build/plugins/text.js

raw symbols SCIP
1 define(["dojo/json", "../fs"], function(json, fs){
2 return {
3 start:function(
4 mid,
5 referenceModule,
6 bc
7 ){
8 // mid may contain a pragma (e.g. "!strip"); remove
9 mid = mid.split("!")[0];
10
11 var textPlugin = bc.amdResources["dojo/text"],
12 moduleInfo = bc.getSrcModuleInfo(mid, referenceModule, true),
13 textResource = bc.resources[moduleInfo.url];
14
15 if (!textPlugin){
16 throw new Error("text! plugin missing");
17 }
18 if (!textResource){
19 throw new Error("text resource (" + moduleInfo.url + ") missing");
20 }
21
22 var result = [textPlugin];
23 if(bc.internStrings && !bc.internSkip(moduleInfo.mid, referenceModule)){
24 result.push({
25 module:textResource,
26 pid:moduleInfo.pid,
27 mid:moduleInfo.mid,
28 deps:[],
29 getText:function(){
30 var text = this.module.getText ? this.module.getText() : this.module.text;
31 if(text===undefined){
32 // the module likely did not go through the read transform; therefore, just read it manually
33 text= fs.readFileSync(this.module.src, "utf8");
34 }
35 return json.stringify(text+"");
36 },
37 internStrings:function(){
38 return ["url:" + this.mid, this.getText()];
39 }
40 });
41 }
42 return result;
43 }
44 };
45 });