actionview-svelte-handler 0.5.7 → 0.6.0

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: 35a9952571d74905f67d9219dd86b759f2ac7b11c42fc68a0817f964247fa0d4
4
- data.tar.gz: be744cb8c46cfaafe8e4d3a707499038eb6f3200f0256cc947d766ed325d0d08
3
+ metadata.gz: 3c662bff173e3c32b2785f35eec52ac42e05abb82e6572c900ecaf86dae1d8ac
4
+ data.tar.gz: a076f194d83d7742d76483d8ab789f283838589b2fb728386123dd070523592e
5
5
  SHA512:
6
- metadata.gz: c7ca8ce660365595737c2f60e04b6c027a11f879e540f3af405d31fe168caf58914cb7b7e1a74c08c4ee74e2c226d01c5cb45b39944d981b5eb564074a25c5b2
7
- data.tar.gz: 28fbb9843d9893b9a92a03c26296e7fe3271548ceea5a5e2a559d578d3ec5ff545a3de7f0076e0c62b7605b9494d9996ef397130186313f70030427a4ff41c7b
6
+ metadata.gz: 83ca34a75800e1eab54d46885932a4a70e2828aec25f2b98177955ac357811f3024516826c438902fa177333b1f1504286f39dd83ffe6f539e54bd2a6d915e94
7
+ data.tar.gz: 264abb20627100eb9e4ed8f5f2417a752c12a397bc77494f6583a2dceb48aed2bbe5b25eac9d0174787cc7992f9df4dfb5113be06ab274205f21d99b9b3409b0
data/Gemfile.lock CHANGED
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- actionview-svelte-handler (0.5.7)
4
+ actionview-svelte-handler (0.6.0)
5
5
  rails (~> 7.0)
6
+ zeitwerk (~> 2)
6
7
 
7
8
  GEM
8
9
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- <img src="https://codeberg.org/reesericci/actionview-svelte-handler/raw/branch/main/svelte-on-rails.png" width="100px">
1
+ <img src="https://codeberg.org/reesericci/actionview-svelte-handler/raw/branch/main/docs/public/logo.png" width="100px">
2
2
 
3
3
  # `actionview-svelte-handler`
4
4
 
@@ -2,6 +2,7 @@ require_relative "lib/svelte/version"
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "actionview-svelte-handler"
5
+ spec.autorequire = "svelte"
5
6
  spec.version = Svelte::VERSION
6
7
  spec.authors = ["reesericci"]
7
8
  spec.email = ["me@reeseric.ci"]
@@ -18,4 +19,6 @@ Gem::Specification.new do |spec|
18
19
  end
19
20
 
20
21
  spec.add_runtime_dependency "rails", "~> 7.0"
22
+
23
+ spec.add_dependency "zeitwerk", "~> 2"
21
24
  end
@@ -0,0 +1 @@
1
+ require "svelte"
@@ -9,7 +9,8 @@ module Svelte
9
9
  insert_into_file "app/views/layouts/application.html.erb",
10
10
  "\n <%= svelte_tags %>",
11
11
  after: "<head>"
12
- `npm install #{Gem::Specification.find_by_name("actionview-svelte-handler").gem_dir} --install-links --save=false`
12
+ `npm link #{Gem::Specification.find_by_name("actionview-svelte-handler").gem_dir} --save`
13
+ `npm install`
13
14
  end
14
15
  end
15
16
  end
data/lib/svelte/errors.rb CHANGED
@@ -1,148 +1,150 @@
1
1
  require "active_support/syntax_error_proxy"
2
2
  require "action_view/template/error"
3
3
  module Svelte
4
- class CompilerError < ActiveSupport::SyntaxErrorProxy # steep:ignore UnknownConstant
5
- attr_accessor :location, :suggestion, :template
6
-
7
- def initialize(message, location)
8
- @location = location
9
- @sugggestion = @location.dig(:suggestion) || ""
10
- # steep:ignore:start
11
- super(message) # : self
12
- # steep:ignore:end
13
- end
14
-
15
- def message
16
- to_s
17
- end
18
-
19
- def backtrace
20
- if suggestion
21
- ["#{Rails.root.join location[:file]}:#{location[:line]}:#{message}, #{suggestion}"] + caller
22
- else
23
- ["#{Rails.root.join location[:file]}:#{location[:line]}:#{message}"] + caller
4
+ module Errors
5
+ class CompilerError < ActiveSupport::SyntaxErrorProxy # steep:ignore UnknownConstant
6
+ attr_accessor :location, :suggestion, :template
7
+
8
+ def initialize(message, location)
9
+ @location = location
10
+ @sugggestion = @location.dig(:suggestion) || ""
11
+ # steep:ignore:start
12
+ super(message) # : self
13
+ # steep:ignore:end
24
14
  end
