sprockets-esbuild 0.0.1-x64-mingw32
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/x64-mingw32/esbuild +14 -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: 956c419099365cfbc676bf57d3404edde072871d1de81326896419691c1393f0
|
4
|
+
data.tar.gz: 608dc9458c55e4e61f94c0bbd7ce35becded6441669e28669f73a9d07566afd6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3e7244cbd3c451d06e7bbdb5145fe247cc38aff3954941cb4a371d57b635299ffc42f8e58c34dd801b86b1d0ebb6df77302e89de7ef3ca7c5499fb2b9ff21c3f
|
7
|
+
data.tar.gz: 2ef3ef44050ae5c96a0420ad9946f6429c2679ed998416ff99312debb3c88b8a9d9f68d092a28f0733f92840c88d5e32e5ade0bd3b875f7a08932ea4603b6c2c
|
@@ -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)
|
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
|
3
|
+
// Unfortunately even though npm shims "bin" commands on Windows with auto-
|
4
|
+
// generated forwarding scripts, it doesn't strip the ".exe" from the file name
|
5
|
+
// first. So it's possible to publish executables via npm on all platforms
|
6
|
+
// except Windows. I consider this a npm bug.
|
7
|
+
//
|
8
|
+
// My workaround is to add this script as another layer of indirection. It'll
|
9
|
+
// be slower because node has to boot up just to shell out to the actual exe,
|
10
|
+
// but Windows is somewhat of a second-class platform to npm so it's the best
|
11
|
+
// I can do I think.
|
12
|
+
const esbuild_exe = require.resolve('esbuild-windows-64/esbuild.exe');
|
13
|
+
const child_process = require('child_process');
|
14
|
+
child_process.spawnSync(esbuild_exe, process.argv.slice(2), { stdio: 'inherit' });
|
@@ -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: x64-mingw32
|
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/x64-mingw32/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: []
|