opal-vite 0.3.1 → 0.3.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8736c0cccd990adbc7f614480718ba0bab767f94ad281f508b0a01b9898deb3d
4
- data.tar.gz: 93ab376b58edb586aed577d0d4a19011f7f84660c62eebffe418eccb4b9b1e73
3
+ metadata.gz: 5491e78891b38d4e302b86941b5bce99574452f0e361bad6c109711f9e0e247d
4
+ data.tar.gz: 70c7080aa2c98fc641c28e63c077aed1a601705a0c3b380031c0e822b7a6f1be
5
5
  SHA512:
6
- metadata.gz: 1c0d8a02384a2e1f958d2a0ce62f66fe8f63db8c87cbe709089e04ca9441e2d37a9a41b860170cdb2ca8f24467a79ce12b2587d1312e0d59dd22e75020429911
7
- data.tar.gz: 7aae2b96e735993cfd583cdc98ea0ad6bbd49110ef63209b17f6f49e614bf7edc0d1948612f40522ed9aa6e1839fa6e02731a7f6764ef269b3b61c17cee5c2b3
6
+ metadata.gz: 5951f4e205e1c6415062830331007db5592a51d8672f025a02cbee24ac4eef2239895c5f6ceb35e2a7c3b96187be54e80e85c032671e45640b815011e3fc98b7
7
+ data.tar.gz: c36245a857819c721caa5a5ab98f5beaeea97babf49168018abe84a104864696c19c3f34bd7393c9a2076b81599c3702babbd208e35a619239ae7336955a6905
@@ -11,6 +11,7 @@ module Opal
11
11
  @options = options
12
12
  @config = options[:config] || Opal::Vite.config
13
13
  @include_concerns = options.fetch(:include_concerns, true)
14
+ @stubs = options.fetch(:stubs, [])
14
15
  end
15
16
 
16
17
  # Compile Ruby source code to JavaScript
@@ -18,7 +19,7 @@ module Opal
18
19
  def compile(source, file_path)
19
20
  begin
20
21
  # Use Opal::Builder and add the file's directory to load paths
21
- builder = Opal::Builder.new
22
+ builder = Opal::Builder.new(stubs: @stubs)
22
23
 
23
24
  # Add the directory containing the file to load paths
24
25
  # This allows require statements to work relative to the file
@@ -1,5 +1,5 @@
1
1
  module Opal
2
2
  module Vite
3
- VERSION = "0.3.1"
3
+ VERSION = "0.3.2"
4
4
  end
5
5
  end
data/lib/opal-vite.rb CHANGED
@@ -31,12 +31,13 @@ module Opal
31
31
  # @param file_path [String] The path to the Ruby file to compile
32
32
  # @param include_concerns [Boolean] Whether to include built-in concerns
33
33
  # @param source_map [Boolean] Whether to generate source maps
34
- def compile_for_vite(file_path, include_concerns: true, source_map: true)
34
+ # @param stubs [Array<String>] List of modules to stub (return empty implementations)
35
+ def compile_for_vite(file_path, include_concerns: true, source_map: true, stubs: [])
35
36
  # Temporarily override source map setting if specified
36
37
  original_source_map = config.source_map_enabled
37
38
  config.source_map_enabled = source_map
38
39
 
39
- compiler = Compiler.new(include_concerns: include_concerns)
40
+ compiler = Compiler.new(include_concerns: include_concerns, stubs: stubs)
40
41
  result = compiler.compile_file(file_path)
41
42
 
42
43
  # Output JSON to stdout for the Vite plugin to consume
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opal-vite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - stofu1234