opal-webpack-loader 0.3.1 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6b74a5392ea2d224f3c9f75b7a542054736d8f3ba676ed63f2f60bbf12f1a755
4
- data.tar.gz: 35b368358aaf9199c13b4339a9b47e533218ecf158a8a87ba9a7cc078dec34e9
3
+ metadata.gz: 8032476092204172bd9c607147b7cb05eaf3859f17926d1e09bd9853b4971045
4
+ data.tar.gz: 252dff9803283436c074fe997e6ae2dec0f32d6ba16d1977ad5200b92edd81eb
5
5
  SHA512:
6
- metadata.gz: 738778833ae9d11c1a6e774b5173b2fb4676786e4bc4863e11880997b4ddf32040a5ece56511e0a5279270a0442b4445a245a7e0e3214affd98f20b59395d955
7
- data.tar.gz: 5e2a1737d57113c78310890db6aea0e8419a75c44c2f242d113f5038cd44da68511ca32f907a158d6e4814b204b419d139611867ac459c57721394f2580bb135
6
+ metadata.gz: b73cf6b3b946ffaed75e1b684bbd3dff266bc1fde599132fcb8f2992b37a44836cf5ac80a1a9efbc35dcc9332801dbc6ae8067628f585457e043aaabc86647f5
7
+ data.tar.gz: b844a167b78695aaa20ae7f0e11a409c6e0f67a8de7e78aa619df4c51b0f85a25e573550ec071a43465cb2842109a076a8c263421403512b0f03b69ded94d9cf
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.3.1
4
+ version: 0.3.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-09-06 00:00:00.000000000 Z
11
+ date: 2018-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opal
@@ -75,9 +75,6 @@ extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
77
  - bin/opal-webpack-compile-server
78
- - lib/opal-webpack-loader.rb
79
- - lib/opal-webpack-loader/compile_server.rb
80
- - lib/opal-webpack-loader/version.rb
81
78
  homepage: http://hyperstack.org
82
79
  licenses:
83
80
  - MIT
