sprockets-esbuild 0.0.1-x86_64-darwin
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE-DEPENDENCIES +27 -0
- data/README.md +19 -0
- data/Rakefile +14 -0
- data/exe/esbuild +19 -0
- data/exe/x86_64-darwin/esbuild +0 -0
- data/lib/sprockets-esbuild/transformers.rb +69 -0
- data/lib/sprockets-esbuild/version.rb +3 -0
- data/lib/sprockets-esbuild.rb +2 -0
- metadata +66 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8e3670f95dbcbe1ebee9b2ff73847e888cd3c52b83147646dba20e7c8247d3d7
|
4
|
+
data.tar.gz: 4e525c3261d1fc3aa87a04a398fd893370348fcc2884e896568769e5a8615bdc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0f8e2a464c12b2d161dd35628639d53b0ac99ba58ccd7456daaebaec8741277710df78e91c14e66e9305de3981b236e5370d0418a5d1b40fede19192c1ff3b91
|
7
|
+
data.tar.gz: 1af047e61d41dc1b26f2cced3d903b77b9c2a7f81928083bd66c12253813472151272098b66f5019dc7c3b2e8b259487f8f2dae9a01690d20dd1ce7f9eb8f881
|
@@ -0,0 +1,27 @@
|
|
1
|
+
sprockets-esbuild may redistribute executables from the https://github.com/evanw/esbuild
|
2
|
+
|
3
|
+
The license for that software can be found at https://github.com/evanw/esbuild/blob/master/LICENSE.md which is reproduced here for your convenience:
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
MIT License
|
8
|
+
|
9
|
+
Copyright (c) 2020 Evan Wallace
|
10
|
+
|
11
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
12
|
+
copy of this software and associated documentation files (the "Software"),
|
13
|
+
to deal in the Software without restriction, including without limitation
|
14
|
+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
15
|
+
and/or sell copies of the Software, and to permit persons to whom the
|
16
|
+
Software is furnished to do so, subject to the following conditions:
|
17
|
+
|
18
|
+
The above copyright notice and this permission notice shall be included in
|
19
|
+
all copies or substantial portions of the Software.
|
20
|
+
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
22
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
23
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
24
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
25
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
26
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
27
|
+
DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# esbuild support for Sprockets
|
2
|
+
|
3
|
+
esbuild is an extremely fast transpiler.
|
4
|
+
|
5
|
+
This gem uses esbuild to implement Sprockets transformers that will convert
|
6
|
+
TypeScript, JSX, and TSX formats to JavaScript. Sourcemaps are produced.
|
7
|
+
|
8
|
+
This gem wraps [the standalone executable version](https://esbuild.github.io/getting-started/#download-a-build) of the esbuild executables. These executables are platform specific, so there are actually separate underlying gems per platform, but the correct gem will automatically be picked for your platform. Supported platforms are Linux x64, macOS arm64, macOS x64, and Windows x64. (Note that due to this setup, you must install the actual gems – you can't pin your gem to the github repo.)
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Inside a Rails application, run:
|
13
|
+
|
14
|
+
1. Run `./bin/bundle add sprockets-esbuild`
|
15
|
+
|
16
|
+
## License
|
17
|
+
|
18
|
+
sprockets-esbuild is released under the [MIT License](https://opensource.org/licenses/MIT).
|
19
|
+
esbuild is released under the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/exe/esbuild
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# because rubygems shims assume a gem's executables are Ruby
|
3
|
+
|
4
|
+
require "shellwords"
|
5
|
+
|
6
|
+
platform_dir = Dir.glob(File.join(__dir__, "*")).select do |f|
|
7
|
+
File.directory?(f) && Gem::Platform.match(File.basename(f))
|
8
|
+
end.first
|
9
|
+
if platform_dir.nil?
|
10
|
+
raise "Cannot find the esbuild executable in #{__dir__} (1)"
|
11
|
+
end
|
12
|
+
|
13
|
+
exe_path = File.join(platform_dir, "esbuild")
|
14
|
+
if !File.exist?(exe_path)
|
15
|
+
raise "Cannot find the esbuild executable in #{__dir__} (2)"
|
16
|
+
end
|
17
|
+
|
18
|
+
command = Shellwords.join([exe_path, ARGV].flatten)
|
19
|
+
exec(command)
|
Binary file
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# Define JSX, TS (TypeScript) and TSX tranformers, based on shelling
|
2
|
+
# out to a platform specific esbuild executable.
|
3
|
+
|
4
|
+
require 'open3'
|
5
|
+
require 'sprockets'
|
6
|
+
|
7
|
+
module SprocketsEsbuild
|
8
|
+
|
9
|
+
class TransformerBase
|
10
|
+
include Sprockets
|
11
|
+
|
12
|
+
ESBUILD = File.expand_path('../../exe/esbuild', __dir__)
|
13
|
+
|
14
|
+
def cache_key
|
15
|
+
@cache_key ||= "#{self.class.name}::#{VERSION}".freeze
|
16
|
+
end
|
17
|
+
|
18
|
+
def call(input)
|
19
|
+
data = input[:data]
|
20
|
+
|
21
|
+
input[:cache].fetch([cache_key, data]) do
|
22
|
+
|
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
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# https://esbuild.github.io/content-types/#jsx
|
37
|
+
class JsxTransformer < TransformerBase
|
38
|
+
def loader
|
39
|
+
'jsx'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# https://esbuild.github.io/content-types/#typescript
|
44
|
+
class TsTransformer < TransformerBase
|
45
|
+
def loader
|
46
|
+
'ts'
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# https://esbuild.github.io/content-types/#typescript
|
51
|
+
class TsxTransformer < TransformerBase
|
52
|
+
def loader
|
53
|
+
'tsx'
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
Sprockets.register_mime_type 'application/typescript', extensions: ['.ts']
|
59
|
+
Sprockets.register_mime_type 'text/jsx', extensions: ['.jsx']
|
60
|
+
Sprockets.register_mime_type 'text/tsx', extensions: ['.tsx']
|
61
|
+
|
62
|
+
Sprockets.register_transformer 'application/typescript',
|
63
|
+
'application/javascript', SprocketsEsbuild::TsTransformer.new
|
64
|
+
|
65
|
+
Sprockets.register_transformer 'text/jsx',
|
66
|
+
'application/javascript', SprocketsEsbuild::JsxTransformer.new
|
67
|
+
|
68
|
+
Sprockets.register_transformer 'text/tsx',
|
69
|
+
'application/javascript', SprocketsEsbuild::TsxTransformer.new
|
metadata
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sprockets-esbuild
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: x86_64-darwin
|
6
|
+
authors:
|
7
|
+
- Sam Ruby
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-12-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sprockets
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description:
|
28
|
+
email: rubys@intertwingly.net
|
29
|
+
executables:
|
30
|
+
- esbuild
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- LICENSE-DEPENDENCIES
|
35
|
+
- README.md
|
36
|
+
- Rakefile
|
37
|
+
- exe/esbuild
|
38
|
+
- exe/x86_64-darwin/esbuild
|
39
|
+
- lib/sprockets-esbuild.rb
|
40
|
+
- lib/sprockets-esbuild/transformers.rb
|
41
|
+
- lib/sprockets-esbuild/version.rb
|
42
|
+
homepage: https://github.com/rails/tailwindcss-rails
|
43
|
+
licenses:
|
44
|
+
- MIT
|
45
|
+
metadata:
|
46
|
+
homepage_uri: https://github.com/rails/tailwindcss-rails
|
47
|
+
post_install_message:
|
48
|
+
rdoc_options: []
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
requirements: []
|
62
|
+
rubygems_version: 3.2.33
|
63
|
+
signing_key:
|
64
|
+
specification_version: 4
|
65
|
+
summary: Transpile JSX, TS, and TSX files with esbuild.
|
66
|
+
test_files: []
|