sprockets-esbuild 0.0.2 → 0.0.4

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: ba4d356fee1fd0f71fef9dc414ec9abe50a37e45670640d14e365925a5b431ca
4
- data.tar.gz: 36e320940a5ae86295bf1ca2e9bdcec84f9ba004dae21bfcba307ea94f728557
3
+ metadata.gz: d20f7c95a2fc77139827ac99da09e09496210cd0407248588b8b677fc5b8dae7
4
+ data.tar.gz: 4e317ebdb0ee6f02f31ac6e5ffb110131debe72c92667826af2c599da75821fa
5
5
  SHA512:
6
- metadata.gz: 99db531229668f9dadeca630ae8d4bd0e958abc5afc08d217102230f3a7fe841ebfdf1676d478c69f0dd13684898ec72a6c9e4ac7c340fddd5818b8521a32938
7
- data.tar.gz: a2ea342368d2b5ed9e25c22f4759d0901aa6fe37146c8d084aba59d2df56dac6839a760ab2d6cca5d1aab9ff5d73a5174366904d17e2f6fc592a248deb5f798f
6
+ metadata.gz: 6c1d4f2f6bc6bfb9e69f2addb1d10bdeb30a9988040bf9ad5ae0410052bdee95b43f69c6069f702bc60028849eec283bd2ad72353515d5fcfe561750efef1fec
7
+ data.tar.gz: 0474ff1a41a5b4015e7098fac2b2b5518fe78141f8e9a3d513d834386def603180607d392c274154a1c54a47bb1e73358f76ef5f94a1765b69b8347de9de0ec0
data/exe/esbuild CHANGED
@@ -34,4 +34,11 @@ if exe_path.nil?
34
34
  exit 1
35
35
  end
36
36
 
37
- system exe_path, *ARGV
37
+ if Gem.win_platform?
38
+ # use system rather than exec as exec inexplicably fails to find the executable
39
+ # on Windows
40
+ system exe_path, *ARGV
41
+ else
42
+ # use exec rather than system to avoid creating a new process
43
+ exec exe_path, *ARGV
44
+ end
@@ -3,13 +3,21 @@
3
3
 
4
4
  require 'open3'
5
5
  require 'sprockets'
6
+ require 'sprockets/source_map_utils'
7
+ require 'json'
8
+ require 'base64'
9
+ require 'pathname'
6
10
 
7
11
  module SprocketsEsbuild
8
12
 
9
13
  class TransformerBase
10
14
  include Sprockets
11
15
 
12
- ESBUILD = File.expand_path('../../exe/esbuild', __dir__)
16
+ ESBUILD = [File.expand_path('../../exe/esbuild', __dir__)]
17
+
18
+ # As windows doesn't support she-bang syntax in scripts, prepend Ruby to
19
+ # the command
20
+ ESBUILD.unshift RbConfig.ruby if Gem.win_platform?
13
21
 
14
22
  def cache_key
15
23
  @cache_key ||= "#{self.class.name}::#{VERSION}".freeze
@@ -20,15 +28,31 @@ module SprocketsEsbuild
20
28
 
21
29
  input[:cache].fetch([cache_key, data]) do
22
30
 
23
- out, err, status = Open3.capture3(ESBUILD, '--sourcemap',
24
- "--sourcefile=#{input[:filename]}", "--loader=#{loader}",
25
- stdin_data: input[:data])
26
-
27
- if status.success? and err.empty?
28
- out
29
- else
30
- raise Error, "esbuild exit status=#{status.exitstatus}\n#{err}"
31
- end
31
+ out, err, status = Open3.capture3(*ESBUILD, '--sourcemap',
32
+ "--sourcefile=#{input[:filename]}", "--loader=#{loader}",
33
+ stdin_data: input[:data])
34
+
35
+ match = out.match %r{^//# sourceMappingURL=data:application/json;base64,(.*)\s*}
36
+
37
+ if match
38
+ # extract sourcemap from output and then format and combine it
39
+ out[match.begin(0)..match.end(0)] = ''
40
+ map = JSON.parse(Base64.decode64(match[1]))
41
+ map = SourceMapUtils.format_source_map(map, input)
42
+ map = SourceMapUtils.combine_source_maps(input[:metadata][:map], map)
43
+ else
44
+ map = nil
45
+ end
46
+
47
+ if status.success? and err.empty?
48
+ if map
49
+ { data: out, map: map }
50
+ else
51
+ out
52
+ end
53
+ else
54
+ raise Error, "esbuild exit status=#{status.exitstatus}\n#{err}"
55
+ end
32
56
  end
33
57
  end
34
58
  end
@@ -1,7 +1,7 @@
1
1
  module SprocketsEsbuild
2
2
  # constants describing the upstream esbuild project
3
3
  module Upstream
4
- VERSION = "0.14.5"
4
+ VERSION = "0.19.5"
5
5
 
6
6
  # rubygems platform name => [upstream release tarball name, tarball path]
7
7
  NATIVE_PLATFORMS = {
@@ -1,3 +1,3 @@
1
1
  module SprocketsEsbuild
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sprockets-esbuild
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Ruby
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2021-12-26 00:00:00.000000000 Z
12
+ date: 2023-10-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sprockets
@@ -59,7 +59,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
59
59
  - !ruby/object:Gem::Version
60
60
  version: '0'
61
61
  requirements: []
62
- rubygems_version: 3.2.33
62
+ rubygems_version: 3.4.8
63
63
  signing_key:
64
64
  specification_version: 4
65
65
  summary: Transpile JSX, TS, and TSX files with esbuild.