sprockets-esbuild 0.0.1-arm64-darwin

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 0f6a8ca3ce140702830aa6d81f5c495b8398e683db8e20c7f016cdbfb768aecb
4
+ data.tar.gz: ea48d381efbbb9a3e56d0386c3fd07b980747dfe8017cd74f42ca3c663652153
5
+ SHA512:
6
+ metadata.gz: dcc59b2562ca442daf0220929564a804b1ca8419e81dd47ff384060a28adb905c17b233baacf5b409bdf65408bfa4172ce4cdb5aa71ea183d18ef2ff181f5371
7
+ data.tar.gz: fc6455ae4e99447959271290a48dda3d60c8c5c0333f15833295ff7bba5201e106357448fe8748657297c158bd85b2528a9673332a5b1f901dc44e7cf4226930
@@ -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
@@ -0,0 +1,14 @@
1
+ require "bundler/setup"
2
+
3
+ require "bundler/gem_tasks"
4
+
5
+ require "rake/testtask"
6
+
7
+ Rake::TestTask.new(:test) do |t|
8
+ t.libs << 'test'
9
+ t.pattern = 'test/**/*_test.rb'
10
+ t.verbose = false
11
+ t.warning = true
12
+ end
13
+
14
+ task default: :test
Binary file
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,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
@@ -0,0 +1,3 @@
1
+ module SprocketsEsbuild
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,2 @@
1
+ require 'sprockets-esbuild/version'
2
+ require 'sprockets-esbuild/transformers'
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: arm64-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/arm64-darwin/esbuild
38
+ - exe/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: []