25
- end
26
-
27
- def cause
28
- nil
29
- end
30
-
31
- def bindings
32
- [template.send(:binding)]
33
- end
34
-
35
- def backtrace_locations
36
- traces = backtrace.map { |trace|
37
- file, line = trace.match(/^(.+?):(\d+).*$/, &:captures) || trace
38
- ActiveSupport::SyntaxErrorProxy::BacktraceLocation.new(file, line.to_i, trace) # steep:ignore UnknownConstant
39
- }
40
-
41
- traces.map { |loc| ActiveSupport::SyntaxErrorProxy::BacktraceLocationProxy.new(loc, self) } # steep:ignore UnknownConstant
42
- end
43
-
44
- def annotated_source_code
45
- location[:lineText].split("\n").map.with_index(1) { |line, index|
46
- indentation = " " * 4
47
- "#{index}:#{indentation}#{line}"
48
- }
49
- end
50
- end
51
-
52
- class TemplateError < StandardError
53
- attr_reader :cause, :template
54
-
55
- SOURCE_CODE_RADIUS = 3
56
-
57
- def initialize(template, error)
58
- raise("Did not provide cause error") unless error
59
- @cause = error
60
-
61
- raise("Did not provide template") unless template
62
- @template, @sub_templates = template, nil
63
-
64
- raise("Cause error is nil for TemplateError") unless @cause
65
- @cause.template = template
66
-
67
- # steep:ignore:start
68
- super(@cause.message) # : self
69
- # steep:ignore:end
70
- end
71
-
72
- def message
73
- @cause.message
74
- end
75
-
76
- def annotated_source_code
77
- @cause.annotated_source_code
78
- end
79
-
80
- # Following is copypasta-ed from ActionView::Template::Error
81
- def backtrace
82
- @cause.backtrace
83
- end
84
-
85
- def backtrace_locations
86
- @cause.backtrace_locations
87
- end
88
-
89
- def file_name
90
- @template.identifier
91
- end
92
-
93
- def sub_template_message
94
- if @sub_templates
95
- "Trace of template inclusion: " +
96
- @sub_templates.collect(&:inspect).join(", ")
97
- else
98
- ""
15
+
16
+ def message
17
+ to_s
99
18
  end
100
- end
101
-
102
- def source_extract(indentation = 0)
103
- return [] unless (num = line_number)
104
- num = num.to_i
105
-
106
- source_code = @template.encode!.split("\n")
107
-
108
- start_on_line = [num - SOURCE_CODE_RADIUS - 1, 0].max
109
- end_on_line = [num + SOURCE_CODE_RADIUS - 1, source_code.length].min
110
-
111
- indent = end_on_line.to_s.size + indentation
112
- return [] unless (source_code = source_code[start_on_line..end_on_line])
113
-
114
- formatted_code_for(source_code, start_on_line, indent)
115
- end
116
-
117
- def sub_template_of(template_path)
118
- @sub_templates ||= []
119
- @sub_templates << template_path
120
- end
121
-
122
- def line_number
123
- @line_number ||=
124
- if file_name
125
- regexp = /#{Regexp.escape File.basename(file_name)}:(\d+)/
126
- $1 if message =~ regexp || backtrace.find { |line| line =~ regexp }
19
+
20
+ def backtrace
21
+ if suggestion
22
+ ["#{Rails.root.join location[:file]}:#{location[:line]}:#{message}, #{suggestion}"] + caller
23
+ else
24
+ ["#{Rails.root.join location[:file]}:#{location[:line]}:#{message}"] + caller
127
25
  end
