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 +4 -4
- data/lib/opal/vite/compiler.rb +2 -1
- data/lib/opal/vite/version.rb +1 -1
- data/lib/opal-vite.rb +3 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5491e78891b38d4e302b86941b5bce99574452f0e361bad6c109711f9e0e247d
|
|
4
|
+
data.tar.gz: 70c7080aa2c98fc641c28e63c077aed1a601705a0c3b380031c0e822b7a6f1be
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5951f4e205e1c6415062830331007db5592a51d8672f025a02cbee24ac4eef2239895c5f6ceb35e2a7c3b96187be54e80e85c032671e45640b815011e3fc98b7
|
|
7
|
+
data.tar.gz: c36245a857819c721caa5a5ab98f5beaeea97babf49168018abe84a104864696c19c3f34bd7393c9a2076b81599c3702babbd208e35a619239ae7336955a6905
|
data/lib/opal/vite/compiler.rb
CHANGED
|
@@ -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
|
data/lib/opal/vite/version.rb
CHANGED
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
|
-
|
|
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
|