DEV: Merge root JS packages (#25857)

Before this commit, we had a yarn package set up in the root directory and also in `app/assets/javascripts`. That meant two `yarn install` calls and two `node_modules` directories. This commit merges them both into the root location, and updates references to node_modules.

A previous attempt can be found at https://github.com/discourse/discourse/pull/21172. This commit re-uses that script to merge the `yarn.lock` files.

Co-authored-by: Jarek Radosz <jradosz@gmail.com>
This commit is contained in:
David Taylor
2024-02-26 13:45:58 +00:00
committed by GitHub
co-authored by Jarek Radosz
parent b3a1199493
commit 588a79c80c
26 changed files with 8863 additions and 11882 deletions
+1 -2
View File
@@ -41,8 +41,7 @@ class EmberCli < ActiveSupport::CurrentAttributes
def self.ember_version
@version ||=
begin
ember_source_package_raw =
File.read("#{Rails.root}/app/assets/javascripts/node_modules/ember-source/package.json")
ember_source_package_raw = File.read("#{Rails.root}/node_modules/ember-source/package.json")
JSON.parse(ember_source_package_raw)["version"]
end
end
+1 -1
View File
@@ -1,7 +1,7 @@
# frozen_string_literal: true
module HighlightJs
HIGHLIGHTJS_DIR ||= "#{Rails.root}/app/assets/javascripts/node_modules/@highlightjs/cdn-assets/"
HIGHLIGHTJS_DIR ||= "#{Rails.root}/node_modules/@highlightjs/cdn-assets/"
VERSION ||= 1 # bump to invalidate caches following core changes
def self.languages
+1 -3
View File
@@ -332,9 +332,7 @@ module JsLocaleHelper
@ctx ||=
begin
ctx = MiniRacer::Context.new(timeout: 15_000, ensure_gc_after_idle: 2000)
ctx.load(
"#{Rails.root}/app/assets/javascripts/node_modules/messageformat/messageformat.js",
)
ctx.load("#{Rails.root}/node_modules/messageformat/messageformat.js")
ctx
end
)
+5 -3
View File
@@ -66,10 +66,12 @@ module PrettyText
end
root_path = "#{Rails.root}/app/assets/javascripts"
ctx.load("#{root_path}/node_modules/loader.js/dist/loader/loader.js")
ctx.load("#{root_path}/node_modules/markdown-it/dist/markdown-it.js")
node_modules = "#{Rails.root}/node_modules"
md_node_modules = "#{Rails.root}/app/assets/javascripts/discourse-markdown-it/node_modules"
ctx.load("#{node_modules}/loader.js/dist/loader/loader.js")
ctx.load("#{md_node_modules}/markdown-it/dist/markdown-it.js")
ctx.load("#{root_path}/handlebars-shim.js")
ctx.load("#{root_path}/node_modules/xss/dist/xss.js")
ctx.load("#{node_modules}/xss/dist/xss.js")
ctx.load("#{Rails.root}/lib/pretty_text/vendor-shims.js")
ctx_load_directory(