opal-webpack-loader 0.8.8 → 0.9.0
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/bin/opal-webpack-compile-server +22 -13
- data/lib/opal-webpack-loader/compile_server.rb +5 -8
- data/lib/opal-webpack-loader/installer_cli.rb +1 -1
- data/lib/opal-webpack-loader/load_path_manager.rb +6 -5
- data/lib/opal-webpack-loader/templates/debug.js.erb +3 -0
- data/lib/opal-webpack-loader/templates/development.js.erb +3 -0
- data/lib/opal-webpack-loader/templates/package.json.erb +1 -0
- data/lib/opal-webpack-loader/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b9be7c0874e8efdf2c1c15c2a38bf1cc107136626239924aaf0d2407983c4f6
|
4
|
+
data.tar.gz: e3c584bc62ca84f981d1800664c510d332c92a7d4f018c91d1e0a7ccf853e98f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ef420caee7d006a798b70b5bbfc51d46c1d3520d15be5afe7b8f3af4cf627c7c7450490c7531c63b25818e358456afef1572983cbe3b9d3c4fb781f22ba977f
|
7
|
+
data.tar.gz: 4907ac5ebacb26340fcdcc0016801b762030398d36b4c3884d89df95ab5d38a174257b1e957eaa3c467122692d3b75ac9892bc210d912c5de3f3535eea5e96a0
|
@@ -10,16 +10,9 @@ require 'opal-webpack-loader/load_path_manager'
|
|
10
10
|
require 'opal-webpack-loader/compile_worker'
|
11
11
|
require 'opal-webpack-loader/compile_server'
|
12
12
|
|
13
|
-
at_exit do
|
14
|
-
if OpalWebpackLoader::CompileServer.unlink_socket?
|
15
|
-
if File.exist?(OpalWebpackLoader::CompileServer::OWCS_SOCKET_PATH)
|
16
|
-
File.unlink(OpalWebpackLoader::CompileServer::OWCS_SOCKET_PATH)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
13
|
modules_to_require = []
|
22
14
|
compiler_options = {}
|
15
|
+
compile_server_options = {}
|
23
16
|
|
24
17
|
OptionParser.new do |opts|
|
25
18
|
opts.on('-r', '--require MODULE', 'Require the module before starting the compile server.') do |m|
|
@@ -43,17 +36,33 @@ OptionParser.new do |opts|
|
|
43
36
|
opts.on('-f', '--false FLAG', 'Set compiler flag to false.' ) do |f|
|
44
37
|
compiler_options[f.to_sym] = false
|
45
38
|
end
|
39
|
+
|
40
|
+
opts.on('-l', '--load-paths-cache PATH', 'Path to load path cache json') do |l|
|
41
|
+
compile_server_options[:load_paths_cache] = l
|
42
|
+
end
|
43
|
+
|
44
|
+
opts.on('-s', '--socket-path PATH', 'Path of the socket the compile server should create.') do |s|
|
45
|
+
compile_server_options[:socket_path] = s
|
46
|
+
end
|
46
47
|
end.parse!
|
47
48
|
|
48
49
|
modules_to_require.each do |mod|
|
49
50
|
require mod
|
50
51
|
end
|
51
52
|
|
53
|
+
at_exit do
|
54
|
+
if OpalWebpackLoader::CompileServer.unlink_socket?
|
55
|
+
if File.exist?(compile_server_options[:socket_path])
|
56
|
+
File.unlink(compile_server_options[:socket_path])
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
52
61
|
if ARGV[0] == 'stop' || ARGV[0] == 'kill'
|
53
|
-
OpalWebpackLoader::CompileServer.stop
|
62
|
+
OpalWebpackLoader::CompileServer.stop(compile_server_options[:socket_path])
|
54
63
|
else
|
55
64
|
if ARGV[0] == 'start'
|
56
|
-
OpalWebpackLoader::CompileServer.stop(false)
|
65
|
+
OpalWebpackLoader::CompileServer.stop(compile_server_options[:socket_path],false)
|
57
66
|
number_of_workers = ARGV[1].to_i
|
58
67
|
number_of_workers == 4 if number_of_workers == 0
|
59
68
|
number_of_workers == 16 if number_of_workers > 16
|
@@ -69,18 +78,18 @@ else
|
|
69
78
|
exit(1)
|
70
79
|
end
|
71
80
|
|
72
|
-
load_paths = OpalWebpackLoader::LoadPathManager.read_load_paths_cache
|
81
|
+
load_paths = OpalWebpackLoader::LoadPathManager.read_load_paths_cache(compile_server_options[:load_paths_cache])
|
73
82
|
if load_paths
|
74
83
|
Opal.append_paths(*load_paths)
|
75
84
|
end
|
76
85
|
|
77
|
-
pid = fork { OpalWebpackLoader::CompileServer.new.start(number_of_workers, compiler_options) }
|
86
|
+
pid = fork { OpalWebpackLoader::CompileServer.new.start(number_of_workers, compiler_options, compile_server_options[:socket_path]) }
|
78
87
|
|
79
88
|
have_socket = false
|
80
89
|
start_time = Time.now
|
81
90
|
begin
|
82
91
|
until have_socket
|
83
|
-
if File.exist?(
|
92
|
+
if File.exist?(compile_server_options[:socket_path])
|
84
93
|
have_socket = true
|
85
94
|
else
|
86
95
|
if Time.now - start_time > 60
|
@@ -3,9 +3,6 @@ require 'tempfile'
|
|
3
3
|
|
4
4
|
module OpalWebpackLoader
|
5
5
|
class CompileServer
|
6
|
-
OWL_CACHE_DIR = File.join('.','.owl_cache/')
|
7
|
-
OWL_LP_CACHE = File.join(OWL_CACHE_DIR, 'load_paths.json')
|
8
|
-
OWCS_SOCKET_PATH = File.join(OWL_CACHE_DIR, 'owcs_socket')
|
9
6
|
SIGNALS = %w[QUIT INT TERM]
|
10
7
|
TIMEOUT = 15
|
11
8
|
|
@@ -21,11 +18,11 @@ module OpalWebpackLoader
|
|
21
18
|
@unlink = false
|
22
19
|
end
|
23
20
|
|
24
|
-
def self.stop(do_exit = true)
|
25
|
-
if File.exist?(
|
21
|
+
def self.stop(socket_path, do_exit = true)
|
22
|
+
if File.exist?(socket_path)
|
26
23
|
dont_unlink_socket_on_exit
|
27
24
|
begin
|
28
|
-
s = UNIXSocket.new(
|
25
|
+
s = UNIXSocket.new(socket_path)
|
29
26
|
s.send("command:stop\x04", 0)
|
30
27
|
s.close
|
31
28
|
rescue
|
@@ -42,12 +39,12 @@ module OpalWebpackLoader
|
|
42
39
|
@signal_queue = []
|
43
40
|
end
|
44
41
|
|
45
|
-
def start(number_of_workers = 4, compiler_options)
|
42
|
+
def start(number_of_workers = 4, compiler_options, socket_path)
|
46
43
|
$PROGRAM_NAME = 'owl compile server'
|
47
44
|
@number_of_workers = number_of_workers
|
48
45
|
@server_pid = Process.pid
|
49
46
|
$stderr.sync = $stdout.sync = true
|
50
|
-
@socket = UNIXServer.new(
|
47
|
+
@socket = UNIXServer.new(socket_path)
|
51
48
|
spawn_workers(compiler_options)
|
52
49
|
SIGNALS.each { |sig| trap_deferred(sig) }
|
53
50
|
trap('CHLD') { @write_pipe.write_nonblock('.') }
|
@@ -298,7 +298,7 @@ module OpalWebpackLoader
|
|
298
298
|
end
|
299
299
|
|
300
300
|
def production_script
|
301
|
-
"webpack --config=#{File.join(@webpack_config_directory, 'production.js')}"
|
301
|
+
"parallel-webpack --config=#{File.join(@webpack_config_directory, 'production.js')}"
|
302
302
|
end
|
303
303
|
|
304
304
|
def install_webpack_config
|
@@ -25,12 +25,14 @@ module OpalWebpackLoader
|
|
25
25
|
path_entries
|
26
26
|
end
|
27
27
|
|
28
|
-
def self.read_load_paths_cache
|
29
|
-
load_paths_cache = Oj.load(File.read(
|
28
|
+
def self.read_load_paths_cache(json_path)
|
29
|
+
load_paths_cache = Oj.load(File.read(json_path), mode: :strict)
|
30
30
|
load_paths_cache['opal_load_paths']
|
31
31
|
end
|
32
32
|
|
33
|
-
def self.create_load_paths_cache(
|
33
|
+
def self.create_load_paths_cache(args)
|
34
|
+
cache_path = args[0]
|
35
|
+
filter = args[1..-1]
|
34
36
|
load_paths = if File.exist?(File.join('bin', 'rails'))
|
35
37
|
%x{
|
36
38
|
bundle exec rails runner "puts (Rails.configuration.respond_to?(:assets) ? (Rails.configuration.assets.paths + Opal.paths).uniq : Opal.paths)"
|
@@ -54,8 +56,7 @@ module OpalWebpackLoader
|
|
54
56
|
load_path_entries.push(*more_path_entries) if more_path_entries.size > 0
|
55
57
|
end
|
56
58
|
cache_obj = { 'opal_load_paths' => load_path_lines, 'opal_load_path_entries' => load_path_entries }
|
57
|
-
|
58
|
-
File.write(OpalWebpackLoader::CompileServer::OWL_LP_CACHE, Oj.dump(cache_obj, mode: :strict, indent: 2))
|
59
|
+
File.write(cache_path, Oj.dump(cache_obj, mode: :strict, indent: 2))
|
59
60
|
load_path_lines
|
60
61
|
else
|
61
62
|
raise 'Error getting load paths!'
|
@@ -9,6 +9,9 @@ const common_config = {
|
|
9
9
|
context: path.resolve(__dirname, '<%= opal_directory %>'),
|
10
10
|
mode: "development",
|
11
11
|
optimization: {
|
12
|
+
removeAvailableModules: false,
|
13
|
+
removeEmptyChunks: false,
|
14
|
+
splitChunks: false,
|
12
15
|
minimize: false // dont minimize for debugging
|
13
16
|
},
|
14
17
|
performance: {
|
@@ -9,6 +9,9 @@ const common_config = {
|
|
9
9
|
context: path.resolve(__dirname, '<%= opal_directory %>'),
|
10
10
|
mode: "development",
|
11
11
|
optimization: {
|
12
|
+
removeAvailableModules: false,
|
13
|
+
removeEmptyChunks: false,
|
14
|
+
splitChunks: false,
|
12
15
|
minimize: false // dont minimize in development, to speed up hot reloads
|
13
16
|
},
|
14
17
|
performance: {
|
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.9.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-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opal
|