@@ -1,31 +0,0 @@
1
- # check version of opal-webpack-loader-npm
2
- require 'opal-webpack-loader/version'
3
- require 'opal-webpack-loader/manifest'
4
- if defined? Rails
5
- require 'opal-webpack-loader/rails_view_helper'
6
- else
7
- require 'opal-webpack-loader/view_helper'
8
- end
9
-
10
- owl_version = ''
11
- npm = `which npm`.chop
12
-
13
- if npm != ''
14
- owl_version = `#{npm} view opal-webpack-loader version`
15
- else
16
- yarn = `which yarn`.chop
17
- if yarn != ''
18
- owl_version = `#{yarn} -s info opal-webpack-loader version`
19
- else
20
- raise 'opal-webpack-loader: Could not find npm or yarn! Please install npm or yarn'
21
- end
22
- end
23
-
24
- owl_version = owl_version.chop # remove newline at end
25
-
26
- unless owl_version != OpalWebpackLoader::VERSION
27
- raise "opal-webpack-loader: Incorrect version of npm package found or npm package not installed.\n" +
28
- "Please install the npm package for opal-webpack-loader:\n" +
29
- "\twith npm:\tnpm install opal-webpack-loader@#{OpalWebpackLoader::VERSION} --save-dev\n" +
30
- "\twith yarn:\tyarn add opal-webpack-loader@#{OpalWebpackLoader::VERSION} --dev\n"
31
- end
@@ -1,156 +0,0 @@
1
- require 'oj'
2
- require 'eventmachine'
3
- require 'opal/paths'
4
- require 'opal/source_map'
5
- require 'source_map'
6
- require 'opal/compiler'
7
- require 'socket'
8
-
9
- at_exit do
10
- if OpalWebpackCompileServer::Exe.unlink_socket?
11
- if File.exist?(OpalWebpackCompileServer::OWCS_SOCKET_PATH)
12
- File.unlink(OpalWebpackCompileServer::OWCS_SOCKET_PATH)
13
- end
14
- end
15
- end
16
-
17
- module OpalWebpackCompileServer
18
- OWL_CACHE_DIR = './.owl_cache/'
19
- OWL_LP_CACHE = OWL_CACHE_DIR + 'load_paths.json'
20
- OWCS_SOCKET_PATH = OWL_CACHE_DIR + 'owcs_socket'
21
-
22
- class Compiler < EventMachine::Connection
23
- def receive_data(data)
24
- if data.start_with?('command:stop')
25
- EventMachine.stop
26
- exit(0)
27
- end
28
-
29
- filename = data.chop # remove newline
30
-
31
- operation = proc do
32
- begin
33
- source = File.read(filename)
34
- c = Opal::Compiler.new(source, file: filename, es6_modules: true)
35
- c.compile
36
- result = { 'javascript' => c.result }
37
- result['source_map'] = c.source_map.as_json
38
- result['source_map']['sourcesContent'] = [source]
39
- result['source_map']['file'] = filename
40
- result['source_map']['names'] = result['source_map']['names'].map(&:to_s)
41
- result['required_trees'] = c.required_trees
42
- Oj.dump(result)
43
- rescue Exception => e
44
- Oj.dump({ 'error' => { 'name' => e.class, 'message' => e.message, 'backtrace' => e.backtrace } })
45
- end
46
- end
47
-
48
- callback = proc do |json|
49
- self.send_data(json + "\n")
50
- close_connection_after_writing
51
- end
52
-
53
- EM.defer(operation, callback)
54
- end
55
- end
56
-
57
- class LoadPathManager
58
- def self.get_load_path_entries(path)
59
- path_entries = []
60
- return [] unless Dir.exist?(path)
61
- dir_entries = Dir.entries(path)
62
- dir_entries.each do |entry|
63
- next if entry == '.'
64
- next if entry == '..'
65
- absolute_path = File.join(path, entry)
66
- if File.directory?(absolute_path)
67
- more_path_entries = get_load_path_entries(absolute_path)
68
- path_entries.push(*more_path_entries) if more_path_entries.size > 0
69
- elsif (absolute_path.end_with?('.rb') || absolute_path.end_with?('.js')) && File.file?(absolute_path)
70
- path_entries.push(absolute_path)
71
- end
72
- end
73
- path_entries
74
- end
75
-
76
- def self.get_load_paths
77
- load_paths = if File.exist?('bin/rails')
78
- %x{
79
- bundle exec rails runner "puts (Rails.configuration.respond_to?(:assets) ? (Rails.configuration.assets.paths + Opal.paths).uniq : Opal.paths)"
80
- }
81
- else
82
- %x{
83
- bundle exec ruby -e 'require "bundler/setup"; Bundler.require; puts Opal.paths'
84
- }
85
- end
86
- if $? == 0
87
- load_path_lines = load_paths.split("\n")
88
- load_path_lines.pop if load_path_lines.last == ''
89
-
90
- load_path_entries = []
91
-
92
- cwd = Dir.pwd
93
-
94
- load_path_lines.each do |path|
95
- next if path.start_with?(cwd)
96
- more_path_entries = get_load_path_entries(path)
97
- load_path_entries.push(*more_path_entries) if more_path_entries.size > 0
98
- end
99
- cache_obj = { 'opal_load_paths' => load_path_lines, 'opal_load_path_entries' => load_path_entries }
100
- Dir.mkdir(OpalWebpackCompileServer::OWL_CACHE_DIR) unless Dir.exist?(OpalWebpackCompileServer::OWL_CACHE_DIR)
101
- File.write(OpalWebpackCompileServer::OWL_LP_CACHE, Oj.dump(cache_obj))
102
- load_path_lines
103
- else
104
- raise 'Error getting load paths!'
105
- exit(2)
106
- end
107
- end
108
- end
109
-
110
- class Exe
111
- def self.unlink_socket?
112
- @unlink
113
- end
114
-
115
- def self.unlink_on_exit
116
- @unlink = true
117
- end
118
-
119
- def self.dont_unlink_on_exit
120
- @unlink = false
121
- end
122
-
123
- def self.stop
124
- if File.exist?(OWCS_SOCKET_PATH)
125
- dont_unlink_on_exit
126
- begin
127
- s = UNIXSocket.new(OWCS_SOCKET_PATH)
128
- s.send("command:stop\n", 0)
129
- s.close
130
- rescue
131
- # socket cant be reached so owcs is already dead, delete socket
132
- unlink_on_exit
133
- end
134
- exit(0)
135
- end
136
- end
137
-
138
- def self.run
139
- if File.exist?(OWCS_SOCKET_PATH) # OWCS already running
140
- puts 'Another Opal Webpack Compile Server already running, exiting'
141
- dont_unlink_on_exit
142
- exit(1)
143
- else
144
- unlink_on_exit
145
- load_paths = OpalWebpackCompileServer::LoadPathManager.get_load_paths
146
- if load_paths
147
- Opal.append_paths(*load_paths)
148
- Process.daemon(true)
149
- EventMachine.run do
150
- EventMachine.start_unix_domain_server(OWCS_SOCKET_PATH, OpalWebpackCompileServer::Compiler)
151
- end
152
- end
153
- end
154
- end
155
- end
156
- end
@@ -1,3 +0,0 @@
1
- module OpalWebpackLoader
2
- VERSION="0.3.1"
3
- end