From d8c0ec4435db34b85f83a2e4799bc15b0469ef27 Mon Sep 17 00:00:00 2001 From: Jonathan Rochkind Date: Thu, 18 Jan 2024 15:47:08 -0500 Subject: [PATCH] all imports should be relative, so individual files can still be imported from blacklight-frontend npm package eg local app might import 'blacklight-frontend/app/javascript/blacklight/core'; import 'blacklight-frontend/app/javascript/blacklight/modal'; or import Blacklight from 'blacklight-frontend/app/javascript/blacklight/core' import Modal from 'blacklight-frontend/app/javascript/blacklight/modal'; --- app/javascript/blacklight/bookmark_toggle.js | 2 +- app/javascript/blacklight/index.js | 15 ++++++++++----- app/javascript/blacklight/modal.js | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app/javascript/blacklight/bookmark_toggle.js b/app/javascript/blacklight/bookmark_toggle.js index 7303d730f..52302712f 100644 --- a/app/javascript/blacklight/bookmark_toggle.js +++ b/app/javascript/blacklight/bookmark_toggle.js @@ -1,4 +1,4 @@ -import CheckboxSubmit from 'blacklight/checkbox_submit' +import CheckboxSubmit from './checkbox_submit.js' const BookmarkToggle = (e) => { if (e.target.matches('[data-checkboxsubmit-target="checkbox"]')) { diff --git a/app/javascript/blacklight/index.js b/app/javascript/blacklight/index.js index 0fe8e2272..9d30f8f91 100644 --- a/app/javascript/blacklight/index.js +++ b/app/javascript/blacklight/index.js @@ -1,8 +1,13 @@ -import BookmarkToggle from 'blacklight/bookmark_toggle' -import ButtonFocus from 'blacklight/button_focus' -import Modal from 'blacklight/modal' -import SearchContext from 'blacklight/search_context' -import Core from 'blacklight/core' +// ALL imports in this dir, including in files imported, should be RELATIVE +// paths to keep things working in the various ways these files get used, at +// both compile time and npm package run time. + +import BookmarkToggle from './bookmark_toggle.js' +import ButtonFocus from './button_focus.js' +import Modal from './modal.js' +import SearchContext from './search_context.js' +import Core from './core.js' + export default { BookmarkToggle, diff --git a/app/javascript/blacklight/modal.js b/app/javascript/blacklight/modal.js index f1b74c457..2ad744539 100644 --- a/app/javascript/blacklight/modal.js +++ b/app/javascript/blacklight/modal.js @@ -52,7 +52,7 @@ can be a turbo-stream that defines some HTML fragementsand where on the page to put them: https://turbo.hotwired.dev/handbook/streams */ -import ModalForm from 'blacklight/modalForm' +import ModalForm from './modalForm.js' const Modal = (() => { const modal = {}