opal-webpack-loader 0.7.1 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE +21 -0
- data/lib/opal-webpack-loader/version.rb +1 -1
- data/readme.md +340 -0
- metadata +7 -15
- data/spec/fixtures/flattering/Gemfile +0 -10
- data/spec/fixtures/flattering/config.ru +0 -22
- data/spec/installer_spec.rb +0 -100
- data/spec/owl_spec.rb +0 -105
- data/spec/spec_helper.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35c2949cd7cbe92ee220b608ee25589900f80a9dca13ae0d9a01e0b12f342188
|
4
|
+
data.tar.gz: edcb7595436d4334d3e0dd17c9c6dd5f998a4f70a22335f5fd155faff9575db2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f181858e65471a1915c330d425636ba965f3690271b597ebebd52b39df13a0f3ed905c0038f890147a2556f851a0073271adfed457c39e81bd9c13f7a6055d99
|
7
|
+
data.tar.gz: 9201d624ffc9cb34ad31de04494e82acaf6bfcbd552df24bd202756a44842fab75b3ca91433986fa90ef8999e29fb2b45f006b4147482278344dcd1825481c47
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2018, 2019 Jan Biedermann
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/readme.md
ADDED
@@ -0,0 +1,340 @@
|
|
1
|
+
# opal-webpack-loader
|
2
|
+
Bundle assets with webpack, resolve and compile opal ruby files and import them in the bundle, without sprockets or the webpacker gem
|
3
|
+
(but can be used with both of them too).
|
4
|
+
Includes a loader and resolver plugin for webpack.
|
5
|
+
|
6
|
+
### Community and Support
|
7
|
+
At the [Isomorfeus Framework Project](http://isomorfeus.com)
|
8
|
+
|
9
|
+
### Features
|
10
|
+
- comes with a installer for rails and other frameworks
|
11
|
+
- webpack based build process
|
12
|
+
- very fast, asynchronous and parallel builds of opal code:
|
13
|
+
opal-webpack-loader-0.7.1 compiles all of opal, a bunch of gems and over 19000SLC on a
|
14
|
+
Intel® Core™ i7-7700HQ CPU @ 2.80GHz × 8, with 8 workers in around 1850ms
|
15
|
+
- opal modules are packaged as es6 modules
|
16
|
+
- other webpack features become available, like:
|
17
|
+
- source maps
|
18
|
+
- multiple targets: web (for browsers), node (for server side rendering) and webworker (for Web Workers)
|
19
|
+
- hot module reloading for opal ruby code and stylesheets and html views
|
20
|
+
- tree shaking
|
21
|
+
- code splitting
|
22
|
+
- lazy loading
|
23
|
+
- everything else webpack can do, like loading stylesheets, etc.
|
24
|
+
|
25
|
+
### Requirements
|
26
|
+
- webpack 4.30
|
27
|
+
- webpack-dev-server 3.3.0
|
28
|
+
- es6_import_export branch of opal, [PR#1832](https://github.com/opal/opal/pull/1832)
|
29
|
+
- if you have webpacker gem installed somewhere, it should be a version supporting webpack 4
|
30
|
+
- ruby, version 2.5 or higher recommended
|
31
|
+
- bundler, latest version recommended
|
32
|
+
|
33
|
+
### Installation
|
34
|
+
|
35
|
+
#### Using the installer
|
36
|
+
First install the gem:
|
37
|
+
```
|
38
|
+
gem install 'opal-webpack-loader'
|
39
|
+
```
|
40
|
+
##### Install for Rails like projects
|
41
|
+
If you start a new rails project, the following options are recommended for `rails new`: `--skip-sprockets --skip-javascript`
|
42
|
+
|
43
|
+
Then within the projects root directory execute:
|
44
|
+
```bash
|
45
|
+
owl-install rails
|
46
|
+
```
|
47
|
+
If you have the webpacker gem installed, you need to merge the configuration in the config/webpacker directory.
|
48
|
+
A example for config/webpack/development.js is in the
|
49
|
+
[templates](https://github.com/isomorfeus/opal-webpack-loader/blob/master/lib/opal-webpack-loader/templates/webpacker_development.js_example).
|
50
|
+
|
51
|
+
Please see the messages of owl-install. You may need to manually add the following gems to the projects Gemfile:
|
52
|
+
```ruby
|
53
|
+
gem 'opal', github: 'janbiedermann/opal', branch: 'es6_import_export'
|
54
|
+
gem 'opal-webpack-loader', '~> 0.6.2' # use the most recent released version here
|
55
|
+
```
|
56
|
+
|
57
|
+
Then:
|
58
|
+
```bash
|
59
|
+
yarn install
|
60
|
+
bundle install
|
61
|
+
```
|
62
|
+
Opal ruby files should then go in the newly created `app/opal` directory. With the option -o the directory can be named differently, for example:
|
63
|
+
```bash
|
64
|
+
owl-install rails -o hyperhyper
|
65
|
+
```
|
66
|
+
A directory `app/hyperhyper` will be created, opal files should then go there and will be properly resolved by webpack.
|
67
|
+
|
68
|
+
Complete set of directories and files created by the installer for projects with a rails like structure:
|
69
|
+
```
|
70
|
+
project_root
|
71
|
+
+- app
|
72
|
+
+- assets
|
73
|
+
+- javascripts # javascript entries directory
|
74
|
+
+- styles # directory for stylesheets
|
75
|
+
+- opal # directory for opal application files, can be changed with -o
|
76
|
+
+- config
|
77
|
+
+- webpack # directory for webpack configuration files
|
78
|
+
+- initializers
|
79
|
+
+- opal_webpack_loader.rb # initializer for owl
|
80
|
+
+- package.json # package config for npm/yarn and their scripts
|
81
|
+
+- public
|
82
|
+
+- assets # directory for compiled output files
|
83
|
+
+- Procfile # config file for foreman
|
84
|
+
```
|
85
|
+
|
86
|
+
##### Install for Cuba, Roda, Sinatra and others with a flat structure
|
87
|
+
```bash
|
88
|
+
owl-install flat
|
89
|
+
```
|
90
|
+
|
91
|
+
Please see the message of owl-install. You may need to manually add the following gems to the projects Gemfile:
|
92
|
+
```ruby
|
93
|
+
gem 'opal', github: 'janbiedermann/opal', branch: 'es6_import_export'
|
94
|
+
gem 'opal-webpack-loader', '~> 0.5.1'
|
95
|
+
```
|
96
|
+
|
97
|
+
Then:
|
98
|
+
```bash
|
99
|
+
yarn install
|
100
|
+
bundle install
|
101
|
+
```
|
102
|
+
The installer produces a `app_loader.rb` which `require './owl_init'`. `app_loader.rb` is used by the compile server to correctly determine opal load
|
103
|
+
paths. It should be required by `config.ru`.
|
104
|
+
Opal ruby files should then go in the newly created `opal` directory. With the option -o the directory can be named differently, for example:
|
105
|
+
```bash
|
106
|
+
owl-install rails -o supersuper
|
107
|
+
```
|
108
|
+
A directory `supersuper` will be created, opal files should then go there and will be properly resolved by webpack.
|
109
|
+
|
110
|
+
Complete set of directories and files created by the installer for projects with a flat structure:
|
111
|
+
```
|
112
|
+
project_root
|
113
|
+
+- owl_init.rb # initializer for owl
|
114
|
+
+- javascripts # javascript entries directory
|
115
|
+
+- opal # directory for opal application files, can be changed with -o
|
116
|
+
+- package.json # package config for npm/yarn and their scripts
|
117
|
+
+- public
|
118
|
+
+- assets # directory for compiled output files
|
119
|
+
+- styles # directory for stylesheets
|
120
|
+
+- webpack # directory for webpack configuration files
|
121
|
+
+- Procfile # config file for foreman
|
122
|
+
```
|
123
|
+
|
124
|
+
#### Manual Installation
|
125
|
+
##### Install the accompanying NPM package:
|
126
|
+
one of:
|
127
|
+
```bash
|
128
|
+
npm i opal-webpack-loader
|
129
|
+
yarn add opal-webpack-loader
|
130
|
+
```
|
131
|
+
##### Install the gems
|
132
|
+
```bash
|
133
|
+
gem install opal-webpack-loader
|
134
|
+
```
|
135
|
+
or add it to the Gemfile as below and `bundle install`
|
136
|
+
```ruby
|
137
|
+
source 'https://rubygems.org'
|
138
|
+
|
139
|
+
gem 'opal', github: 'janbiedermann/opal', branch: 'es6_import_export' # requires this branch
|
140
|
+
gem 'opal-autoloader' # recommended
|
141
|
+
gem 'opal-webpack-loader'
|
142
|
+
```
|
143
|
+
##### Install the configuration
|
144
|
+
See the [configuration templates](https://github.com/isomorfeus/opal-webpack-loader/tree/master/lib/opal-webpack-loader/templates)
|
145
|
+
and adjust to your preference.
|
146
|
+
|
147
|
+
### General Usage
|
148
|
+
|
149
|
+
After installing owl with the installer, three scripts are provided in package.json:
|
150
|
+
- `development` - runs the webpack-dev-server, use for general development, provides fast reloads, entry is application.js
|
151
|
+
- `debug` - runs the webpack-dev-server, use for debugging, provides source maps, entry is application_debug.js. Additional debugging tools may be added there.
|
152
|
+
- `production_build` - runs webpack to build assets for production, entry is application.js
|
153
|
+
|
154
|
+
These scripts can for example be run with:
|
155
|
+
`yarn run debug` or `npm run debug`
|
156
|
+
|
157
|
+
The default config provides several targets and entries:
|
158
|
+
|
159
|
+
- **Browser**: the webpack target is 'web' and the javascript entry file for imports is `application.js` - general use for the application with all
|
160
|
+
browser features, the opal ruby entry file is `opal_loader.rb` in the opal or app/opal directory of the app.
|
161
|
+
- **Server Side Rendering**: the webpack target is `node` and the javascript entry file for imports is `application_ssr.js` - general use for the
|
162
|
+
application server side rendering, several Browser features are unavailable, no `window`, no `document`, some node features are available,
|
163
|
+
like `Buffer`, the opal ruby entry file is `opal_loader.rb` in the opal or app/opal directory of the app.
|
164
|
+
(meant to be used with isomorfeus-speednode, standard ExecJS limitations prevent certain webpack features)
|
165
|
+
- **Web Worker**: the webpack target is 'webworker' and the javascript entry file for imports is `application_webworker.js` - used to initialize Web
|
166
|
+
Workers in the browser, the opal ruby entry file is `opal_webworker_loader.rb` in the opal or app/opal directory of the app.
|
167
|
+
|
168
|
+
Only the browser target is build by default. To builds the other target, just add the needed targets to the last line of the webpack config,
|
169
|
+
for example to `development.js`:
|
170
|
+
default config:
|
171
|
+
```javascript
|
172
|
+
module.exports = [ browser ];
|
173
|
+
```
|
174
|
+
modified config with ssr and web_worker targets enabled:
|
175
|
+
```javascript
|
176
|
+
module.exports = [ browser, ssr, web_worker ];
|
177
|
+
```
|
178
|
+
Same works for the `debug.js` and `production.js` webpack config files.
|
179
|
+
|
180
|
+
Also a Procfile has been installed, for rails its easy to startup rails and webpack with foreman:
|
181
|
+
`foreman start` (`gem install foreman` if you dont have it already). It will start rails and webpack-dev-server with the development script.
|
182
|
+
|
183
|
+
For non rails installation check the Procfile and add a starter for your app.
|
184
|
+
|
185
|
+
#### Opal Ruby Application Files
|
186
|
+
For rails installations with the installer they all go into: `app/opal`, for flat installations in the `opal` directory.
|
187
|
+
In this directory there already is a `opal_loader.rb` which is the entry point for your app.
|
188
|
+
|
189
|
+
#### Stylesheets
|
190
|
+
Stylesheets are hot reloaded too with the default config installed by the installer. Also they are imported into application.js by default.
|
191
|
+
For rails like applications stylesheets are in `app/assets/stylesheets/application.css`, for flat applications they are in `styles/application.css`.
|
192
|
+
SCSS is supported too by the default config.
|
193
|
+
|
194
|
+
#### Views
|
195
|
+
For rails like applications a watcher for `app/views` is installed by default. The watcher will trigger a page reload when views are changed.
|
196
|
+
For flat applications nothing is configured by default, as there are to many ways to generate views, they are not even needed with
|
197
|
+
frameworks like isomorfeus. Instead the section for configuring a view watcher is included in the development.js and debug.js webpack
|
198
|
+
config, but it is commented out. Please see those files and adjust to your liking.
|
199
|
+
|
200
|
+
#### Parallel compilation for speed
|
201
|
+
For speed the number of workers for compiling opal ruby files can be adjusted in `package.json` -> "scripts" key:
|
202
|
+
Default entries look like:
|
203
|
+
`"production_build": "bundle exec opal-webpack-compile-server start 4 webpack --config=config/webpack/production.js"`
|
204
|
+
The compile server will start 4 workers for compiling opal files. The recommended number of workers should be 4 for machines with 4 or less cores,
|
205
|
+
or equal to the number of cores, for machines with up to 12 cores. More than 12 can't be kept busy by webpack it seems, ymmv.
|
206
|
+
Example for 8 cores:
|
207
|
+
`"production_build": "bundle exec opal-webpack-compile-server start 8 webpack --config=config/webpack/production.js"`
|
208
|
+
### Source Maps
|
209
|
+
|
210
|
+
#### Source Map Demo
|
211
|
+
[](https://www.youtube.com/watch?v=SCmDYu_MLQU)
|
212
|
+
|
213
|
+
It shows a exception during a page load. In the console tab of the browsers developer tools, the error message is then expanded and just by clicking
|
214
|
+
on the shown file:line_numer link, the browser shows the ruby source code, where the exception occured.
|
215
|
+
|
216
|
+
#### Source Map Configuration
|
217
|
+
|
218
|
+
The opal-webpack-loader for webpack supports the following options to enable HMR:
|
219
|
+
(These are options for the webpack config, not to be confused with the owl ruby project options further down below)
|
220
|
+
```javascript
|
221
|
+
loader: 'opal-webpack-loader',
|
222
|
+
options: {
|
223
|
+
sourceMap: true
|
224
|
+
}
|
225
|
+
```
|
226
|
+
|
227
|
+
- `sourceMap` : enable (`true`) or disable (`false`) source maps. Optional, default: `false`
|
228
|
+
|
229
|
+
Also source maps must be enabled in webpack. See [webpack devtool configuration](https://webpack.js.org/configuration/devtool).
|
230
|
+
### Hot Module Reloading
|
231
|
+
|
232
|
+
#### HMR Demo
|
233
|
+
|
234
|
+
[](https://www.youtube.com/watch?v=igF3cUsZrAQ)
|
235
|
+
|
236
|
+
(Recommended to watch in FullHD)
|
237
|
+
|
238
|
+
#### HMR and Ruby
|
239
|
+
|
240
|
+
When a module uses method aliasing and is reloaded, the aliases are applied again, which may lead to a endless recursion of method calls of
|
241
|
+
the aliased method once called after hot reloading.
|
242
|
+
To prevent that, the alias should be conditional, only be applied if the alias has not been applied before. Or alternatively the original
|
243
|
+
method must be restored before aliasing it again.
|
244
|
+
Because gems are not hot reloaded, this is not a issue for imported gems, but must be taken care of within the projects code.
|
245
|
+
|
246
|
+
Also it must be considered, that other code, which without hot reloading would only execute once during the programs life cycle, possibly will
|
247
|
+
execute many times when hot reloaded. "initialization code" should be guarded to prevent it from executing many times.
|
248
|
+
|
249
|
+
#### HMR Configuration
|
250
|
+
|
251
|
+
The opal-webpack-loader for webpack supports the following options to enable HMR:
|
252
|
+
(These are options for the webpack config, not to be confused with the owl ruby project options further down below)
|
253
|
+
```javascript
|
254
|
+
loader: 'opal-webpack-loader',
|
255
|
+
options: {
|
256
|
+
hmr: true,
|
257
|
+
hmrHook: 'global.Opal.ViewJS["$force_update!"]();'
|
258
|
+
}
|
259
|
+
```
|
260
|
+
|
261
|
+
- `hmr` : enable (`true`) or disable (`false`) hot module reloading. Optional, default: `false`
|
262
|
+
- `hmrHook` : A javascript expression as string which will be executed after the new code has been loaded.
|
263
|
+
Useful to trigger a render or update for React or ViewJS projects.
|
264
|
+
|
265
|
+
Note: HMR works only for files within the project tree. Files outside the project tree are not hot reloaded.
|
266
|
+
|
267
|
+
### Opal Load Path
|
268
|
+
The projects directory for opal ruby files must be in the opal load path. This is done in the initializer for rails apps in
|
269
|
+
config/initializers/opal_webpack_loader.rb or in 'owl_init.rb' for non rails apps, for example:
|
270
|
+
```ruby
|
271
|
+
Opal.append_path(File.realdirpath('app/opal'))
|
272
|
+
```
|
273
|
+
|
274
|
+
### View Helper
|
275
|
+
In Rails or frameworks that support `javscript_include_tag`, add to the app/helpers/application_helper.rb
|
276
|
+
```ruby
|
277
|
+
module ApplicationHelper
|
278
|
+
include OpalWebpackLoader::RailsViewHelper
|
279
|
+
```
|
280
|
+
in other frameworks that dont have a `javascript_include_tag`:
|
281
|
+
```ruby
|
282
|
+
module MyProjectsViewThings
|
283
|
+
include OpalWebpackLoader::ViewHelper
|
284
|
+
```
|
285
|
+
|
286
|
+
Then you can use in your views:
|
287
|
+
```ruby
|
288
|
+
owl_script_tag('application.js')
|
289
|
+
```
|
290
|
+
#### Compile Server and app_loader.rb
|
291
|
+
For non rails projects, determining Opal load paths, for the resolver and compile server to work properly, may not be obvious. For these cases
|
292
|
+
a file `app_loader.rb` in the projects root can be created which just loads all requirements without starting anything.
|
293
|
+
Usually it would just setup bundler with the appropriate options, for example:
|
294
|
+
```ruby
|
295
|
+
require 'bundler/setup'
|
296
|
+
if ENV['MY_PROJECT_ENV'] && ENV['MY_PROJECT_ENV'] == 'test'
|
297
|
+
Bundler.require(:default, :test)
|
298
|
+
elsif ENV['MY_PROJECT_ENV'] && ENV['MY_PROJECT_ENV'] == 'production'
|
299
|
+
Bundler.require(:default, :production)
|
300
|
+
else
|
301
|
+
Bundler.require(:default, :development)
|
302
|
+
end
|
303
|
+
require './owl_init.rb' # this is a good place to require the opal-webpack-loader initializer, to get the apps opal load path
|
304
|
+
```
|
305
|
+
When this file exists, the compile server will load it and generate Opal load paths accordingly for the resolver.
|
306
|
+
|
307
|
+
#### Project configuration options for the view helper
|
308
|
+
These setting are in the initializer in config/initializers/opal_webpack_loader.rb for rails like apps, or owl_init.rb for others.
|
309
|
+
```ruby
|
310
|
+
OpalWebpackLoader.use_manifest = false
|
311
|
+
```
|
312
|
+
If the manifest file should be used, use_manifest should be true.
|
313
|
+
```ruby
|
314
|
+
OpalWebpackLoader.manifest_path = File.join(Dir.getwd, 'public', 'assets', 'manifest.json')
|
315
|
+
```
|
316
|
+
Sets the path to the webpack (with the [webpack-manifest-plugin](https://www.npmjs.com/package/webpack-manifest-plugin)) generated manifest.json to look up assets.
|
317
|
+
```ruby
|
318
|
+
OpalWebpackLoader.client_asset_path = 'http://localhost:3035/assets/'
|
319
|
+
```
|
320
|
+
The path to prepend to the assets as configured in the webpack config 'publicPath'.
|
321
|
+
In the config example below its `publicPath: 'http://localhost:3025/assets'` so
|
322
|
+
client_asset_path should be set to the same.
|
323
|
+
|
324
|
+
For **production** use with readily precompiled and compressed assets which contain a fingerprint in the name (webpacks [chunkhash]),
|
325
|
+
and if the path in the manifest is the full path to the asset as configured in webpack,
|
326
|
+
these settings would work:
|
327
|
+
```ruby
|
328
|
+
OpalWebpackLoader.use_manifest = true
|
329
|
+
OpalWebpackLoader.manifest_path = File.join(Dir.getwd, 'public', 'assets', 'manifest.json')
|
330
|
+
OpalWebpackLoader.client_asset_path = ''
|
331
|
+
```
|
332
|
+
|
333
|
+
For **development** use with webpack-dev-server, with no manifest, these settings would work:
|
334
|
+
```ruby
|
335
|
+
OpalWebpackLoader.use_manifest = false
|
336
|
+
OpalWebpackLoader.manifest_path = File.join(Dir.getwd, 'public', 'assets', 'manifest.json') # doesn't matter, not used
|
337
|
+
OpalWebpackLoader.client_asset_path = 'http://localhost:3035/assets/'
|
338
|
+
```
|
339
|
+
### Example webpack configuration
|
340
|
+
See the [configuration templates](https://github.com/isomorfeus/opal-webpack-loader/tree/master/lib/opal-webpack-loader/templates).
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opal-webpack-loader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Biedermann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opal
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.11.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.11.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
@@ -132,6 +132,7 @@ executables:
|
|
132
132
|
extensions: []
|
133
133
|
extra_rdoc_files: []
|
134
134
|
files:
|
135
|
+
- LICENSE
|
135
136
|
- bin/opal-webpack-compile-server
|
136
137
|
- bin/owl-install
|
137
138
|
- lib/opal-webpack-loader.rb
|
@@ -159,11 +160,7 @@ files:
|
|
159
160
|
- lib/opal-webpack-loader/templates/webpacker_development.js_example
|
160
161
|
- lib/opal-webpack-loader/version.rb
|
161
162
|
- lib/opal-webpack-loader/view_helper.rb
|
162
|
-
-
|
163
|
-
- spec/fixtures/flattering/config.ru
|
164
|
-
- spec/installer_spec.rb
|
165
|
-
- spec/owl_spec.rb
|
166
|
-
- spec/spec_helper.rb
|
163
|
+
- readme.md
|
167
164
|
homepage: http://isomorfeus.com
|
168
165
|
licenses:
|
169
166
|
- MIT
|
@@ -188,9 +185,4 @@ signing_key:
|
|
188
185
|
specification_version: 4
|
189
186
|
summary: Bundle assets with webpack, resolve and compile opal ruby files and import
|
190
187
|
them in the bundle.
|
191
|
-
test_files:
|
192
|
-
- spec/fixtures/flattering/Gemfile
|
193
|
-
- spec/fixtures/flattering/config.ru
|
194
|
-
- spec/installer_spec.rb
|
195
|
-
- spec/owl_spec.rb
|
196
|
-
- spec/spec_helper.rb
|
188
|
+
test_files: []
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require './app_loader.rb'
|
2
|
-
|
3
|
-
class App < Roda
|
4
|
-
|
5
|
-
|
6
|
-
route do |r|
|
7
|
-
r.root do
|
8
|
-
<<~HTML
|
9
|
-
<html>
|
10
|
-
<head>
|
11
|
-
<title>Welcome</title>
|
12
|
-
</head>
|
13
|
-
<body>
|
14
|
-
<div>Hello world!</div>
|
15
|
-
</body>
|
16
|
-
</html>
|
17
|
-
HTML
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
run App.app
|
data/spec/installer_spec.rb
DELETED
@@ -1,100 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe 'owl installer' do
|
4
|
-
context 'structure: :app' do
|
5
|
-
before do
|
6
|
-
Dir.chdir('spec')
|
7
|
-
Dir.chdir('test_apps')
|
8
|
-
FileUtils.rm_rf('railing') if Dir.exist?('railing')
|
9
|
-
end
|
10
|
-
|
11
|
-
after do
|
12
|
-
Dir.chdir('..') if Dir.pwd.end_with?('railing')
|
13
|
-
FileUtils.rm_rf('railing') if Dir.exist?('railing')
|
14
|
-
Dir.chdir('..')
|
15
|
-
Dir.chdir('..')
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'can install in a rails app without sprockets and webpacker gem' do
|
19
|
-
`bundle exec rails new railing --skip-git --skip-bundle --skip-sprockets --skip-spring --skip-bootsnap`
|
20
|
-
expect(Dir.exist?('railing')).to be true
|
21
|
-
Dir.chdir('railing')
|
22
|
-
arg_val = %w[rails]
|
23
|
-
expect(Dir.exist?(File.join('railing', 'config', 'webpack'))).to be false
|
24
|
-
OpalWebpackLoader::Installer::CLI.start(arg_val)
|
25
|
-
expect(File.exist?(File.join('app', 'assets', 'javascripts', 'application.js'))).to be true
|
26
|
-
expect(File.exist?(File.join('app', 'assets', 'javascripts', 'application.js_owl_new'))).to be true
|
27
|
-
expect(File.exist?(File.join('app', 'assets', 'javascripts', 'application_common.js'))).to be true
|
28
|
-
expect(File.exist?(File.join('app', 'assets', 'javascripts', 'application_debug.js'))).to be true
|
29
|
-
expect(File.exist?(File.join('app', 'assets', 'javascripts', 'application_ssr.js'))).to be true
|
30
|
-
expect(File.exist?(File.join('app', 'assets', 'javascripts', 'application_web_worker.js'))).to be true
|
31
|
-
expect(File.exist?(File.join('app', 'opal', 'opal_loader.rb'))).to be true
|
32
|
-
expect(File.exist?(File.join('app', 'opal', 'opal_web_worker_loader.rb'))).to be true
|
33
|
-
expect(File.exist?(File.join('config', 'initializers', 'opal_webpack_loader.rb'))).to be true
|
34
|
-
expect(File.exist?(File.join('config', 'webpack', 'debug.js'))).to be true
|
35
|
-
expect(File.exist?(File.join('config', 'webpack', 'development.js'))).to be true
|
36
|
-
expect(File.exist?(File.join('config', 'webpack', 'production.js'))).to be true
|
37
|
-
expect(File.exist?('package.json')).to be true
|
38
|
-
expect(File.exist?('Procfile')).to be true
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'can install in a rails app without sprockets and webpacker gem specifying another opal files dir' do
|
42
|
-
`bundle exec rails new railing --skip-git --skip-bundle --skip-sprockets --skip-spring --skip-bootsnap`
|
43
|
-
expect(Dir.exist?('railing')).to be true
|
44
|
-
Dir.chdir('railing')
|
45
|
-
arg_val = %w[rails -o hyperhyper]
|
46
|
-
expect(Dir.exist?(File.join('railing', 'config', 'webpack'))).to be false
|
47
|
-
OpalWebpackLoader::Installer::CLI.start(arg_val)
|
48
|
-
expect(File.exist?(File.join('app', 'assets', 'javascripts', 'application.js'))).to be true
|
49
|
-
expect(File.exist?(File.join('app', 'assets', 'javascripts', 'application.js_owl_new'))).to be true
|
50
|
-
expect(File.exist?(File.join('app', 'assets', 'javascripts', 'application_common.js'))).to be true
|
51
|
-
expect(File.exist?(File.join('app', 'assets', 'javascripts', 'application_debug.js'))).to be true
|
52
|
-
expect(File.exist?(File.join('app', 'assets', 'javascripts', 'application_ssr.js'))).to be true
|
53
|
-
expect(File.exist?(File.join('app', 'assets', 'javascripts', 'application_web_worker.js'))).to be true
|
54
|
-
expect(File.exist?(File.join('app', 'hyperhyper', 'hyperhyper_loader.rb'))).to be true
|
55
|
-
expect(File.exist?(File.join('app', 'hyperhyper', 'hyperhyper_web_worker_loader.rb'))).to be true
|
56
|
-
expect(File.exist?(File.join('config', 'initializers', 'opal_webpack_loader.rb'))).to be true
|
57
|
-
expect(File.exist?(File.join('config', 'webpack', 'debug.js'))).to be true
|
58
|
-
expect(File.exist?(File.join('config', 'webpack', 'development.js'))).to be true
|
59
|
-
expect(File.exist?(File.join('config', 'webpack', 'production.js'))).to be true
|
60
|
-
expect(File.exist?('package.json')).to be true
|
61
|
-
expect(File.exist?('Procfile')).to be true
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
context 'structure: :flat' do
|
66
|
-
before do
|
67
|
-
Dir.chdir('spec')
|
68
|
-
Dir.chdir('test_apps')
|
69
|
-
FileUtils.rm_rf('flattering') if Dir.exist?('flattering')
|
70
|
-
end
|
71
|
-
|
72
|
-
after do
|
73
|
-
Dir.chdir('..') if Dir.pwd.end_with?('flattering')
|
74
|
-
FileUtils.rm_rf('flattering') if Dir.exist?('flattering')
|
75
|
-
Dir.chdir('..')
|
76
|
-
Dir.chdir('..')
|
77
|
-
end
|
78
|
-
|
79
|
-
it 'can install in a roda app' do
|
80
|
-
FileUtils.cp_r(File.join('..', 'fixtures', 'flattering'), File.join('.'))
|
81
|
-
expect(Dir.exist?('flattering')).to be true
|
82
|
-
Dir.chdir('flattering')
|
83
|
-
arg_val = %w[flat]
|
84
|
-
OpalWebpackLoader::Installer::CLI.start(arg_val)
|
85
|
-
expect(File.exist?(File.join('styles', 'application.css'))).to be true
|
86
|
-
expect(File.exist?(File.join('javascripts', 'application.js'))).to be true
|
87
|
-
expect(File.exist?(File.join('javascripts', 'application_common.js'))).to be true
|
88
|
-
expect(File.exist?(File.join('javascripts', 'application_debug.js'))).to be true
|
89
|
-
expect(File.exist?(File.join('javascripts', 'application_ssr.js'))).to be true
|
90
|
-
expect(File.exist?(File.join('opal', 'opal_loader.rb'))).to be true
|
91
|
-
expect(File.exist?(File.join('owl_init.rb'))).to be true
|
92
|
-
expect(File.exist?(File.join('app_loader.rb'))).to be true
|
93
|
-
expect(File.exist?(File.join('webpack', 'debug.js'))).to be true
|
94
|
-
expect(File.exist?(File.join('webpack', 'development.js'))).to be true
|
95
|
-
expect(File.exist?(File.join('webpack', 'production.js'))).to be true
|
96
|
-
expect(File.exist?('package.json')).to be true
|
97
|
-
expect(File.exist?('Procfile')).to be true
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
data/spec/owl_spec.rb
DELETED
@@ -1,105 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe 'owl' do
|
4
|
-
context 'in a rails app' do
|
5
|
-
before :all do
|
6
|
-
`npm pack`
|
7
|
-
end
|
8
|
-
|
9
|
-
before do
|
10
|
-
Dir.chdir('spec')
|
11
|
-
Dir.chdir('test_apps')
|
12
|
-
FileUtils.rm_rf('railing') if Dir.exist?('railing')
|
13
|
-
`yarn cache clean`
|
14
|
-
end
|
15
|
-
|
16
|
-
after do
|
17
|
-
Dir.chdir('..') if Dir.pwd.end_with?('railing')
|
18
|
-
FileUtils.rm_rf('railing') if Dir.exist?('railing')
|
19
|
-
Dir.chdir('..')
|
20
|
-
Dir.chdir('..')
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'can run the production build script' do
|
24
|
-
`bundle exec rails new railing --skip-git --skip-bundle --skip-sprockets --skip-javascript --skip-spring --skip-bootsnap`
|
25
|
-
expect(Dir.exist?('railing')).to be true
|
26
|
-
Dir.chdir('railing')
|
27
|
-
arg_val = %w[rails]
|
28
|
-
expect(Dir.exist?(File.join('railing', 'config', 'webpack'))).to be false
|
29
|
-
OpalWebpackLoader::Installer::CLI.start(arg_val)
|
30
|
-
gemfile = File.read('Gemfile')
|
31
|
-
gemfile << <<~GEMS
|
32
|
-
|
33
|
-
gem 'opal', github: 'janbiedermann/opal', branch: 'es6_import_export'
|
34
|
-
gem 'opal-webpack-loader', path: '#{File.realpath(File.join('..','..', '..', '..', 'opal-webpack-loader'))}'
|
35
|
-
|
36
|
-
GEMS
|
37
|
-
File.write('Gemfile', gemfile)
|
38
|
-
# add local owl npm package
|
39
|
-
package_json = Oj.load(File.read('package.json'), mode: :strict)
|
40
|
-
package_json["devDependencies"].delete("opal-webpack-loader")
|
41
|
-
File.write('package.json', Oj.dump(package_json, mode: :strict))
|
42
|
-
`yarn add file:../../../opal-webpack-loader-#{OpalWebpackLoader::VERSION}.tgz --dev`
|
43
|
-
`yarn install`
|
44
|
-
# bundler set some environment things, but we need a clean environment, so things don't get mixed up, use env
|
45
|
-
`env -i PATH="#{ENV['PATH']}" bundle install`
|
46
|
-
expect(File.exist?('Gemfile.lock')).to be true
|
47
|
-
`env -i PATH="#{ENV['PATH']}" yarn run production_build`
|
48
|
-
expect(File.exist?(File.join('public', 'assets', 'manifest.json'))).to be true
|
49
|
-
manifest = Oj.load(File.read(File.join('public', 'assets', 'manifest.json')), mode: :strict)
|
50
|
-
application_js = manifest['application.js']
|
51
|
-
expect(File.exist?(File.join('public', application_js))).to be true
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
context 'in a roda app' do
|
56
|
-
before :all do
|
57
|
-
`npm pack`
|
58
|
-
end
|
59
|
-
|
60
|
-
before do
|
61
|
-
Dir.chdir('spec')
|
62
|
-
Dir.chdir('test_apps')
|
63
|
-
FileUtils.rm_rf('flattering') if Dir.exist?('flattering')
|
64
|
-
`yarn cache clean`
|
65
|
-
end
|
66
|
-
|
67
|
-
after do
|
68
|
-
Dir.chdir('..') if Dir.pwd.end_with?('flattering')
|
69
|
-
FileUtils.rm_rf('flattering') if Dir.exist?('flattering')
|
70
|
-
Dir.chdir('..')
|
71
|
-
Dir.chdir('..')
|
72
|
-
end
|
73
|
-
|
74
|
-
it 'can run the production build script in a roda app' do
|
75
|
-
FileUtils.cp_r(File.join('..', 'fixtures', 'flattering'), File.join('.'))
|
76
|
-
expect(Dir.exist?('flattering')).to be true
|
77
|
-
Dir.chdir('flattering')
|
78
|
-
arg_val = %w[flat]
|
79
|
-
OpalWebpackLoader::Installer::CLI.start(arg_val)
|
80
|
-
|
81
|
-
gemfile = File.read('Gemfile')
|
82
|
-
gemfile << <<~GEMS
|
83
|
-
|
84
|
-
gem 'opal', github: 'janbiedermann/opal', branch: 'es6_import_export'
|
85
|
-
gem 'opal-webpack-loader', path: '#{File.realpath(File.join('..','..', '..', '..', 'opal-webpack-loader'))}'
|
86
|
-
|
87
|
-
GEMS
|
88
|
-
File.write('Gemfile', gemfile)
|
89
|
-
# add local owl npm package
|
90
|
-
package_json = Oj.load(File.read('package.json'), mode: :strict)
|
91
|
-
package_json["devDependencies"].delete("opal-webpack-loader")
|
92
|
-
File.write('package.json', Oj.dump(package_json, mode: :strict))
|
93
|
-
`yarn add file:../../../opal-webpack-loader-#{OpalWebpackLoader::VERSION}.tgz --dev`
|
94
|
-
`yarn install`
|
95
|
-
# bundler set some environment things, but we need a clean environment, so things don't get mixed up, use env
|
96
|
-
`env -i PATH="#{ENV['PATH']}" bundle install`
|
97
|
-
expect(File.exist?('Gemfile.lock')).to be true
|
98
|
-
`env -i PATH="#{ENV['PATH']}" yarn run production_build`
|
99
|
-
expect(File.exist?(File.join('public', 'assets', 'manifest.json'))).to be true
|
100
|
-
manifest = Oj.load(File.read(File.join('public', 'assets', 'manifest.json')), mode: :strict)
|
101
|
-
application_js = manifest['application.js']
|
102
|
-
expect(File.exist?(File.join('public', application_js))).to be true
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
require 'oj'
|
3
|
-
require 'thor'
|
4
|
-
require_relative '../lib/opal-webpack-loader/version'
|
5
|
-
require_relative '../lib/opal-webpack-loader/installer_cli'
|
6
|
-
|
7
|
-
RSpec.configure do |config|
|
8
|
-
config.expect_with :rspec do |expectations|
|
9
|
-
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
10
|
-
end
|
11
|
-
|
12
|
-
config.mock_with :rspec do |mocks|
|
13
|
-
mocks.verify_partial_doubles = true
|
14
|
-
end
|
15
|
-
|
16
|
-
config.shared_context_metadata_behavior = :apply_to_host_groups
|
17
|
-
end
|