rolldown 0.1.0-arm-linux-gnu

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.
Files changed (44) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +21 -0
  3. data/README.md +152 -0
  4. data/ext/rolldown/extconf.rb +123 -0
  5. data/ext/rolldown/include/rolldown.h +54 -0
  6. data/ext/rolldown/rolldown.c +130 -0
  7. data/lib/rolldown/3.2/rolldown.so +0 -0
  8. data/lib/rolldown/3.3/rolldown.so +0 -0
  9. data/lib/rolldown/3.4/rolldown.so +0 -0
  10. data/lib/rolldown/4.0/rolldown.so +0 -0
  11. data/lib/rolldown/asset.rb +33 -0
  12. data/lib/rolldown/backend.rb +36 -0
  13. data/lib/rolldown/build_result.rb +106 -0
  14. data/lib/rolldown/chunk.rb +70 -0
  15. data/lib/rolldown/diagnostic.rb +56 -0
  16. data/lib/rolldown/errors.rb +11 -0
  17. data/lib/rolldown/options.rb +152 -0
  18. data/lib/rolldown/version.rb +5 -0
  19. data/lib/rolldown.rb +50 -0
  20. data/licenses/README.md +8 -0
  21. data/licenses/rolldown-MIT.txt +25 -0
  22. data/licenses/rolldown-THIRD-PARTY.txt +33 -0
  23. data/rolldown.gemspec +43 -0
  24. data/rust/Cargo.lock +3086 -0
  25. data/rust/Cargo.toml +37 -0
  26. data/rust/build.rs +55 -0
  27. data/rust/cbindgen.toml +24 -0
  28. data/rust/rustfmt.toml +3 -0
  29. data/rust/src/build.rs +39 -0
  30. data/rust/src/lib.rs +92 -0
  31. data/rust/src/modules.rs +89 -0
  32. data/rust/src/options.rs +251 -0
  33. data/rust/src/payload.rs +104 -0
  34. data/rust/src/result.rs +49 -0
  35. data/sig/rolldown/asset.rbs +23 -0
  36. data/sig/rolldown/backend.rbs +26 -0
  37. data/sig/rolldown/build_result.rbs +47 -0
  38. data/sig/rolldown/chunk.rbs +39 -0
  39. data/sig/rolldown/diagnostic.rbs +35 -0
  40. data/sig/rolldown/errors.rbs +24 -0
  41. data/sig/rolldown/options.rbs +61 -0
  42. data/sig/rolldown/version.rbs +5 -0
  43. data/sig/rolldown.rbs +12 -0
  44. metadata +92 -0
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rolldown
4
+ class Chunk
5
+ attr_reader :filename #: String
6
+ attr_reader :name #: String
7
+ attr_reader :code #: String
8
+ attr_reader :map #: String?
9
+ attr_reader :imports #: Array[String]
10
+ attr_reader :dynamic_imports #: Array[String]
11
+ attr_reader :exports #: Array[String]
12
+ attr_reader :module_ids #: Array[String]
13
+
14
+ #: (Hash[String, untyped]) -> Rolldown::Chunk
15
+ def self.from_hash(hash)
16
+ new(
17
+ filename: hash.fetch("filename"),
18
+ name: hash.fetch("name"),
19
+ code: hash.fetch("code"),
20
+ map: hash["map"],
21
+ entry: hash.fetch("is_entry"),
22
+ dynamic_entry: hash.fetch("is_dynamic_entry"),
23
+ imports: hash.fetch("imports"),
24
+ dynamic_imports: hash.fetch("dynamic_imports"),
25
+ exports: hash.fetch("exports"),
26
+ module_ids: hash.fetch("module_ids")
27
+ )
28
+ end
29
+
30
+ #: (filename: String, name: String, code: String, map: String?, entry: bool, dynamic_entry: bool, imports: Array[String], dynamic_imports: Array[String], exports: Array[String], module_ids: Array[String]) -> void
31
+ def initialize(filename:, name:, code:, map:, entry:, dynamic_entry:, imports:, dynamic_imports:, exports:, module_ids:)
32
+ @filename = filename.freeze
33
+ @name = name.freeze
34
+ @code = code.freeze
35
+ @map = map&.freeze
36
+ @entry = entry
37
+ @dynamic_entry = dynamic_entry
38
+ @imports = imports.freeze
39
+ @dynamic_imports = dynamic_imports.freeze
40
+ @exports = exports.freeze
41
+ @module_ids = module_ids.freeze
42
+
43
+ freeze
44
+ end
45
+
46
+ #: () -> bool
47
+ def entry?
48
+ @entry
49
+ end
50
+
51
+ #: () -> bool
52
+ def dynamic_entry?
53
+ @dynamic_entry
54
+ end
55
+
56
+ #: () -> String
57
+ def to_s
58
+ code
59
+ end
60
+
61
+ #: () -> String
62
+ def inspect
63
+ parts = [filename.inspect, "#{code.bytesize} bytes"]
64
+ parts << "entry" if entry?
65
+ parts << "map" if map
66
+
67
+ "#<#{self.class.name} #{parts.join(" ")}>"
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rolldown
4
+ class Diagnostic
5
+ attr_reader :kind #: String
6
+ attr_reader :severity #: String
7
+ attr_reader :message #: String
8
+ attr_reader :file #: String?
9
+ attr_reader :line #: Integer?
10
+ attr_reader :column #: Integer?
11
+
12
+ #: (Hash[String, untyped]) -> Rolldown::Diagnostic
13
+ def self.from_hash(hash)
14
+ new(
15
+ kind: hash.fetch("kind"),
16
+ severity: hash.fetch("severity"),
17
+ message: hash.fetch("message"),
18
+ file: hash["file"],
19
+ line: hash["line"],
20
+ column: hash["column"]
21
+ )
22
+ end
23
+
24
+ #: (kind: String, severity: String, message: String, file: String?, line: Integer?, column: Integer?) -> void
25
+ def initialize(kind:, severity:, message:, file:, line:, column:)
26
+ @kind = kind.freeze
27
+ @severity = severity.freeze
28
+ @message = message.freeze
29
+ @file = file&.freeze
30
+ @line = line
31
+ @column = column
32
+
33
+ freeze
34
+ end
35
+
36
+ #: () -> bool
37
+ def error?
38
+ severity == "error"
39
+ end
40
+
41
+ #: () -> bool
42
+ def warning?
43
+ severity == "warning"
44
+ end
45
+
46
+ #: () -> String
47
+ def to_s
48
+ message
49
+ end
50
+
51
+ #: () -> String
52
+ def inspect
53
+ "#<#{self.class.name} #{severity} #{kind} #{message.inspect}>"
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rolldown
4
+ class Error < StandardError; end
5
+ class OptionError < Error; end
6
+ class EncodingError < Error; end
7
+ class BuildError < Error; end
8
+ class IOError < Error; end
9
+ class InternalError < Error; end
10
+ class PanicError < InternalError; end
11
+ end
@@ -0,0 +1,152 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+
5
+ module Rolldown
6
+ class Options
7
+ INPUT = [
8
+ :input, :cwd, :external, :platform, :treeshake, :shim_missing_exports, :module_types, :modules
9
+ ].freeze #: Array[Symbol]
10
+
11
+ OUTPUT = [
12
+ :dir, :file, :format, :name, :exports, :sourcemap, :minify, :banner, :footer, :intro, :outro,
13
+ :entry_file_names, :chunk_file_names, :asset_file_names, :keep_names, :legal_comments, :es_module
14
+ ].freeze #: Array[Symbol]
15
+
16
+ TRANSFORM = [:define].freeze #: Array[Symbol]
17
+
18
+ KNOWN = (INPUT + [:output, :transform]).freeze #: Array[Symbol]
19
+
20
+ CALLABLE = {
21
+ plugins: "plugins",
22
+ on_log: "onLog",
23
+ manual_chunks: "manualChunks",
24
+ sourcemap_path_transform: "sourcemapPathTransform",
25
+ }.freeze #: Hash[Symbol, String]
26
+
27
+ #: (Hash[Symbol, untyped], ?String) -> String
28
+ def self.serialize(options, subject = "a build")
29
+ new(options, subject).to_json
30
+ end
31
+
32
+ attr_reader :options #: Hash[Symbol, untyped]
33
+
34
+ #: (Hash[Symbol, untyped], ?String) -> void
35
+ def initialize(options, subject = "a build")
36
+ @options = normalize(options)
37
+
38
+ validate!(subject)
39
+
40
+ freeze
41
+ end
42
+
43
+ #: () -> Hash[Symbol, untyped]
44
+ def to_h
45
+ options
46
+ end
47
+
48
+ #: (?untyped) -> String
49
+ def to_json(state = nil)
50
+ state ? JSON.generate(to_h, state) : JSON.generate(to_h)
51
+ end
52
+
53
+ #: () -> String
54
+ def inspect
55
+ "#<#{self.class.name} #{to_h.inspect}>"
56
+ end
57
+
58
+ private
59
+
60
+ #: (Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
61
+ def normalize(given)
62
+ normalized = given.compact
63
+ output = (normalized[:output] || {}).compact
64
+
65
+ normalized[:input] = entries(normalized[:input]) if normalized.key?(:input)
66
+ normalized[:external] = externals(normalized[:external]) if normalized.key?(:external)
67
+ normalized[:cwd] = normalized[:cwd].to_s if normalized.key?(:cwd)
68
+ normalized[:platform] = normalized[:platform].to_s if normalized.key?(:platform)
69
+
70
+ [:format, :exports, :legal_comments].each do |key|
71
+ output[key] = output[key].to_s if output.key?(key)
72
+ end
73
+
74
+ [:sourcemap, :minify].each do |key|
75
+ output[key] = output[key].to_s if output[key].is_a?(Symbol)
76
+ end
77
+
78
+ normalized[:output] = output
79
+ normalized[:transform] = (normalized[:transform] || {}).compact
80
+
81
+ normalized
82
+ end
83
+
84
+ #: (untyped) -> Array[untyped]
85
+ def entries(given)
86
+ return named(given) if given.is_a?(Hash)
87
+
88
+ list = given.is_a?(Array) ? given : [given]
89
+
90
+ list.map { |entry| entry.is_a?(Hash) ? entry : entry.to_s }
91
+ end
92
+
93
+ #: (untyped) -> Array[String]
94
+ def externals(given)
95
+ list = given.is_a?(Array) ? given : [given]
96
+
97
+ list.map(&:to_s)
98
+ end
99
+
100
+ #: (Symbol, Array[Symbol], String) -> void
101
+ def refuse_nested(group, allowed, subject)
102
+ unknown = nested_keys(group) - allowed
103
+
104
+ return if unknown.empty?
105
+
106
+ raise OptionError, "#{group}.#{unknown.first} is not an option for #{subject}"
107
+ end
108
+
109
+ #: (Symbol) -> Array[Symbol]
110
+ def nested_keys(group)
111
+ value = options[group]
112
+
113
+ value.is_a?(Hash) ? value.keys : []
114
+ end
115
+
116
+ #: () -> Array[Symbol]
117
+ def output_keys
118
+ output = options[:output]
119
+
120
+ output.is_a?(Hash) ? output.keys : []
121
+ end
122
+
123
+ #: (Hash[untyped, untyped]) -> Array[untyped]
124
+ def named(given)
125
+ given.map { |name, import| { name: name.to_s, import: import.to_s } }
126
+ end
127
+
128
+ #: (String) -> void
129
+ def validate!(subject)
130
+ refuse_callables
131
+
132
+ unknown = options.keys - KNOWN
133
+
134
+ raise OptionError, "#{unknown.first} is not an option for #{subject}" unless unknown.empty?
135
+
136
+ refuse_nested(:output, OUTPUT, subject)
137
+ refuse_nested(:transform, TRANSFORM, subject)
138
+ end
139
+
140
+ #: () -> void
141
+ def refuse_callables
142
+ given = options.keys + output_keys + nested_keys(:transform)
143
+ named = CALLABLE.keys.find { |key| given.include?(key) }
144
+
145
+ return unless named
146
+
147
+ raise OptionError,
148
+ "#{named} takes a JavaScript function, which cannot cross into Ruby. " \
149
+ "See https://rolldown.rs for what #{CALLABLE.fetch(named)} does."
150
+ end
151
+ end
152
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rolldown
4
+ VERSION = "0.1.0"
5
+ end
data/lib/rolldown.rb ADDED
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "rolldown/version"
4
+ require_relative "rolldown/errors"
5
+ require_relative "rolldown/backend"
6
+ require_relative "rolldown/options"
7
+ require_relative "rolldown/chunk"
8
+ require_relative "rolldown/asset"
9
+ require_relative "rolldown/diagnostic"
10
+ require_relative "rolldown/build_result"
11
+
12
+ begin
13
+ require "rolldown/rolldown"
14
+ rescue LoadError
15
+ nil
16
+ end
17
+
18
+ module Rolldown
19
+ class << self
20
+ #: (**untyped) -> Rolldown::BuildResult
21
+ def build(**options)
22
+ strict = options.delete(:strict)
23
+ serialized = Options.serialize(options, "a build")
24
+
25
+ payload = Backend.build(serialized)
26
+
27
+ BuildResult.from_json(payload, destination(options), options[:cwd]&.to_s).validate!(strict: strict ? true : false)
28
+ end
29
+
30
+ #: () -> String
31
+ def rolldown_version
32
+ Backend.rolldown_version
33
+ end
34
+
35
+ private
36
+
37
+ #: (Hash[Symbol, untyped]) -> String?
38
+ def destination(options)
39
+ output = options[:output]
40
+
41
+ return nil unless output.is_a?(Hash)
42
+
43
+ file = output[:file]
44
+
45
+ return File.dirname(file.to_s) if file
46
+
47
+ output[:dir]&.to_s
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,8 @@
1
+ # Licenses
2
+
3
+ This gem is MIT licensed, and links [rolldown](https://github.com/rolldown/rolldown) statically.
4
+
5
+ - `rolldown-MIT.txt` is rolldown's own license.
6
+ - `rolldown-THIRD-PARTY.txt` is what rolldown vendors and reproduces in turn.
7
+
8
+ Run `cargo about generate` before a release to confirm nothing in the dependency closure has been missed.
@@ -0,0 +1,25 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-present VoidZero Inc. & Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ end of terms and conditions
24
+
25
+ The licenses of externally maintained libraries from which parts of the Software is derived are listed [here](https://github.com/rolldown/rolldown/blob/main/THIRD-PARTY-LICENSE).
@@ -0,0 +1,33 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 [these people](https://github.com/rollup/rollup/graphs/contributors)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10
+
11
+ ---
12
+
13
+ MIT License
14
+
15
+ Copyright (c) 2020 Evan Wallace
16
+
17
+ Permission is hereby granted, free of charge, to any person obtaining a copy
18
+ of this software and associated documentation files (the "Software"), to deal
19
+ in the Software without restriction, including without limitation the rights
20
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
21
+ copies of the Software, and to permit persons to whom the Software is
22
+ furnished to do so, subject to the following conditions:
23
+
24
+ The above copyright notice and this permission notice shall be included in all
25
+ copies or substantial portions of the Software.
26
+
27
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
28
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
29
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
30
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
31
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
32
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33
+ SOFTWARE.
data/rolldown.gemspec ADDED
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/rolldown/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "rolldown"
7
+ spec.version = Rolldown::VERSION
8
+ spec.authors = ["Marco Roth"]
9
+ spec.email = ["marco.roth@intergga.ch"]
10
+
11
+ spec.summary = "Blazing Fast Rust-based bundler for JavaScript"
12
+ spec.description = "Ruby bindings for Rolldown, the Rust bundler behind Vite."
13
+ spec.homepage = "https://github.com/marcoroth/rolldown-ruby"
14
+ spec.licenses = ["MIT"]
15
+ spec.required_ruby_version = ">= 3.2.0"
16
+ spec.require_paths = ["lib"]
17
+
18
+ spec.metadata["homepage_uri"] = spec.homepage
19
+ spec.metadata["source_code_uri"] = "https://github.com/marcoroth/rolldown-ruby"
20
+ spec.metadata["changelog_uri"] = "https://github.com/marcoroth/rolldown-ruby/releases"
21
+ spec.metadata["rubygems_mfa_required"] = "true"
22
+
23
+ spec.files = Dir[
24
+ "rolldown.gemspec",
25
+ "LICENSE.txt",
26
+ "licenses/*.txt",
27
+ "licenses/README.md",
28
+ "README.md",
29
+ "lib/**/*.rb",
30
+ "sig/**/*.rbs",
31
+ "ext/rolldown/extconf.rb",
32
+ "ext/rolldown/rolldown.c",
33
+ "ext/rolldown/include/**/*.h",
34
+ "rust/Cargo.toml",
35
+ "rust/Cargo.lock",
36
+ "rust/build.rs",
37
+ "rust/cbindgen.toml",
38
+ "rust/rustfmt.toml",
39
+ "rust/src/**/*.rs"
40
+ ]
41
+
42
+ spec.extensions = ["ext/rolldown/extconf.rb"]
43
+ end