Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

JavaScript.txt 5.4 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
  1. = JavaScript Packaging Guidelines
  2. :last-reviewed: 2019-01-17
  3. == Overview
  4. JavaScript code used for the web needs special consideration
  5. to ensure that it meets the high standards expected of all code shipped by Fedora,
  6. while still being useful
  7. and complying with conventions already used on millions of websites.
  8. Additionally, certain libraries typically used on the web
  9. can also be useful in a server-side context
  10. (by nodejs or rubygem-execjs),
  11. so it's important to package JavaScript so
  12. it meets the standards required of locally executed code as well.
  13. Please note that this section really only applies to JavaScript libraries
  14. intended for use on the web.
  15. Server-side JavaScript runtimes like
  16. Node.js xref:Node.js.adoc[have their own guidelines],
  17. and software like GNOME which embeds JavaScript for extensions
  18. have their own directories and policies as well.
  19. == Naming Guidelines
  20. The name of a JavaScript library package MUST start with
  21. `+js-+` then the upstream name. For example: `+js-jquery+`.
  22. == BuildRequires
  23. To ensure the presence of the necessary RPM macros,
  24. all packages that provide JavaScript in `+%{_jsdir}+` MUST have:
  25. BuildRequires: web-assets-devel
  26. == Requires
  27. To ensure the availability of the necessary directories,
  28. all packages that provide JavaScript in `+%{_jsdir}+` MUST have:
  29. Requires: web-assets-filesystem
  30. JavaScript packages MUST NOT have Requires on any
  31. HTTP daemon-specific configuration package,
  32. such as `+web-assets-httpd+`,
  33. since they could be used by any HTTP daemon.
  34. == RPM Macros
  35. |===
  36. |Macro |Normal Definition |Notes
  37. |`+%{_jsdir}+` |`+%{_datadir}/javascript+` |The directory where JavaScript libraries are stored
  38. |===
  39. == Install Location
  40. * If a JavaScript library can be executed locally
  41. or consists purely of JavaScript code,
  42. it MUST be installed into a subdirectory of `+%{_jsdir}+`.
  43. * If a package contains JavaScript code,
  44. but is never useful outside the browser
  45. (e.g. if it is some sort of HTML user interface library)
  46. it may instead install to `+%{_assetdir}+`.
  47. For more information, see xref:Web_Assets.adoc[the Web Assets guidelines].
  48. * If a package contains JavaScript code
  49. that is only used as part of a web application,
  50. and it is not useful to any other applications whatsoever,
  51. it may continue to ship that code along with the application.
  52. However, that does not absolve it from complying
  53. with the rest of these guidelines.
  54. * If a package contains JavaScript code
  55. that is not useful on the web,
  56. but only in locally run software
  57. (e.g. xref:Node.js.adoc[Node.js] or GNOME shell extensions),
  58. it should use the appropriate directory for its runtime,
  59. not `+%{_jsdir}+`.
  60. == Server Location
  61. JavaScript code is included as part of the general xref:Web_Assets.adoc[Web Assets framework].
  62. Therefore, `+%{_jsdir}+` is available on Fedora-provided web servers
  63. by default at `+/_sysassets/javascript/+`.
  64. For instance, jQuery may be installed in `+%{_jsdir}/jquery/jquery-min.js+`,
  65. so web applications that need to use it can simply include this HTML tag:
  66. ----
  67. <script type="text/javascript" src="/_sysassets/javascript/jquery/jquery-min.js"></script>;
  68. ----
  69. Regardless, web applications may want to make
  70. subdirectories of `+%{_jsdir}+` available
  71. under their own directory via aliases or symlinks
  72. for compatibility purposes
  73. or to eliminate needless deviation from upstream.
  74. == Compilation/Minification
  75. If a JavaScript library typically is shipped as minified or compiled code,
  76. it MUST be compiled or minified as part of the RPM build process.
  77. Shipping pre-minified or pre-compiled code is unacceptable in Fedora.
  78. The compiler or minifier used by upstream
  79. should be used to compile or minify the code.
  80. If the minifier used by upstream is unable to be included in Fedora,
  81. an alternative minifier may be used.
  82. See https://fedoraproject.org/wiki/JavaScript/Minification_Issues[this page]
  83. for a list of known problem areas and suggestions for workarounds.
  84. Additionally, the uncompiled/unminified version MUST be included
  85. alongside the compiled/minified version.
  86. Minified JavaScript is not useful for JavaScript run locally,
  87. as the entire point of minification is to reduce HTTP transfer times.
  88. Therefore, JavaScript not intended for the web
  89. (e.g. for Node.js or GNOME Shell extensions)
  90. MUST NOT be minified.
  91. == Bundling of other Libraries
  92. It is common for a single minified JavaScript file
  93. to contain bundled code from other JavaScript libraries.
  94. JavaScript is treated no differently
  95. than other libraries in this respect,
  96. so the
  97. xref:index.adoc#bundling[Bundling Guidelines].
  98. MUST still be followed.
  99. == Wrappers for Other Languages or Environments
  100. Sometimes there may exist a simple wrapper
  101. from a foreign language
  102. (like Ruby via rubygem-execjs or Java via rhino)
  103. or server-side JavaScript environment
  104. (like Node.js)
  105. to a pure JavaScript library.
  106. Such packages should delete the bundled library code
  107. and instead point to and Require the code provided
  108. by the primary Fedora package for that library.
  109. == Node.js Modules that contain browser/pure-JS components
  110. Some Node.js modules include parts that can be used in the browser
  111. or by other server-side JavaScript engines.
  112. Such packages should be shipped as one SRPM that contains two packages:
  113. * One `+js-foo+` package that contains
  114. the pure JavaScript portion, following these guidelines.
  115. * One `+nodejs-foo+` package that contains
  116. the Node.js module portion,
  117. following the xref:Node.js.adoc[Node.js guidelines].
  118. This may symlink to the necessary files or directories
  119. of the `+js-foo+` package.
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...