opal-webpack-compile-server 0.0.1 → 0.0.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/lib/opal-webpack-compile-server/exe.rb +21 -6
- data/lib/opal-webpack-compile-server/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: 59d4390234fd961b3a2e5b21b30e802131cb73df824872946a01b0a4f64a8cc6
|
4
|
+
data.tar.gz: 349b7074debec95163e688a5557b345487744fce06dafc62691b51f7ade053e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4be03971e338d21e56556e82ce22e0abdc3decf8e944cbe90f9b71465d20b725536571bd1969fa64f788dd7d4a8ce10c115c3ddbc3a5e86cbd9ddc3e4000d320
|
7
|
+
data.tar.gz: c02374559aa1f1aa8be0bfe8ad7cbc5fd0dc8cba3b465d55daca0e184d504abbdb6ad4c03ae60435b085db2c305b6f37585271a206b99487fc1cec33affb936b
|
@@ -1,12 +1,18 @@
|
|
1
1
|
require 'oj'
|
2
2
|
require 'eventmachine'
|
3
|
+
require 'opal/paths'
|
3
4
|
require 'opal/source_map'
|
4
5
|
require 'source_map'
|
5
6
|
require 'opal/compiler'
|
6
7
|
|
8
|
+
at_exit do
|
9
|
+
File.unlink(OpalWebpackCompileServer::OWCS_SOCKET_PATH)
|
10
|
+
end
|
11
|
+
|
7
12
|
module OpalWebpackCompileServer
|
8
13
|
|
9
14
|
OWL_CACHE_DIR = './.owl_cache/'
|
15
|
+
OWL_LP_CACHE = './.owl_cache/load_paths.json'
|
10
16
|
OWCS_SOCKET_PATH = OWL_CACHE_DIR + 'owcs_socket'
|
11
17
|
|
12
18
|
class Compiler < EventMachine::Connection
|
@@ -16,23 +22,26 @@ module OpalWebpackCompileServer
|
|
16
22
|
exit(0)
|
17
23
|
end
|
18
24
|
|
19
|
-
filename = data.chop
|
25
|
+
filename = data.chop # remove newline
|
20
26
|
|
21
27
|
operation = proc do
|
22
28
|
begin
|
23
29
|
source = File.read(filename)
|
24
|
-
c = Opal::Compiler.new(source, es_six_imexable: true)
|
30
|
+
c = Opal::Compiler.new(source, file: filename, es_six_imexable: true)
|
25
31
|
c.compile
|
26
|
-
result = { javascript
|
27
|
-
result[
|
32
|
+
result = { 'javascript' => c.result }
|
33
|
+
result['source_map'] = c.source_map(filename).as_json
|
34
|
+
result['source_map']['sourcesContent'] = [source]
|
35
|
+
result['source_map']['file'] = filename
|
36
|
+
result['required_trees'] = c.required_trees
|
28
37
|
Oj.dump(result)
|
29
38
|
rescue Exception => e
|
30
|
-
Oj.dump({ error
|
39
|
+
Oj.dump({ 'error' => { 'name' => e.class, 'message' => e.message, 'backtrace' => e.backtrace } })
|
31
40
|
end
|
32
41
|
end
|
33
42
|
|
34
43
|
callback = proc do |json|
|
35
|
-
self.send_data(json)
|
44
|
+
self.send_data(json + "\n")
|
36
45
|
close_connection_after_writing
|
37
46
|
end
|
38
47
|
|
@@ -42,6 +51,12 @@ module OpalWebpackCompileServer
|
|
42
51
|
|
43
52
|
class Exe
|
44
53
|
def self.run
|
54
|
+
exit(1) if File.exist?(OWCS_SOCKET_PATH) # OWCS already running
|
55
|
+
if File.exist?(OWL_LP_CACHE)
|
56
|
+
Opal.append_paths(*(Oj.load(File.read(OWL_LP_CACHE))['opal_load_paths']))
|
57
|
+
else
|
58
|
+
exit(2)
|
59
|
+
end
|
45
60
|
EventMachine.run do
|
46
61
|
EventMachine.start_unix_domain_server(OWCS_SOCKET_PATH, OpalWebpackCompileServer::Compiler)
|
47
62
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opal-webpack-compile-server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.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: 2018-05-
|
11
|
+
date: 2018-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: eventmachine
|