opal-webpack-loader 0.8.2 → 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 254f61ad12a19a8d5712b94a2c8d00dd21c8d3840abed2481bf82f1fa86ff989
4
- data.tar.gz: 5577b24f292caa635a9d71d607c38bbaab4f324870419b92840eb2756458f31d
3
+ metadata.gz: a6476d6f3c8ab61e7883e7f6a7e6ec11c4a69be908dd3a88efd11482d78e7764
4
+ data.tar.gz: f741336673d35391dbcde48684d0165b0cf1312a30013d71605058a30e5724b2
5
5
  SHA512:
6
- metadata.gz: 2a8527341d06d9bc9b5860f82d7c7ca2115053fbf9bdc422150a7b619215fcaabd4fe0ce376713d904ba7269b94e3fedecc78d42be55f8dad9efd19aaf8371bd
7
- data.tar.gz: 886419b70f9677e301464d7993f91f75596c8cafdca8aab85192d56c64a4f9f164a4c99e2ef202a53764c4f67909283c5a073b3e7d4c10e26690c67bd9b7180d
6
+ metadata.gz: 7e7c5f101b6e053326dc5c4badef25e871104ab686219cf6abe312504d52f4388e195ad24016fc6b2323a204493517bb64b54946d7d1728de71c1b4073eb8b70
7
+ data.tar.gz: 460f918145a5a78bea6c20a6149dffe9d69b6c3986f35f68fea1cbae57e5b9251c4fbfc8d79c616e07e99bee1188d1799c079996eb615bac44d759805f9f58c0
@@ -19,15 +19,30 @@ at_exit do
19
19
  end
20
20
 
21
21
  modules_to_require = []
22
+ compiler_options = {}
22
23
 
23
24
  OptionParser.new do |opts|
24
- opts.on('-r', '--require MODULE', 'require the module before starting the compile server') do |m|
25
+ opts.on('-r', '--require MODULE', 'Require the module before starting the compile server.') do |m|
25
26
  modules_to_require << m
26
27
  end
27
28
 
28
29
  opts.on('-I', '--include DIR', 'Append a load path (may be used more than once)') do |i|
29
30
  $:.unshift(File.expand_path(i))
30
31
  end
32
+
33
+ opts.on('-d', '--dynamic-require-severity SEVERITY', 'Compiler option, one of: error, warning, ignore.') do |s|
34
+ if %w[error warning ignore].include?(s)
35
+ compiler_options[:dynamic_require_severity] = s.to_sym
36
+ end
37
+ end
38
+
39
+ opts.on('-t', '--true FLAG', 'Set compiler flag to true.' ) do |f|
40
+ compiler_options[f.to_sym] = true
41
+ end
42
+
43
+ opts.on('-f', '--false FLAG', 'Set compiler flag to false.' ) do |f|
44
+ compiler_options[f.to_sym] = false
45
+ end
31
46
  end.parse!
32
47
 
33
48
  modules_to_require.each do |mod|
@@ -59,7 +74,7 @@ else
59
74
  Opal.append_paths(*load_paths)
60
75
  end
61
76
 
62
- pid = fork { OpalWebpackLoader::CompileServer.new.start(number_of_workers) }
77
+ pid = fork { OpalWebpackLoader::CompileServer.new.start(number_of_workers, compiler_options) }
63
78
 
64
79
  have_socket = false
65
80
  start_time = Time.now
@@ -42,13 +42,13 @@ module OpalWebpackLoader
42
42
  @signal_queue = []
43
43
  end
44
44
 
45
- def start(number_of_workers = 4)
45
+ def start(number_of_workers = 4, compiler_options)
46
46
  $PROGRAM_NAME = 'owl compile server'
47
47
  @number_of_workers = number_of_workers
48
48
  @server_pid = Process.pid
49
49
  $stderr.sync = $stdout.sync = true
50
50
  @socket = UNIXServer.new(OWCS_SOCKET_PATH)
51
- spawn_workers
51
+ spawn_workers(compiler_options)
52
52
  SIGNALS.each { |sig| trap_deferred(sig) }
53
53
  trap('CHLD') { @write_pipe.write_nonblock('.') }
54
54
 
@@ -58,7 +58,7 @@ module OpalWebpackLoader
58
58
  case mode
59
59
  when nil
60
60
  kill_runaway_workers
61
- spawn_workers
61
+ spawn_workers(compiler_options)
62
62
  when 'QUIT', 'TERM', 'INT'
63
63
  @workers.each_pair do |pid, _worker|
64
64
  Process.kill('TERM', pid)
@@ -114,14 +114,14 @@ module OpalWebpackLoader
114
114
  worker.start
115
115
  end
116
116
 
117
- def spawn_workers
117
+ def spawn_workers(compiler_options)
118
118
  worker_number = -1
119
119
  until (worker_number += 1) == @number_of_workers
120
120
  @workers.value?(worker_number) && next
121
121
  tempfile = Tempfile.new('')
122
122
  tempfile.unlink
123
123
  tempfile.sync = true
124
- worker = OpalWebpackLoader::CompileWorker.new(@server_pid, @socket, tempfile, worker_number)
124
+ worker = OpalWebpackLoader::CompileWorker.new(@server_pid, @socket, tempfile, worker_number, compiler_options)
125
125
  pid = fork { init_worker(worker) }
126
126
  @workers[pid] = worker
127
127
  end
@@ -6,11 +6,12 @@ module OpalWebpackLoader
6
6
 
7
7
  attr_reader :number, :tempfile
8
8
 
9
- def initialize(master_pid, socket, tempfile, number)
9
+ def initialize(master_pid, socket, tempfile, number, compiler_options)
10
10
  @master_pid = master_pid
11
11
  @socket = socket
12
12
  @tempfile = tempfile
13
13
  @number = number
14
+ @compiler_options = compiler_options.merge(es6_modules: true)
14
15
  end
15
16
 
16
17
  def ==(other_number)
@@ -72,7 +73,7 @@ module OpalWebpackLoader
72
73
  source = File.read(filename)
73
74
 
74
75
  begin
75
- c = Opal::Compiler.new(source, file: filename, es6_modules: true)
76
+ c = Opal::Compiler.new(source, @compiler_options.merge(file: filename))
76
77
  result = { 'javascript' => c.compile }
77
78
  if compile_source_map
78
79
  result['source_map'] = c.source_map.as_json
@@ -1,3 +1,3 @@
1
1
  module OpalWebpackLoader
2
- VERSION="0.8.2"
2
+ VERSION="0.8.3"
3
3
  end
data/readme.md CHANGED
@@ -197,7 +197,8 @@ OpalWebpackLoader.use_manifest = false
197
197
  OpalWebpackLoader.manifest_path = File.join(Dir.getwd, 'public', 'assets', 'manifest.json') # doesn't matter, not used
198
198
  OpalWebpackLoader.client_asset_path = 'http://localhost:3035/assets/'
199
199
  ```
200
-
200
+ ### Advanced Options
201
+ [Advanced Options](https://github.com/isomorfeus/opal-webpack-loader/blob/master/docs/advanced_options.md)
201
202
  ### Tests
202
203
  - clone the repo
203
204
  - `bundle install`
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.8.2
4
+ version: 0.8.3
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-17 00:00:00.000000000 Z
11
+ date: 2019-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opal