26
+ end
27
+
28
+ def cause
29
+ nil
30
+ end
31
+
32
+ def bindings
33
+ [template.send(:binding)]
34
+ end
35
+
36
+ def backtrace_locations
37
+ traces = backtrace.map { |trace|
38
+ file, line = trace.match(/^(.+?):(\d+).*$/, &:captures) || trace
39
+ ActiveSupport::SyntaxErrorProxy::BacktraceLocation.new(file, line.to_i, trace) # steep:ignore UnknownConstant
40
+ }
41
+
42
+ traces.map { |loc| ActiveSupport::SyntaxErrorProxy::BacktraceLocationProxy.new(loc, self) } # steep:ignore UnknownConstant
43
+ end
44
+
45
+ def annotated_source_code
46
+ location[:lineText].split("\n").map.with_index(1) { |line, index|
47
+ indentation = " " * 4
48
+ "#{index}:#{indentation}#{line}"
49
+ }
50
+ end
128
51
  end
129
-
130
- private
131
-
132
- def source_location
133
- if line_number
134
- "on line ##{line_number} of "
135
- else
136
- "in "
137
- end + file_name
138
- end
139
-
140
- def formatted_code_for(source_code, line_counter, indent)
141
- raise("line counter is nil") if line_counter.nil?
142
- indent_template = "%#{indent}s: %s"
143
- source_code.map do |line|
144
- line_counter += 1
145
- indent_template % [line_counter, line]
52
+
53
+ class TemplateError < StandardError
54
+ attr_reader :cause, :template
55
+
56
+ SOURCE_CODE_RADIUS = 3
57
+
58
+ def initialize(template, error)
59
+ raise("Did not provide cause error") unless error
60
+ @cause = error
61
+
62
+ raise("Did not provide template") unless template
63
+ @template, @sub_templates = template, nil
64
+
65
+ raise("Cause error is nil for TemplateError") unless @cause
66
+ @cause.template = template
67
+
68
+ # steep:ignore:start
69
+ super(@cause.message) # : self
70
+ # steep:ignore:end
71
+ end
72
+
73
+ def message
74
+ @cause.message
75
+ end
76
+
77
+ def annotated_source_code
78
+ @cause.annotated_source_code
79
+ end
80
+
81
+ # Following is copypasta-ed from ActionView::Template::Error
82
+ def backtrace
83
+ @cause.backtrace
84
+ end
85
+
86
+ def backtrace_locations
87
+ @cause.backtrace_locations
88
+ end
89
+
90
+ def file_name
91
+ @template.identifier
92
+ end
93
+
94
+ def sub_template_message
95
+ if @sub_templates
96
+ "Trace of template inclusion: " +
97
+ @sub_templates.collect(&:inspect).join(", ")
98
+ else
99
+ ""
100
+ end
101
+ end
102
+
103
+ def source_extract(indentation = 0)
104
+ return [] unless (num = line_number)
105
+ num = num.to_i
106
+
107
+ source_code = @template.encode!.split("\n")
108
+
109
+ start_on_line = [num - SOURCE_CODE_RADIUS - 1, 0].max
110
+ end_on_line = [num + SOURCE_CODE_RADIUS - 1, source_code.length].min
111
+
112
+ indent = end_on_line.to_s.size + indentation
113
+ return [] unless (source_code = source_code[start_on_line..end_on_line])
114
+
115
+ formatted_code_for(source_code, start_on_line, indent)
116
+ end
117
+
118
+ def sub_template_of(template_path)
119
+ @sub_templates ||= []
120
+ @sub_templates << template_path
121
+ end
122
+
123
+ def line_number
124
+ @line_number ||=
125
+ if file_name
126
+ regexp = /#{Regexp.escape File.basename(file_name)}:(\d+)/
127
+ $1 if message =~ regexp || backtrace.find { |line| line =~ regexp }
128
+ end
129
+ end
130
+
131
+ private
132
+
133
+ def source_location
134
+ if line_number
135
+ "on line ##{line_number} of "
136
+ else
137
+ "in "
138
+ end + file_name
139
+ end
140
+
141
+ def formatted_code_for(source_code, line_counter, indent)
142
+ raise("line counter is nil") if line_counter.nil?
143
+ indent_template = "%#{indent}s: %s"
144
+ source_code.map do |line|
145
+ line_counter += 1
146
+ indent_template % [line_counter, line]
147
+ end
146
148
  end
147
149
  end
148
150
  end
@@ -1,5 +1,6 @@
1
1
  require "erb"
2
2
  require "svelte/helpers"
3
+ require "ostruct"
3
4
 
4
5
  module Svelte
5
6
  DISCARD_PROPS = %w[lookup_context view_renderer current_template output_buffer view_flow rendered_format marked_for_same_origin_verification virtual_path]
