| 
									
										
										
										
											2017-08-05 06:32:57 +00:00
										 |  |  | # RequireJS
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-01 16:32:08 +00:00
										 |  |  | The module complies with the AMD `define` semantics, enabling use in RequireJS | 
					
						
							|  |  |  | out of the box. | 
					
						
							| 
									
										
										
										
											2017-08-05 06:32:57 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-24 23:40:09 +00:00
										 |  |  | The require config should set `xlsx` path to the appropriate dist file: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ```js | 
					
						
							|  |  |  | 	paths: { | 
					
						
							|  |  |  | 		xlsx: "xlsx.full.min" | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-01 16:32:08 +00:00
										 |  |  | Once that is set, app code can freely require `"xlsx"`: | 
					
						
							| 
									
										
										
										
											2017-09-24 23:40:09 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | ```js | 
					
						
							| 
									
										
										
										
											2018-06-01 16:32:08 +00:00
										 |  |  | require(["xlsx"], function(XLSX) { | 
					
						
							| 
									
										
										
										
											2017-09-24 23:40:09 +00:00
										 |  |  | 	/* use XLSX here */ | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ## Deployments
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | `browser.html` demonstrates a dynamic deployment, using the in-browser config: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ```html | 
					
						
							|  |  |  | <script src="require.js"></script> | 
					
						
							|  |  |  | <script> | 
					
						
							|  |  |  | require.config({ | 
					
						
							|  |  |  | 	baseUrl: ".", | 
					
						
							|  |  |  | 	name: "app", | 
					
						
							|  |  |  | 	paths: { | 
					
						
							|  |  |  | 		xlsx: "xlsx.full.min" | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | </script> | 
					
						
							|  |  |  | <script src="app.js"></script> | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | `optimizer.html` demonstrates an optimized deployment using `build.js` config: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ```js | 
					
						
							|  |  |  | /* build config */ | 
					
						
							|  |  |  | ({ | 
					
						
							|  |  |  | 	baseUrl: ".", | 
					
						
							|  |  |  | 	name: "app", | 
					
						
							|  |  |  | 	paths: { | 
					
						
							|  |  |  | 		xlsx: "xlsx.full.min" | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	out: "app-built.js" | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | The optimizer is invoked with: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ```bash | 
					
						
							|  |  |  | node r.js -o build.js paths.requireLib=./require include=requireLib | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | That step creates a file `app-built.js` that can be included in a page: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ```html | 
					
						
							| 
									
										
										
										
											2018-06-01 16:32:08 +00:00
										 |  |  | <!-- final bundle includes require.js, library and app code --> | 
					
						
							| 
									
										
										
										
											2017-09-24 23:40:09 +00:00
										 |  |  | <script src="app-built.js"></script> | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [](https://github.com/SheetJS/js-xlsx) |