opal-webpack-loader 0.7.4 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/opal-webpack-compile-server +17 -27
- data/bin/owl-gen-loadpath-cache +6 -0
- data/lib/opal-webpack-loader/compile_worker.rb +2 -5
- data/lib/opal-webpack-loader/installer_cli.rb +86 -5
- data/lib/opal-webpack-loader/load_path_manager.rb +6 -1
- data/lib/opal-webpack-loader/templates/debug.js.erb +6 -11
- data/lib/opal-webpack-loader/templates/development.js.erb +6 -11
- data/lib/opal-webpack-loader/templates/package.json.erb +2 -0
- data/lib/opal-webpack-loader/templates/production.js.erb +13 -13
- data/lib/opal-webpack-loader/templates/webpacker.js +30 -0
- data/lib/opal-webpack-loader/version.rb +1 -1
- data/readme.md +12 -17
- metadata +51 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c724250c05cffa31dfa68ddf06cf501e5993a17b5553dd40061c3e921edc74d2
|
4
|
+
data.tar.gz: cbbabc576daf3622e6e7d118d07dfd0ee59fd56dd803b5cfbc501b7493146c9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c3f756fa3e66924c07ee831369708985bb73a54816b1fa57268fc197e4088687f8390d6d2f0812c2f460d3e1c964362242b13ef27320dbdec8720aa88b32f90
|
7
|
+
data.tar.gz: dbc2978da4134506446d96aca264930bc387644e0aee657f8d3ace42539dd90830f7f6c9980929a9761db1ba12a4e28dd0e680f2a70af19fe09c791448d7ab7d
|
@@ -1,6 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'open3'
|
3
3
|
require 'oj'
|
4
|
+
require 'c_lexer'
|
4
5
|
require 'opal/paths'
|
5
6
|
require 'opal/source_map'
|
6
7
|
require 'opal/compiler'
|
@@ -16,26 +17,27 @@ at_exit do
|
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
19
|
-
puts "args: #{ARGV}"
|
20
|
-
|
21
20
|
if ARGV[0] == 'stop' || ARGV[0] == 'kill'
|
22
21
|
OpalWebpackLoader::CompileServer.stop
|
23
22
|
else
|
24
23
|
if ARGV[0] == 'start'
|
25
24
|
OpalWebpackLoader::CompileServer.stop(false)
|
26
25
|
number_of_workers = ARGV[1].to_i
|
27
|
-
if number_of_workers == 0
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
26
|
+
number_of_workers == 4 if number_of_workers == 0
|
27
|
+
number_of_workers == 16 if number_of_workers > 16
|
28
|
+
if ARGV[2]
|
29
|
+
raise <<~MSG
|
30
|
+
Please change the scripts in package.json to only start webpack:\n
|
31
|
+
eg. from: "debug": "bundle exec opal-webpack-compile-server start 8 webpack --config=config/webpack/test.js"
|
32
|
+
to just: "debug": "webpack --config=config/webpack/test.js"
|
33
|
+
MSG
|
32
34
|
end
|
33
35
|
else
|
34
|
-
raise 'arguments must be either "stop" or "start number_of_workers
|
36
|
+
raise 'arguments must be either "stop" or "start number_of_workers"'
|
35
37
|
exit(1)
|
36
38
|
end
|
37
39
|
|
38
|
-
load_paths = OpalWebpackLoader::LoadPathManager.
|
40
|
+
load_paths = OpalWebpackLoader::LoadPathManager.read_load_paths_cache
|
39
41
|
if load_paths
|
40
42
|
Opal.append_paths(*load_paths)
|
41
43
|
end
|
@@ -50,7 +52,7 @@ else
|
|
50
52
|
have_socket = true
|
51
53
|
else
|
52
54
|
if Time.now - start_time > 60
|
53
|
-
puts "opal-webpack-compile-server didnt start in time. Exiting"
|
55
|
+
STDERR.puts "opal-webpack-compile-server didnt start in time. Exiting"
|
54
56
|
OpalWebpackLoader::CompileServer.stop(false)
|
55
57
|
Process.kill("TERM", pid)
|
56
58
|
exit 1
|
@@ -59,29 +61,17 @@ else
|
|
59
61
|
end
|
60
62
|
rescue Exception => e
|
61
63
|
OpalWebpackLoader::CompileServer.stop(false)
|
62
|
-
puts "opal-webpack-compile-server couldn't start:"
|
63
|
-
puts e.backtrace.join("\n")
|
64
|
-
puts e.message
|
64
|
+
STDERR.puts "opal-webpack-compile-server couldn't start:"
|
65
|
+
STDERR.puts e.backtrace.join("\n")
|
66
|
+
STDERR.puts e.message
|
65
67
|
Process.kill("TERM", pid)
|
66
68
|
exit 1
|
67
69
|
end
|
68
70
|
|
69
71
|
begin
|
70
|
-
|
71
|
-
Open3.popen3(*runargs) do |stdin, stdout, stderr, thread|
|
72
|
-
# read each stream from a new thread
|
73
|
-
{ :out => stdout, :err => stderr }.each do |key, stream|
|
74
|
-
Thread.new do
|
75
|
-
until (raw_line = stream.gets).nil? do
|
76
|
-
puts raw_line
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
thread.join # don't exit until the external process is done
|
82
|
-
end
|
72
|
+
Process.waitpid(pid)
|
83
73
|
rescue Interrupt
|
84
|
-
puts "opal-webpack-compile-server got interrupted. Exiting with drama."
|
74
|
+
STDERR.puts "opal-webpack-compile-server got interrupted. Exiting with drama."
|
85
75
|
Process.kill("TERM", pid)
|
86
76
|
exit 0
|
87
77
|
end
|
@@ -73,16 +73,13 @@ module OpalWebpackLoader
|
|
73
73
|
|
74
74
|
begin
|
75
75
|
c = Opal::Compiler.new(source, file: filename, es6_modules: true)
|
76
|
-
c.compile
|
77
|
-
result = { 'javascript' => c.result }
|
76
|
+
result = { 'javascript' => c.compile }
|
78
77
|
if compile_source_map
|
79
78
|
result['source_map'] = c.source_map.as_json
|
80
|
-
result['source_map']['sourcesContent'] = [source]
|
81
79
|
result['source_map']['file'] = filename
|
82
|
-
result['source_map']['names'] = result['source_map']['names'].map(&:to_s)
|
83
80
|
end
|
84
81
|
result['required_trees'] = c.required_trees
|
85
|
-
Oj.dump(result,
|
82
|
+
Oj.dump(result, mode: :strict)
|
86
83
|
rescue Exception => e
|
87
84
|
Oj.dump({ 'error' => { 'name' => e.class, 'message' => e.message, 'backtrace' => e.backtrace.join("\n") } }, {})
|
88
85
|
end
|
@@ -87,7 +87,7 @@ module OpalWebpackLoader
|
|
87
87
|
print_message
|
88
88
|
end
|
89
89
|
|
90
|
-
desc "rails", "Install owl configuration into a existing rails project, execute from the projects root directory."
|
90
|
+
desc "rails", "Install owl configuration into a existing rails project without webpacker, execute from the projects root directory."
|
91
91
|
# <<~TEXT
|
92
92
|
# Showing directories and files relevant to owl:
|
93
93
|
# project_root
|
@@ -130,6 +130,52 @@ module OpalWebpackLoader
|
|
130
130
|
print_message
|
131
131
|
end
|
132
132
|
|
133
|
+
desc "webpacker", "Install owl configuration into a existing rails project with webpacker, execute from the projects root directory."
|
134
|
+
# <<~TEXT
|
135
|
+
# Showing directories and files relevant to owl:
|
136
|
+
# project_root
|
137
|
+
# +- app
|
138
|
+
# +- assets
|
139
|
+
# +- javascripts # javascript entries directory
|
140
|
+
# +- styles # directory for stylesheets
|
141
|
+
# +- opal # directory for opal application files, can be changed with -o
|
142
|
+
# +- config
|
143
|
+
# +- webpack # directory for webpack configuration files
|
144
|
+
# +- initializers
|
145
|
+
# +- owl.rb # initializer for owl
|
146
|
+
# +- node_modules # directory for node modules
|
147
|
+
# +- package.json # package config for npm/yarn and their scripts
|
148
|
+
# +- public
|
149
|
+
# +- assets # directory for compiled output files
|
150
|
+
# +- Procfile # config file for foreman
|
151
|
+
#
|
152
|
+
# TEXT
|
153
|
+
option :opal_name, required: false, type: :string, default: 'opal', aliases: '-o', desc: <<~TEXT
|
154
|
+
Set directory name for Opal source files.
|
155
|
+
Example: owl-installer rails -o isomorfeus # will use project_root/app/isomorfeus for opal files
|
156
|
+
TEXT
|
157
|
+
|
158
|
+
def webpacker
|
159
|
+
@application_css = '../stylesheets/application.css'
|
160
|
+
@asset_output_directory = File.join('public', 'assets')
|
161
|
+
@js_entrypoints_directory = File.join('app', 'assets', 'javascripts')
|
162
|
+
@conf_rel_prefix = File.join('..', '..')
|
163
|
+
@js_rel_prefix = File.join('..', '..', '..')
|
164
|
+
@opal_directory = File.join('app', options[:opal_name])
|
165
|
+
@styles_directory = File.join('app', 'assets', 'stylesheets')
|
166
|
+
@webpack_config_directory = File.join('config', 'webpack')
|
167
|
+
create_directory('app')
|
168
|
+
create_common_directories
|
169
|
+
install_webpacker_config
|
170
|
+
install_webpacker_package_json
|
171
|
+
install_webpacker_js_entry
|
172
|
+
install_opal_entries
|
173
|
+
create_file_from_template('initializer.rb.erb', File.join('config', 'initializers', 'opal_webpack_loader.rb'),
|
174
|
+
{ opal_directory: @opal_directory })
|
175
|
+
add_gem
|
176
|
+
print_message
|
177
|
+
end
|
178
|
+
|
133
179
|
private
|
134
180
|
|
135
181
|
def create_directory(directory)
|
@@ -182,7 +228,7 @@ module OpalWebpackLoader
|
|
182
228
|
package_json["devDependencies"] = {} unless package_json.has_key?("devDependencies")
|
183
229
|
package_json["devDependencies"].merge!(gem_package_json["devDependencies"])
|
184
230
|
package_json["dependencies"]["opal-webpack-loader"] = "^#{OpalWebpackLoader::VERSION}"
|
185
|
-
File.write('package.json', Oj.dump(package_json, mode: :strict))
|
231
|
+
File.write('package.json', Oj.dump(package_json, mode: :strict, indent: 2))
|
186
232
|
puts "Updated package.json, updated scripts and owl dependencies"
|
187
233
|
else
|
188
234
|
erb_hash = {
|
@@ -217,15 +263,15 @@ module OpalWebpackLoader
|
|
217
263
|
end
|
218
264
|
|
219
265
|
def debug_script
|
220
|
-
"
|
266
|
+
"webpack-dev-server --config #{File.join(@webpack_config_directory, 'debug.js')}"
|
221
267
|
end
|
222
268
|
|
223
269
|
def development_script
|
224
|
-
"
|
270
|
+
"webpack-dev-server --config #{File.join(@webpack_config_directory, 'development.js')}"
|
225
271
|
end
|
226
272
|
|
227
273
|
def production_script
|
228
|
-
"
|
274
|
+
"webpack --config=#{File.join(@webpack_config_directory, 'production.js')}"
|
229
275
|
end
|
230
276
|
|
231
277
|
def install_webpack_config
|
@@ -266,6 +312,41 @@ module OpalWebpackLoader
|
|
266
312
|
create_file_from_template('production.js.erb', File.join(@webpack_config_directory, 'production.js'), erb_hash)
|
267
313
|
end
|
268
314
|
|
315
|
+
def install_webpacker_config
|
316
|
+
environment_js = File.read(File.join('config', 'webpack', 'environment.js'), mode: 'r')
|
317
|
+
new_environment_js = ''
|
318
|
+
environment_js.lines.each do |line|
|
319
|
+
new_environment_js << line
|
320
|
+
if line.start_with?('const { environment }')
|
321
|
+
new_environment_js << "\n"
|
322
|
+
new_environment_js << File.read(File.join(templates_path, 'webpacker.js'), mode: 'r')
|
323
|
+
new_environment_js << "\n"
|
324
|
+
end
|
325
|
+
end
|
326
|
+
File.write(File.join('config', 'webpack', 'environment.js'), new_environment_js)
|
327
|
+
end
|
328
|
+
|
329
|
+
def install_webpacker_js_entry
|
330
|
+
application_js = File.read(File.join('app', 'javascript', 'packs', 'application.js'), mode: 'r')
|
331
|
+
application_js << <<~JAVASCRIPT
|
332
|
+
|
333
|
+
// import and load opal ruby files
|
334
|
+
import init_app from '#{options[:opal_name]}_loader.rb';
|
335
|
+
init_app();
|
336
|
+
Opal.load('#{options[:opal_name]}_loader');
|
337
|
+
|
338
|
+
JAVASCRIPT
|
339
|
+
File.write(File.join('app', 'javascript', 'packs', 'application.js'), application_js)
|
340
|
+
end
|
341
|
+
|
342
|
+
def install_webpacker_package_json
|
343
|
+
package_json_file = File.read('package.json')
|
344
|
+
package_json = Oj.load(package_json_file, mode: :strict)
|
345
|
+
package_json["dependencies"]["opal-webpack-loader"] = "^#{OpalWebpackLoader::VERSION}"
|
346
|
+
File.write('package.json', Oj.dump(package_json, mode: :strict, indent: 2))
|
347
|
+
puts "Updated package.json for opal-webpack-loader"
|
348
|
+
end
|
349
|
+
|
269
350
|
def templates_path
|
270
351
|
File.realpath(File.join(File.dirname(File.realpath(__FILE__)), 'templates'))
|
271
352
|
end
|
@@ -19,6 +19,11 @@ module OpalWebpackLoader
|
|
19
19
|
path_entries
|
20
20
|
end
|
21
21
|
|
22
|
+
def self.read_load_paths_cache
|
23
|
+
load_paths_cache = Oj.load(File.read(OpalWebpackLoader::CompileServer::OWL_LP_CACHE), mode: :strict)
|
24
|
+
load_paths_cache['opal_load_paths']
|
25
|
+
end
|
26
|
+
|
22
27
|
def self.create_load_paths_cache
|
23
28
|
load_paths = if File.exist?(File.join('bin', 'rails'))
|
24
29
|
%x{
|
@@ -44,7 +49,7 @@ module OpalWebpackLoader
|
|
44
49
|
end
|
45
50
|
cache_obj = { 'opal_load_paths' => load_path_lines, 'opal_load_path_entries' => load_path_entries }
|
46
51
|
Dir.mkdir(OpalWebpackLoader::CompileServer::OWL_CACHE_DIR) unless Dir.exist?(OpalWebpackLoader::CompileServer::OWL_CACHE_DIR)
|
47
|
-
File.write(OpalWebpackLoader::CompileServer::OWL_LP_CACHE, Oj.dump(cache_obj,
|
52
|
+
File.write(OpalWebpackLoader::CompileServer::OWL_LP_CACHE, Oj.dump(cache_obj, mode: :strict))
|
48
53
|
load_path_lines
|
49
54
|
else
|
50
55
|
raise 'Error getting load paths!'
|
@@ -52,6 +52,7 @@ const common_config = {
|
|
52
52
|
// test means "test for for file endings"
|
53
53
|
test: /.scss$/,
|
54
54
|
use: [
|
55
|
+
{ loader: "cache-loader" },
|
55
56
|
{
|
56
57
|
loader: "style-loader",
|
57
58
|
options: {
|
@@ -77,6 +78,7 @@ const common_config = {
|
|
77
78
|
// loader for .css files
|
78
79
|
test: /.css$/,
|
79
80
|
use: [
|
81
|
+
{ loader: "cache-loader" },
|
80
82
|
{
|
81
83
|
loader: "style-loader",
|
82
84
|
options: {
|
@@ -92,21 +94,14 @@ const common_config = {
|
|
92
94
|
]
|
93
95
|
},
|
94
96
|
{
|
95
|
-
test: /.(png|svg|jpg|gif)$/,
|
96
|
-
use: [
|
97
|
-
'file-loader'
|
98
|
-
]
|
99
|
-
},
|
100
|
-
{
|
101
|
-
test: /.(woff|woff2|eot|ttf|otf)$/,
|
102
|
-
use: [
|
103
|
-
'file-loader'
|
104
|
-
]
|
97
|
+
test: /.(png|svg|jpg|gif|woff|woff2|eot|ttf|otf)$/,
|
98
|
+
use: [ "cache-loader", "file-loader" ]
|
105
99
|
},
|
106
100
|
{
|
107
101
|
// opal-webpack-loader will compile and include ruby files in the pack
|
108
102
|
test: /.(rb|js.rb)$/,
|
109
103
|
use: [
|
104
|
+
{ loader: "cache-loader" },
|
110
105
|
{
|
111
106
|
loader: 'opal-webpack-loader',
|
112
107
|
options: {
|
@@ -144,7 +139,7 @@ const common_config = {
|
|
144
139
|
contentBase: path.resolve(__dirname, 'public'),
|
145
140
|
// watchContentBase: true,
|
146
141
|
// writeToDisk: true, // TODO this may need to be activated for ssr to work in development
|
147
|
-
useLocalIp:
|
142
|
+
useLocalIp: false
|
148
143
|
}
|
149
144
|
};
|
150
145
|
|
@@ -43,6 +43,7 @@ const common_config = {
|
|
43
43
|
// test means "test for for file endings"
|
44
44
|
test: /.scss$/,
|
45
45
|
use: [
|
46
|
+
{ loader: "cache-loader" },
|
46
47
|
{
|
47
48
|
loader: "style-loader",
|
48
49
|
options: {
|
@@ -64,6 +65,7 @@ const common_config = {
|
|
64
65
|
// loader for .css files
|
65
66
|
test: /.css$/,
|
66
67
|
use: [
|
68
|
+
{ loader: "cache-loader" },
|
67
69
|
{
|
68
70
|
loader: "style-loader",
|
69
71
|
options: {
|
@@ -76,21 +78,14 @@ const common_config = {
|
|
76
78
|
]
|
77
79
|
},
|
78
80
|
{
|
79
|
-
test: /.(png|svg|jpg|gif)$/,
|
80
|
-
use: [
|
81
|
-
'file-loader'
|
82
|
-
]
|
83
|
-
},
|
84
|
-
{
|
85
|
-
test: /.(woff|woff2|eot|ttf|otf)$/,
|
86
|
-
use: [
|
87
|
-
'file-loader'
|
88
|
-
]
|
81
|
+
test: /.(png|svg|jpg|gif|woff|woff2|eot|ttf|otf)$/,
|
82
|
+
use: [ "cache-loader", "file-loader" ]
|
89
83
|
},
|
90
84
|
{
|
91
85
|
// opal-webpack-loader will compile and include ruby files in the pack
|
92
86
|
test: /.(rb|js.rb)$/,
|
93
87
|
use: [
|
88
|
+
{ loader: "cache-loader" },
|
94
89
|
{
|
95
90
|
loader: 'opal-webpack-loader',
|
96
91
|
options: {
|
@@ -128,7 +123,7 @@ const common_config = {
|
|
128
123
|
contentBase: path.resolve(__dirname, 'public'),
|
129
124
|
// watchContentBase: true,
|
130
125
|
// writeToDisk: true,
|
131
|
-
useLocalIp:
|
126
|
+
useLocalIp: false
|
132
127
|
}
|
133
128
|
};
|
134
129
|
|
@@ -9,6 +9,7 @@
|
|
9
9
|
"production_build": "<%= production_script %>"
|
10
10
|
},
|
11
11
|
"devDependencies": {
|
12
|
+
"cache-loader": "^3.0.0",
|
12
13
|
"chokidar": "^2.1.5",
|
13
14
|
"compression-webpack-plugin": "^2.0.0",
|
14
15
|
"css-loader": "^2.1.1",
|
@@ -17,6 +18,7 @@
|
|
17
18
|
"node-sass": "^4.12.0",
|
18
19
|
"sass-loader": "^7.1.0",
|
19
20
|
"style-loader": "^0.23.1",
|
21
|
+
"terser-webpack-plugin": "^1.2.3",
|
20
22
|
"webpack": "^4.30.0",
|
21
23
|
"webpack-cli": "^3.3.0",
|
22
24
|
"webpack-dev-server": "^3.3.1",
|
@@ -2,12 +2,18 @@ const path = require('path');
|
|
2
2
|
const OwlResolver = require('opal-webpack-loader/resolver');
|
3
3
|
const CompressionPlugin = require("compression-webpack-plugin"); // for gzipping the packs
|
4
4
|
const ManifestPlugin = require('webpack-manifest-plugin'); // for generating the manifest
|
5
|
+
const TerserPlugin = require('terser-webpack-plugin');
|
5
6
|
|
6
7
|
const common_config = {
|
7
8
|
context: path.resolve(__dirname, '<%= opal_directory %>'),
|
8
9
|
mode: "production",
|
9
10
|
optimization: {
|
10
|
-
minimize: true // minimize
|
11
|
+
minimize: true, // minimize
|
12
|
+
minimizer: [
|
13
|
+
new TerserPlugin({
|
14
|
+
cache: true
|
15
|
+
})
|
16
|
+
]
|
11
17
|
},
|
12
18
|
performance: {
|
13
19
|
maxAssetSize: 20000000,
|
@@ -24,7 +30,7 @@ const common_config = {
|
|
24
30
|
]
|
25
31
|
},
|
26
32
|
plugins: [
|
27
|
-
new CompressionPlugin({ test: /^((?!application_ssr).)
|
33
|
+
new CompressionPlugin({ test: /^((?!application_ssr).)*$/, cache: true }), // gzip compress, exclude application_ssr.js
|
28
34
|
new ManifestPlugin({ fileName: 'manifest.json' }) // generate manifest
|
29
35
|
],
|
30
36
|
module: {
|
@@ -32,6 +38,7 @@ const common_config = {
|
|
32
38
|
{
|
33
39
|
test: /.scss$/,
|
34
40
|
use: [
|
41
|
+
{ loader: "cache-loader" },
|
35
42
|
{
|
36
43
|
loader: "style-loader",
|
37
44
|
options: {
|
@@ -57,24 +64,17 @@ const common_config = {
|
|
57
64
|
{
|
58
65
|
// loader for .css files
|
59
66
|
test: /.css$/,
|
60
|
-
use: [ "style-loader", "css-loader" ]
|
67
|
+
use: [ "cache-loader", "style-loader", "css-loader" ]
|
61
68
|
},
|
62
69
|
{
|
63
|
-
test: /.(png|svg|jpg|gif)$/,
|
64
|
-
use: [
|
65
|
-
'file-loader'
|
66
|
-
]
|
67
|
-
},
|
68
|
-
{
|
69
|
-
test: /.(woff|woff2|eot|ttf|otf)$/,
|
70
|
-
use: [
|
71
|
-
'file-loader'
|
72
|
-
]
|
70
|
+
test: /.(png|svg|jpg|gif|woff|woff2|eot|ttf|otf)$/,
|
71
|
+
use: [ "cache-loader", "file-loader" ]
|
73
72
|
},
|
74
73
|
{
|
75
74
|
// opal-webpack-loader will compile and include ruby files in the pack
|
76
75
|
test: /.(rb|js.rb)$/,
|
77
76
|
use: [
|
77
|
+
{ loader: "cache-loader" },
|
78
78
|
{
|
79
79
|
loader: 'opal-webpack-loader',
|
80
80
|
options: {
|
@@ -0,0 +1,30 @@
|
|
1
|
+
// begin # added by the owl-install
|
2
|
+
const OwlResolver = require('opal-webpack-loader/resolver'); // to resolve ruby files
|
3
|
+
|
4
|
+
const owl_resolver = {
|
5
|
+
resolve: {
|
6
|
+
plugins: [
|
7
|
+
// this makes it possible for webpack to find ruby files
|
8
|
+
new OwlResolver('resolve', 'resolved')
|
9
|
+
]
|
10
|
+
}
|
11
|
+
};
|
12
|
+
environment.config.merge(owl_resolver);
|
13
|
+
|
14
|
+
const opal_loader = {
|
15
|
+
// opal-webpack-loader will compile and include ruby files in the pack
|
16
|
+
test: /.(rb|js.rb)$/,
|
17
|
+
use: [
|
18
|
+
{
|
19
|
+
loader: 'opal-webpack-loader',
|
20
|
+
options: {
|
21
|
+
sourceMap: false,
|
22
|
+
hmr: false,
|
23
|
+
hmrHook: '' // see opal-webpack-loader docs
|
24
|
+
}
|
25
|
+
}
|
26
|
+
]
|
27
|
+
};
|
28
|
+
|
29
|
+
environment.loaders.append('opal', opal_loader);
|
30
|
+
// end # added by owl-install
|
data/readme.md
CHANGED
@@ -6,6 +6,9 @@ Includes a loader and resolver plugin for webpack.
|
|
6
6
|
### Community and Support
|
7
7
|
At the [Isomorfeus Framework Project](http://isomorfeus.com)
|
8
8
|
|
9
|
+
### Tested
|
10
|
+
[TravisCI](https://travis-ci.org): [![Build Status](https://travis-ci.org/isomorfeus/opal-webpack-loader.svg?branch=master)](https://travis-ci.org/isomorfeus/opal-webpack-loader)
|
11
|
+
|
9
12
|
### Features
|
10
13
|
- comes with a installer for rails and other frameworks
|
11
14
|
- webpack based build process
|
@@ -13,6 +16,7 @@ At the [Isomorfeus Framework Project](http://isomorfeus.com)
|
|
13
16
|
opal-webpack-loader-0.7.1 compiles all of opal, a bunch of gems and over 19000SLC on a
|
14
17
|
Intel® Core™ i7-7700HQ CPU @ 2.80GHz × 8, with 8 workers in around 1850ms
|
15
18
|
- opal modules are packaged as es6 modules
|
19
|
+
- support for rails with webpacker
|
16
20
|
- other webpack features become available, like:
|
17
21
|
- source maps
|
18
22
|
- multiple targets: web (for browsers), node (for server side rendering) and webworker (for Web Workers)
|
@@ -23,21 +27,17 @@ Intel® Core™ i7-7700HQ CPU @ 2.80GHz × 8, with 8 workers in around 1850ms
|
|
23
27
|
- everything else webpack can do, like loading stylesheets, etc.
|
24
28
|
|
25
29
|
### Requirements
|
26
|
-
- opal-webpack-loader consists of 2 parts, the npm package and the gem, both are required
|
30
|
+
- opal-webpack-loader consists of 2 parts, the npm package and the gem, both are required and must be the same version.
|
27
31
|
- webpack 4.30
|
28
32
|
- webpack-dev-server 3.3.0
|
29
33
|
- one of the ES6 modules branches of opal
|
30
|
-
- [PR#
|
31
|
-
|
32
|
-
`gem 'opal', github: 'janbiedermann/opal', branch: 'es6_import_export', ref: 'e3fdf16e8a657f7d9f9507207848a34953dced8d'`
|
33
|
-
|
34
|
-
- [PR#1970](https://github.com/opal/opal/pull/1969), implementing ES6 modules and changes for 'strict' mode,
|
35
|
-
based on Opal master 1.0.beta using javascript string primitives
|
34
|
+
- [PR#1970](https://github.com/opal/opal/pull/1969), (recommended) implementing ES6 modules and changes for 'strict' mode,
|
35
|
+
based on Opal master 1.0.0 using javascript string primitives
|
36
36
|
|
37
37
|
`gem 'opal', github: 'janbiedermann/opal', branch: 'es6_modules'`
|
38
38
|
|
39
|
-
- [PR#1973](https://github.com/opal/opal/pull/1973), implementing ES6 modules and changes for 'strict' mode,
|
40
|
-
based on Opal master 1.0.
|
39
|
+
- [PR#1973](https://github.com/opal/opal/pull/1973), (experimental) implementing ES6 modules and changes for 'strict' mode,
|
40
|
+
based on Opal master 1.0.0 using javascript string objects "mutable strings" by default for all strings
|
41
41
|
|
42
42
|
`gem 'opal', github: 'janbiedermann/opal', branch: 'es6_modules_string'`
|
43
43
|
|
@@ -55,7 +55,7 @@ gem install 'opal-webpack-loader'
|
|
55
55
|
|
56
56
|
Continue here:
|
57
57
|
- [Install for Rails like projects](https://github.com/isomorfeus/opal-webpack-loader/blob/master/docs/installation_rails.md)
|
58
|
-
- [Install for Cuba, Roda, Sinatra and
|
58
|
+
- [Install for Cuba, Roda, Sinatra and other projects with a flat structure](https://github.com/isomorfeus/opal-webpack-loader/blob/master/docs/installation_flat.md)
|
59
59
|
- [Manual Installation](https://github.com/isomorfeus/opal-webpack-loader/blob/master/docs/installation_manual.md)
|
60
60
|
|
61
61
|
### Example applications
|
@@ -115,13 +115,8 @@ frameworks like isomorfeus. Instead the section for configuring a view watcher i
|
|
115
115
|
config, but it is commented out. Please see those files and adjust to your liking.
|
116
116
|
|
117
117
|
#### Parallel compilation for speed
|
118
|
-
|
119
|
-
|
120
|
-
`"production_build": "bundle exec opal-webpack-compile-server start 4 webpack --config=config/webpack/production.js"`
|
121
|
-
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,
|
122
|
-
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.
|
123
|
-
Example for 8 cores:
|
124
|
-
`"production_build": "bundle exec opal-webpack-compile-server start 8 webpack --config=config/webpack/production.js"`
|
118
|
+
|
119
|
+
Since version 0.8.0 the number of CPUs is automatically determined and a appropriate number of of compile server workers is started automatically.
|
125
120
|
|
126
121
|
### Source Maps
|
127
122
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opal-webpack-loader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
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-05-
|
11
|
+
date: 2019-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opal
|
@@ -16,26 +16,40 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 1.0.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
|
-
version: 0.
|
26
|
+
version: 1.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: c_lexer
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: oj
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
|
-
- - "
|
45
|
+
- - ">="
|
32
46
|
- !ruby/object:Gem::Version
|
33
47
|
version: 3.7.0
|
34
48
|
type: :runtime
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
|
-
- - "
|
52
|
+
- - ">="
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: 3.7.0
|
41
55
|
- !ruby/object:Gem::Dependency
|
@@ -66,6 +80,20 @@ dependencies:
|
|
66
80
|
- - ">="
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: listen
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
69
97
|
- !ruby/object:Gem::Dependency
|
70
98
|
name: rake
|
71
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,6 +150,20 @@ dependencies:
|
|
122
150
|
- - "~>"
|
123
151
|
- !ruby/object:Gem::Version
|
124
152
|
version: 3.8.0
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: webpacker
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 4.0.0
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 4.0.0
|
125
167
|
description: "Bundle assets with webpack, resolve and compile opal ruby files\nand
|
126
168
|
import them in the bundle, without sprockets or the webpacker gem\n(but can be used
|
127
169
|
with both of them too). \nComes with a installer for rails and other frameworks.\n"
|
@@ -129,11 +171,13 @@ email: jan@kursator.de
|
|
129
171
|
executables:
|
130
172
|
- opal-webpack-compile-server
|
131
173
|
- owl-install
|
174
|
+
- owl-gen-loadpath-cache
|
132
175
|
extensions: []
|
133
176
|
extra_rdoc_files: []
|
134
177
|
files:
|
135
178
|
- LICENSE
|
136
179
|
- bin/opal-webpack-compile-server
|
180
|
+
- bin/owl-gen-loadpath-cache
|
137
181
|
- bin/owl-install
|
138
182
|
- lib/opal-webpack-loader.rb
|
139
183
|
- lib/opal-webpack-loader/compile_server.rb
|
@@ -157,6 +201,7 @@ files:
|
|
157
201
|
- lib/opal-webpack-loader/templates/opal_web_worker_loader.rb.erb
|
158
202
|
- lib/opal-webpack-loader/templates/package.json.erb
|
159
203
|
- lib/opal-webpack-loader/templates/production.js.erb
|
204
|
+
- lib/opal-webpack-loader/templates/webpacker.js
|
160
205
|
- lib/opal-webpack-loader/templates/webpacker_development.js_example
|
161
206
|
- lib/opal-webpack-loader/version.rb
|
162
207
|
- lib/opal-webpack-loader/view_helper.rb
|