Fix raw node_modules paths

This commit is contained in:
Jarek Radosz 2022-11-04 00:05:55 +01:00
parent a9cb77f687
commit 2b396cdb2c
No known key found for this signature in database
GPG Key ID: 62D0FBAE5BF9B953
10 changed files with 52 additions and 29 deletions

View File

@ -18,9 +18,10 @@ module.exports = function prettyTextEngine(app) {
const engineTree = babelAddon.transpileTree(namespacedTree);
let markdownIt = funnel("../node_modules/markdown-it/dist", {
let markdownIt = funnel("../discourse/node_modules/markdown-it/dist", {
files: ["markdown-it.js"],
});
return concat(mergeTrees([engineTree, markdownIt]), {
inputFiles: ["**/*.js"],
outputFile: `assets/markdown-it-bundle.js`,

View File

@ -18,8 +18,8 @@
"dependencies": {
"@babel/core": "^7.19.6",
"@babel/standalone": "^7.20.1",
"@discourse/itsatrap": "^2.0.10",
"@discourse/backburner.js": "^2.7.1-0",
"@discourse/itsatrap": "^2.0.10",
"@ember/jquery": "^2.0.0",
"@ember/optional-features": "^2.0.0",
"@ember/render-modifiers": "^2.0.4",
@ -36,7 +36,7 @@
"@uppy/xhr-upload": "^2.1.2",
"a11y-dialog": "7.5.2",
"admin": "workspace:*",
"discourse-plugins": "workspace:*",
"babel-import-util": "^1.2.2",
"babel-plugin-ember-template-compilation": "^1.0.2",
"bootstrap": "3.4.1",
"broccoli-asset-rev": "^3.0.0",
@ -44,6 +44,7 @@
"discourse-common": "workspace:*",
"discourse-ensure-deprecation-order": "workspace:*",
"discourse-hbr": "workspace:*",
"discourse-plugins": "workspace:*",
"discourse-widget-hbs": "workspace:*",
"ember-auto-import": "^2.4.3",
"ember-auto-import-chunks-json-generator": "^1.0.0",
@ -70,6 +71,7 @@
"ember-test-selectors": "^6.0.0",
"eslint": "^8.26.0",
"eslint-plugin-qunit": "^6.2.0",
"handlebars": "^4.7.7",
"html-entities": "^2.3.3",
"js-yaml": "^4.1.0",
"jsdom": "^20.0.2",
@ -85,10 +87,13 @@
"sass": "^1.55.0",
"select-kit": "workspace:*",
"sinon": "^14.0.1",
"source-map": "^0.7.4",
"terser": "^5.15.1",
"tippy.js": "^6.3.7",
"virtual-dom": "^2.1.1",
"webpack": "^5.74.0",
"wizard": "workspace:*"
"wizard": "workspace:*",
"xss": "^1.0.14"
},
"engines": {
"node": "16.* || >= 18"

View File

@ -71,6 +71,7 @@ importers:
'@uppy/xhr-upload': ^2.1.2
a11y-dialog: 7.5.2
admin: workspace:*
babel-import-util: ^1.2.2
babel-plugin-ember-template-compilation: ^1.0.2
bootstrap: 3.4.1
broccoli-asset-rev: ^3.0.0
@ -105,6 +106,7 @@ importers:
ember-test-selectors: ^6.0.0
eslint: ^8.26.0
eslint-plugin-qunit: ^6.2.0
handlebars: ^4.7.7
html-entities: ^2.3.3
js-yaml: ^4.1.0
jsdom: ^20.0.2
@ -120,10 +122,13 @@ importers:
sass: ^1.55.0
select-kit: workspace:*
sinon: ^14.0.1
source-map: ^0.7.4
terser: ^5.15.1
tippy.js: ^6.3.7
virtual-dom: ^2.1.1
webpack: ^5.74.0
wizard: workspace:*
xss: ^1.0.14
dependencies:
'@babel/core': 7.19.6
'@babel/standalone': 7.20.1
@ -145,6 +150,7 @@ importers:
'@uppy/xhr-upload': 2.1.3_@uppy+core@2.3.4
a11y-dialog: 7.5.2
admin: link:../admin
babel-import-util: 1.2.2
babel-plugin-ember-template-compilation: 1.0.2
bootstrap: 3.4.1
broccoli-asset-rev: 3.0.0
@ -158,7 +164,7 @@ importers:
ember-auto-import-chunks-json-generator: 1.0.0_ember-auto-import@2.4.3
ember-buffered-proxy: 2.1.1_@babel+core@7.19.6
ember-cached-decorator-polyfill: 1.0.1_6w4ezvrlg7cuuzjx6jciook2c4
ember-cli: 3.28.6
ember-cli: 3.28.6_handlebars@4.7.7
ember-cli-app-version: 5.0.0
ember-cli-babel: 7.26.11
ember-cli-dependency-checker: 3.3.1_ember-cli@3.28.6
@ -179,6 +185,7 @@ importers:
ember-test-selectors: 6.0.0
eslint: 8.26.0
eslint-plugin-qunit: 6.2.0_eslint@8.26.0
handlebars: 4.7.7
html-entities: 2.3.3
js-yaml: 4.1.0
jsdom: 20.0.2
@ -194,10 +201,13 @@ importers:
sass: 1.55.0
select-kit: link:../select-kit
sinon: 14.0.1
source-map: 0.7.4
terser: 5.15.1
tippy.js: 6.3.7
virtual-dom: 2.1.1
webpack: 5.74.0
wizard: link:../wizard
xss: 1.0.14
discourse-common:
specifiers:
@ -4389,7 +4399,6 @@ packages:
bluebird: 3.7.2
handlebars: 4.7.7
mustache: 4.2.0
dev: true
/consolidate/0.16.0_mustache@4.2.0:
resolution: {integrity: sha512-Nhl1wzCslqXYTJVDyJCu3ODohy9OfBMB5uD2BiBTzd7w+QY0lBzafkR8y8755yMYHAaMD4NuzbAw03/xzfw+eQ==}
@ -4558,6 +4567,7 @@ packages:
dependencies:
bluebird: 3.7.2
mustache: 4.2.0
dev: true
/constants-browserify/1.0.0:
resolution: {integrity: sha512-xFxOwqIzR/e1k1gLiWEophSCMqXcwVHIH7akf7b/vxcUeGunlj3hvZaaqxwHsTgn+IndtkQJgSztIDWeumWJDQ==}
@ -5165,7 +5175,7 @@ packages:
ember-cli: ^3.2.0 || ^4.0.0
dependencies:
chalk: 2.4.2
ember-cli: 3.28.6
ember-cli: 3.28.6_handlebars@4.7.7
find-yarn-workspace-root: 1.2.1
is-git-url: 1.0.0
resolve: 1.22.1
@ -5542,6 +5552,7 @@ packages:
- velocityjs
- walrus
- whiskers
dev: true
/ember-cli/3.28.6_handlebars@4.7.7:
resolution: {integrity: sha512-aGHIDXM5KujhU+tHyfp1X5bUp3yj47sIWI0zgybyIw6vv6ErAu/eKWWMSib5PF8cQDdXG9vttBcXnvQ4QBNIPQ==}
@ -5697,7 +5708,6 @@ packages:
- velocityjs
- walrus
- whiskers
dev: true
/ember-compatibility-helpers/1.2.6_@babel+core@7.19.6:
resolution: {integrity: sha512-2UBUa5SAuPg8/kRVaiOfTwlXdeVweal1zdNPibwItrhR0IvPrXpaqwJDlEZnWKEoB+h33V0JIfiWleSG6hGkkA==}
@ -10149,6 +10159,11 @@ packages:
resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==}
engines: {node: '>=0.10.0'}
/source-map/0.7.4:
resolution: {integrity: sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA==}
engines: {node: '>= 8'}
dev: false
/sourcemap-codec/1.4.8:
resolution: {integrity: sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==}
dev: false
@ -10594,6 +10609,7 @@ packages:
- velocityjs
- walrus
- whiskers
dev: true
/testem/3.9.0_handlebars@4.7.7:
resolution: {integrity: sha512-YTxCYKj0cc8uUSKEziJtSC5T/pw4fQnY0ZXNOyvAFgrijfsN9NxmncJZOHLhPgFOuhbRd5i+DBQxw0Cpe0SEFg==}
@ -10686,7 +10702,6 @@ packages:
- velocityjs
- walrus
- whiskers
dev: true
/text-table/0.2.0:
resolution: {integrity: sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==}

View File

@ -25,7 +25,7 @@
<%= discourse_stylesheet_link_tag(:desktop, theme_id: nil) %>
<style>
<%= File.read("#{Rails.root}/app/assets/javascripts/node_modules/qunit/qunit/qunit.css") %>
<%= File.read("#{Rails.root}/app/assets/javascripts/discourse/node_modules/qunit/qunit/qunit.css") %>
</style>
<%- else %>
<style>

View File

@ -142,10 +142,10 @@ class DiscourseJsProcessor
JS
# define/require support
load_file_in_context(ctx, "node_modules/loader.js/dist/loader/loader.js")
load_file_in_context(ctx, "discourse/node_modules/loader.js/dist/loader/loader.js")
# Babel
load_file_in_context(ctx, "node_modules/@babel/standalone/babel.js")
load_file_in_context(ctx, "discourse/node_modules/@babel/standalone/babel.js")
ctx.eval <<~JS
globalThis.rawBabelTransform = function(){
return Babel.transform(...arguments).code;
@ -153,15 +153,15 @@ class DiscourseJsProcessor
JS
# Terser
load_file_in_context(ctx, "node_modules/source-map/dist/source-map.js")
load_file_in_context(ctx, "node_modules/terser/dist/bundle.min.js")
load_file_in_context(ctx, "discourse/node_modules/source-map/dist/source-map.js")
load_file_in_context(ctx, "discourse/node_modules/terser/dist/bundle.min.js")
# Template Compiler
load_file_in_context(ctx, "node_modules/ember-source/dist/ember-template-compiler.js")
load_file_in_context(ctx, "node_modules/babel-plugin-ember-template-compilation/src/plugin.js", wrap_in_module: "babel-plugin-ember-template-compilation/index")
load_file_in_context(ctx, "node_modules/babel-plugin-ember-template-compilation/src/expression-parser.js", wrap_in_module: "babel-plugin-ember-template-compilation/expression-parser")
load_file_in_context(ctx, "node_modules/babel-import-util/src/index.js", wrap_in_module: "babel-import-util")
load_file_in_context(ctx, "node_modules/ember-cli-htmlbars/lib/colocated-babel-plugin.js", wrap_in_module: "colocated-babel-plugin")
load_file_in_context(ctx, "discourse/node_modules/ember-source/dist/ember-template-compiler.js")
load_file_in_context(ctx, "discourse/node_modules/babel-plugin-ember-template-compilation/src/plugin.js", wrap_in_module: "babel-plugin-ember-template-compilation/index")
load_file_in_context(ctx, "discourse/node_modules/babel-plugin-ember-template-compilation/src/expression-parser.js", wrap_in_module: "babel-plugin-ember-template-compilation/expression-parser")
load_file_in_context(ctx, "discourse/node_modules/babel-import-util/src/index.js", wrap_in_module: "babel-import-util")
load_file_in_context(ctx, "discourse/node_modules/ember-cli-htmlbars/lib/colocated-babel-plugin.js", wrap_in_module: "colocated-babel-plugin")
# Widget HBS compiler
widget_hbs_compiler_source = File.read("#{Rails.root}/lib/javascripts/widget-hbs-compiler.js")
@ -178,7 +178,7 @@ class DiscourseJsProcessor
ctx.eval(widget_hbs_compiler_transpiled, filename: "widget-hbs-compiler.js")
# Raw HBS compiler
load_file_in_context(ctx, "node_modules/handlebars/dist/handlebars.js", wrap_in_module: "handlebars")
load_file_in_context(ctx, "discourse/node_modules/handlebars/dist/handlebars.js", wrap_in_module: "handlebars")
raw_hbs_transpiled = ctx.call(
"rawBabelTransform",

View File

@ -46,7 +46,7 @@ module EmberCli
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}/app/assets/javascripts/discourse/node_modules/ember-source/package.json")
JSON.parse(ember_source_package_raw)["version"]
end
end

View File

@ -6,7 +6,7 @@
module BarberEmberPrecompilerFreedomPatch
# Use the template compiler JS from node_modules
def ember_template_precompiler
@ember ||= File.new("app/assets/javascripts/node_modules/ember-source/dist/ember-template-compiler.js")
@ember ||= File.new("app/assets/javascripts/discourse/node_modules/ember-source/dist/ember-template-compiler.js")
end
# Apply a couple of extra shims for more recent ember-template-compilers

View File

@ -4,13 +4,15 @@
class Barber::Precompiler
def sources
[File.open("#{Rails.root}/app/assets/javascripts/node_modules/handlebars/dist/handlebars.js"),
precompiler]
[
File.open("#{Rails.root}/app/assets/javascripts/discourse/node_modules/handlebars/dist/handlebars.js"),
precompiler,
]
end
def precompiler
if !@precompiler
loader = File.read("#{Rails.root}/app/assets/javascripts/node_modules/loader.js/dist/loader/loader.js")
loader = File.read("#{Rails.root}/app/assets/javascripts/discourse/node_modules/loader.js/dist/loader/loader.js")
source = File.read("#{Rails.root}/app/assets/javascripts/discourse-common/addon/lib/raw-handlebars.js")
transpiled = DiscourseJsProcessor.transpile(source, "#{Rails.root}/app/assets/javascripts/", "discourse-common/lib/raw-handlebars")

View File

@ -94,13 +94,13 @@ module PrettyText
end
root_path = "#{Rails.root}/app/assets/javascripts/"
ctx_load(ctx, "#{root_path}/node_modules/loader.js/dist/loader/loader.js")
ctx_load(ctx, "#{root_path}/discourse/node_modules/loader.js/dist/loader/loader.js")
ctx_load(ctx, "#{root_path}/handlebars-shim.js")
ctx_load(ctx, "#{root_path}/node_modules/xss/dist/xss.js")
ctx_load(ctx, "#{root_path}/discourse/node_modules/xss/dist/xss.js")
ctx.load("#{Rails.root}/lib/pretty_text/vendor-shims.js")
ctx_load_directory(ctx, "pretty-text/addon")
ctx_load_directory(ctx, "pretty-text/engines/discourse-markdown")
ctx_load(ctx, "#{root_path}/node_modules/markdown-it/dist/markdown-it.js")
ctx_load(ctx, "#{root_path}/discourse/node_modules/markdown-it/dist/markdown-it.js")
apply_es6_file(ctx, root_path, "discourse-common/addon/lib/get-url")
apply_es6_file(ctx, root_path, "discourse-common/addon/lib/object")

View File

@ -102,7 +102,7 @@ RSpec.describe DiscourseJsProcessor do
let(:mini_racer) {
ctx = MiniRacer::Context.new
ctx.eval(File.open("#{Rails.root}/app/assets/javascripts/node_modules/handlebars/dist/handlebars.js").read)
ctx.eval(File.open("#{Rails.root}/app/assets/javascripts/discourse/node_modules/handlebars/dist/handlebars.js").read)
ctx.eval(helpers)
ctx
}