klenod-plugin-javascript 0.0.14 → 0.0.15

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: bec41fc4fdb0a5e8767cef857e2e59516fa26f95f9c24c8a8889dd25010885c1
4
- data.tar.gz: a3f660de08c2bf94173cd16c8aa8552427bea2b1d91a611243e9b8b6ac80867f
3
+ metadata.gz: 3c8464e3833b7ea07785ee149f36573ef7eecaa594cbaa0e80db676b23f7b24e
4
+ data.tar.gz: 04a644220d927ccb75dce5da97368b2f6fda74a40b2fc442899da229bce261fa
5
5
  SHA512:
6
- metadata.gz: 5526827d67e6c8ef371e693399c7093f77cd2a3e2ca5f93e1ceb12688973185e8de4832feb0f9216a7c320a6b849476ccbead6f90fc087d5f2b604c8d30df070
7
- data.tar.gz: 4f691c8f0d52eb5f901e003a9a3a6334837a1123be320a215aa7223fd12efaf7823b3b623581d3bdbca2b4e87e1b8af7193ccb1a85449034e04342b563e5042d
6
+ metadata.gz: f5e7232182b2f214b46a9f6416700d8db21f1bada0c8b2c9abbd22a9d5b8d6abc6776d3c0e789add63ffcfbf41525bfad38214d2bb8d1a299001675843628c1f
7
+ data.tar.gz: 5f1d84b30baefca55d175f3350008850af922c6b9113230c4fc558154908f423684008f0d07071d8ce0c725fe4ae53453cdc042cc24d2e03fa6fe961c71d6764
@@ -73,6 +73,8 @@ module Klenod
73
73
  return super unless EXTENSIONS.include?(module_id.extname)
74
74
 
75
75
  custom_element = custom_element_module?(module_id)
76
+ return analysis_transform(module_id, code, custom_element) if context.analysis?
77
+
76
78
  jsx_runtime_namespace = custom_element ? jsx_runtime_namespace(module_id) : nil
77
79
  transform =
78
80
  begin
@@ -109,6 +111,22 @@ module Klenod
109
111
  )
110
112
  end
111
113
 
114
+ # Analysis only needs the module graph: imports are scanned without
115
+ # compiling, and the missing javascript_source makes finalize skip
116
+ # import rewriting and asset emission.
117
+ def analysis_transform(module_id, code, custom_element)
118
+ imports = Parser::FallbackScanner.new(code, module_id.to_s).imports
119
+
120
+ Klenod::Build::TransformResult.new(
121
+ module_source(nil),
122
+ build_dependencies(module_id, imports),
123
+ nil,
124
+ [],
125
+ [],
126
+ {javascript_imports: imports, javascript_custom_element: custom_element}
127
+ )
128
+ end
129
+
112
130
  def finalize(module_id, result, resolved_dependencies, dependency_records, context)
113
131
  source = result.metadata[:javascript_source]
114
132
  original_source = result.metadata[:javascript_original_source]
@@ -90,7 +90,7 @@ module Klenod
90
90
  return nil unless module_id.scheme == SCHEME
91
91
 
92
92
  path = absolute_path(module_id, context)
93
- LoadResult.new(path.read(encoding: "UTF-8"), Hashing.file_hexdigest(path), nil)
93
+ LoadResult.new(path.read(encoding: "UTF-8"), context.analysis? ? Hashing.file_key(path) : Hashing.file_hexdigest(path), nil)
94
94
  end
95
95
 
96
96
  private
@@ -4,7 +4,7 @@ module Klenod
4
4
  module Build
5
5
  module Plugins
6
6
  module JavaScriptPlugin
7
- VERSION = "0.0.14"
7
+ VERSION = "0.0.15"
8
8
  end
9
9
  end
10
10
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: klenod-plugin-javascript
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrés Alin
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - '='
17
17
  - !ruby/object:Gem::Version
18
- version: 0.0.14
18
+ version: 0.0.15
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - '='
24
24
  - !ruby/object:Gem::Version
25
- version: 0.0.14
25
+ version: 0.0.15
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: rb_sys
28
28
  requirement: !ruby/object:Gem::Requirement