@@ -13,50 +14,53 @@ module Svelte
13
14
  digest = Digest::SHA256.base64digest(source)
14
15
 
15
16
  <<-RUBY
16
- template = ObjectSpace._id2ref(#{template.object_id})
17
-
18
- Svelte.props.merge!(
19
- instance_values.reject { |k,v|
20
- k.start_with?("_") || Svelte::DISCARD_PROPS.include?(k)
21
- }
22
- ) { |key,old,new| old }
23
-
24
- Svelte.props.deep_symbolize_keys!
25
-
26
- if local_assigns.dig(:svelte) == nil
27
- local_assigns[:svelte] = {}
28
- end
29
-
30
- assembler = nil
31
-
32
- assembler = Tempfile.new(['assembler', ".mjs"], '#{Svelte.gem_dir}/tmp')
17
+ Dir.mktmpdir("svelte", Rails.root.join('tmp')) do |dir|
18
+ template = OpenStruct.new(JSON.parse('#{template.to_json}').deep_symbolize_keys)
33
19
 
34
- assembler.write(ERB.new(File.read('#{Svelte.gem_dir}/lib/svelte/templates/assembler.js.erb')).result_with_hash({
35
- path: '#{Rails.root.join template.identifier}',
36
- locals: local_assigns,
37
- compiled_client: j(Rails.cache.read('svelte/template/client' + '#{digest}')),
38
- compiled_server: j(Rails.cache.read('svelte/template/server' + '#{digest}')),
39
- ssr: Svelte.precedence(local_assigns.dig(:svelte, :ssr), template.variant.nil? ? nil : (template.variant == "server"), Svelte.ssr)
40
- }))
41
-
42
- assembler.rewind
20
+ Svelte.props.merge!(
21
+ instance_values.reject { |k,v|
22
+ k.start_with?("_") || Svelte::DISCARD_PROPS.include?(k)
23
+ }
24
+ ) { |key,old,new| old }
25
+
26
+ Svelte.props.deep_symbolize_keys!
27
+
28
+ if local_assigns.dig(:svelte) == nil
29
+ local_assigns[:svelte] = {}
30
+ end
31
+
32
+ assembler = nil
33
+
34
+ assembler = Tempfile.new(['assembler', ".mjs"], dir)
35
+
36
+ assembler.write(ERB.new(File.read('#{Svelte.gem_dir}/lib/svelte/templates/assembler.js.erb')).result_with_hash({
37
+ path: '#{Rails.root.join template.identifier}',
38
+ locals: local_assigns,
39
+ compiled_client: j(Rails.cache.read('svelte/template/client' + '#{digest}')),
40
+ compiled_server: j(Rails.cache.read('svelte/template/server' + '#{digest}')),
41
+ ssr: Svelte.precedence(local_assigns.dig(:svelte, :ssr), template.variant.nil? ? nil : (template.variant == "server"), Svelte.ssr)
42
+ }))
43
+
44
+ assembler.rewind
43
45
 
44
- result = JSON.parse(`NODE_NO_WARNINGS=1 node --experimental-vm-modules \#{assembler.path}`).deep_symbolize_keys
45
-
46
- if result[:error]
47
- e = Svelte::CompilerError.new(result.dig(:error, :text), result.dig(:error, :location))
48
- raise Svelte::TemplateError.new(template, e)
46
+ result = JSON.parse(`NODE_PATH=#{Rails.root.join("node_modules")} NODE_NO_WARNINGS=1 node --experimental-vm-modules \#{assembler.path}`).deep_symbolize_keys
47
+
48
+ if result[:error]
49
+ e = Svelte::Errors::CompilerError.new(result.dig(:error, :text), result.dig(:error, :location))
50
+ raise Svelte::Errors::TemplateError.new(template, e)
51
+ end
52
+
53
+ assembler&.close
54
+ assembler&.unlink
55
+
56
+ Rails.cache.write("svelte/template/client/" + '#{digest}', result[:compiled][:client], expires_in: 14.days)
57
+ Rails.cache.write("svelte/template/server/" + '#{digest}', result[:compiled][:server], expires_in: 14.days)
58
+
59
+ content_for(:head, (result.dig(:server, :head) || "").html_safe)
60
+
61
+ ERB.new(File.read("#{Svelte.gem_dir}/lib/svelte/templates/island.html.erb")).result_with_hash({ result:, locals: local_assigns, digest: "#{digest}", bind: binding })
62
+
49
63
  end
50
-
51
- assembler&.close
52
- assembler&.unlink
53
-
54
- Rails.cache.write("svelte/template/client/" + '#{digest}', result[:compiled][:client], expires_in: 14.days)
55
- Rails.cache.write("svelte/template/server/" + '#{digest}', result[:compiled][:server], expires_in: 14.days)
56
-
57
- content_for(:head, (result.dig(:server, :head) || "").html_safe)
58
-
59
- ERB.new(File.read("#{Svelte.gem_dir}/lib/svelte/templates/island.html.erb")).result_with_hash({ result:, locals: local_assigns, digest: "#{digest}", bind: binding })
60
64
  RUBY
61
65
  end
62
66
 
@@ -9,7 +9,7 @@ module Svelte
9
9
  window.props = readable(JSON.parse("#{j(Svelte.props.to_json)}"))
10
10
  JS
11
11
 
12
- content_for(:head) + "\n" + tag.script(js.html_safe, type: "module") # steep:ignore RequiredBlockMissing
12
+ ((content_for(:head).presence || "") + "\n" + tag.script(js.html_safe, type: "module")).html_safe # steep:ignore RequiredBlockMissing
13
13
  end
14
14
 
15
15
  delegate :destructure_attrs, to: :class
@@ -6,10 +6,15 @@
6
6
 
7
7
  import { readable } from "svelte/store";
8
8
  import { importFromStringSync } from "module-from-string";
9
- import * as esbuild from "esbuild";
10
- import sveltePlugin from "esbuild-svelte";
11
9
  import { sveltePreprocess } from "svelte-preprocess";
12
10
  import * as recast from "recast";
11
+ import { rollup } from "rollup";
12
+ import svelte from "rollup-plugin-svelte";
13
+ import alias from "@rollup/plugin-alias";
14
+ import commonjs from "@rollup/plugin-commonjs";
15
+ import { nodeResolve } from "@rollup/plugin-node-resolve";
16
+ import virtual from "@rollup/plugin-virtual";
17
+ import swc from "@rollup/plugin-swc";
13
18
  class Builder {
14
19
  path;
15
20
  props;
@@ -18,9 +23,10 @@ class Builder {
18
23
  ssr;
19
24
  workingDir;
20
25
  preprocess;
21
- constructor(path, props, locals, client, server, ssr, workingDir, preprocess) {
26
+ pathAliases;
27
+ constructor(path, props, locals, client, server, ssr, workingDir, preprocess, pathAliases) {
22
28
  this.path = path;
23
- this.props = readable(props);
29
+ this.props = readable(Object.assign(props, locals, props));
24
30
  this.locals = locals;
25
31
  this.compiled = {
26
32
  client,
@@ -29,45 +35,64 @@ class Builder {
29
35
  this.ssr = ssr;
30
36
  this.workingDir = workingDir;
31
37
  this.preprocess = preprocess;
38
+ this.pathAliases = pathAliases;
32
39
  }
33
- async bundle(generate, sveltePath = "svelte") {
34
- const bundle = await esbuild.build({
35
- entryPoints: [this.path],
36
- mainFields: ["svelte", "browser", "module", "main"],
37
- conditions: ["svelte", "browser"],
38
- absWorkingDir: this.workingDir,
39
- write: false,
40
- outfile: "component.js",
41
- bundle: true,
42
- format: "esm",
43
- metafile: true,
40
+ async bundle(generate) {
41
+ const bundle = (await (await rollup({
42
+ input: "entry",
43
+ output: {
44
+ format: "esm",
45
+ sourcemap: false
46
+ },
47
+ watch: {
48
+ skipWrite: true
49
+ },
44
50
  plugins: [
45
- // @ts-expect-error
46
- sveltePlugin({
51
+ // @ts-expect-error see https://github.com/rollup/plugins/issues/1662
52
+ virtual({
53
+ entry: `import App from '${this.path}'; export default App`
54
+ }),
55
+ // @ts-expect-error see https://github.com/rollup/plugins/issues/1662
56
+ svelte({
47
57
  compilerOptions: {
48
58
  generate,
49
59
  css: "injected",
50
- hydratable: true,
51
- sveltePath
60
+ hydratable: true
52
61
  },
62
+ emitCss: false,
53
63
  preprocess: sveltePreprocess(this.preprocess),
54
- filterWarnings: (warning) => {
55
- if (warning.code === "missing-declaration" && warning.message.includes("'props'")) {
56
- return false;
64
+ onwarn: (warning, handler) => {
65
+ if (warning.code === "missing-declaration" && warning.message.includes("'props'")) return;
66
+ handler(warning);
67
+ }
68
+ }),
69
+ // @ts-expect-error see https://github.com/rollup/plugins/issues/1662
70
+ alias({
71
+ entries: Object.entries(this.pathAliases || {}).map((k, v) => {
72
+ return new Object({ find: k, replacement: v });
73
+ })
74
+ }),
75
+ // @ts-expect-error see https://github.com/rollup/plugins/issues/1662
76
+ commonjs(),
77
+ nodeResolve({
78
+ browser: true,
79
+ exportConditions: ["svelte"],
80
+ extensions: [".svelte"]
81
+ }),
82
+ // @ts-expect-error see https://github.com/rollup/plugins/issues/1662
83
+ swc({
84
+ swc: {
85
+ jsc: {
86
+ target: "es6"
57
87
  }
58
- return true;
59
88
  }
60
89
  })
61
90
  ]
62
- });
63
- const throwables = [].concat(bundle.errors, bundle.warnings);
64
- if (throwables.length > 0) {
65
- throw throwables[0];
66
- }
67
- return bundle.outputFiles[0].text;
91
+ })).generate({ format: "esm", sourcemap: "inline" })).output;
92
+ return bundle[0].code;
68
93
  }
69
94
  async client() {
70
- return this.compiled?.client || this.standardizeClient(await this.bundle("dom", "https://esm.sh/svelte"));
95
+ return this.compiled?.client || this.standardizeClient(await this.bundle("dom"));
71
96
  }
72
97
  standardizeClient(code) {
73
98
  const ast = recast.parse(code);
@@ -4,6 +4,9 @@ require "svelte/helpers"
4
4
  module Svelte
5
5
  class Railtie < ::Rails::Railtie
6
6
  initializer "svelte" do |app|
7
+ `npm link #{Gem::Specification.find_by_name("actionview-svelte-handler").gem_dir} --save`
8
+ `npm install --install-links`
9
+
7
10
  ActiveSupport.on_load :action_view do
8
11
  ActionView::Template.register_template_handler :svelte, Svelte::Handler
9
12
  ActionView::Base.send :include, Svelte::Helpers
@@ -1,4 +1,4 @@
1
- import Builder from "<%= "#{Svelte.gem_dir}/lib/svelte/js/builder.js" %>";
1
+ import Builder from "actionview-svelte-handler";
2
2
 
3
3
  const bob = new Builder(
4
4
  '<%= path %>',
@@ -8,7 +8,8 @@ const bob = new Builder(
8
8
  '<%= compiled_server || "" %>',
9
9
  <%= ssr %>,
10
10
  '<%= Rails.root %>',
11
- JSON.parse('<%= Svelte.preprocess.to_json || "{}" %>')
11
+ JSON.parse('<%= Svelte.preprocess.to_json || "{}" %>'),
12
+ JSON.parse('<%= Svelte.aliases.to_json || "{}" %>')
12
13
  )
13
14
 
14
15
  const built = await bob.build()
@@ -1,3 +1,3 @@
1
1
  module Svelte
2
- VERSION = "0.5.7"
2
+ VERSION = "0.6.0"
3
3
  end
data/lib/svelte.rb CHANGED
@@ -1,11 +1,12 @@
1
1
  require "active_support/core_ext"
2
- require "svelte/variabilization"
3
- require "svelte/railtie"
4
- require "svelte/errors"
5
- require "svelte/helpers"
6
- require "svelte/handler"
7
- require "svelte/version"
8
2
  require "active_support/isolated_execution_state"
3
+ require "zeitwerk"
4
+
5
+ loader = Zeitwerk::Loader.for_gem
6
+ loader.ignore("#{__dir__}/generators")
7
+ loader.ignore("#{__dir__}/actionview-svelte-handler.rb")
8
+
9
+ loader.setup
9
10
 
10
11
  module Svelte
11
12
  include ActionView::Helpers::JavaScriptHelper
@@ -38,3 +39,5 @@ module Svelte
38
39
  nil
39
40
  end
40
41
  end
42
+
43
+ loader.eager_load