webpack: Remove resolve.modules override.

The minimal syntactic sugar it might provide isn’t worth the
unexpected side effects (including side effects on third party
modules).

For now, we allow zrequire to emulate the previous syntax in the Node
test suite, even though stealing part of the NPM namespace is
confusing.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
Anders Kaseorg 2019-06-20 16:59:21 -07:00 committed by Tim Abbott
parent 7e6bcbeac0
commit 1b94733953
6 changed files with 223 additions and 226 deletions

View File

@ -27,7 +27,7 @@ global.window = _.extend({}, windowObj, {
}, },
}); });
global.Dict = require('js/dict').Dict; global.Dict = require('../../static/js/dict').Dict;
// Create a helper function to avoid sneaky delays in tests. // Create a helper function to avoid sneaky delays in tests.
function immediate(f) { function immediate(f) {

View File

@ -21,7 +21,10 @@ exports.patch_builtin = function (name, val) {
exports.zrequire = function (name, fn) { exports.zrequire = function (name, fn) {
if (fn === undefined) { if (fn === undefined) {
fn = 'js/' + name; fn = '../../static/js/' + name;
} else if (/generated\/|js\/|third\//.test(fn)) {
// FIXME: Stealing part of the NPM namespace is confusing.
fn = '../../static/' + fn;
} }
delete require.cache[require.resolve(fn)]; delete require.cache[require.resolve(fn)];
var obj = require(fn); var obj = require(fn);

View File

@ -1,14 +1,14 @@
import "js/bundles/commons.js"; import "./commons.js";
// Import Third party libraries // Import Third party libraries
import "third/bootstrap-notify/js/bootstrap-notify.js"; import "../../third/bootstrap-notify/js/bootstrap-notify.js";
import "third/jquery-filedrop/jquery.filedrop.js"; import "../../third/jquery-filedrop/jquery.filedrop.js";
import "jquery-caret-plugin/src/jquery.caret.js"; import "jquery-caret-plugin/src/jquery.caret.js";
import "third/jquery-idle/jquery.idle.js"; import "../../third/jquery-idle/jquery.idle.js";
import "jquery-autosize"; import "jquery-autosize";
import "third/spectrum/spectrum.js"; import "../../third/spectrum/spectrum.js";
import "third/sockjs/sockjs-0.3.4.js"; import "../../third/sockjs/sockjs-0.3.4.js";
import "third/marked/lib/marked.js"; import "../../third/marked/lib/marked.js";
import "xdate/src/xdate.js"; import "xdate/src/xdate.js";
import "jquery-validation/dist/jquery.validate.js"; import "jquery-validation/dist/jquery.validate.js";
import "blueimp-md5/js/md5.js"; import "blueimp-md5/js/md5.js";
@ -21,213 +21,213 @@ import "flatpickr/dist/flatpickr.js";
import "flatpickr/dist/plugins/confirmDate/confirmDate.js"; import "flatpickr/dist/plugins/confirmDate/confirmDate.js";
import "error-stack-parser/dist/error-stack-parser.min.js"; import "error-stack-parser/dist/error-stack-parser.min.js";
import "sortablejs/Sortable.js"; import "sortablejs/Sortable.js";
import "generated/emoji/emoji_codes.js"; import "../../generated/emoji/emoji_codes.js";
import "generated/pygments_data.js"; import "../../generated/pygments_data.js";
// Import App JS // Import App JS
import "js/translations.js"; import "../translations.js";
import "js/feature_flags.js"; import "../feature_flags.js";
import "js/loading.js"; import "../loading.js";
import 'js/schema.js'; import "../schema.js";
import "js/util.js"; import "../util.js";
import "js/search_util.js"; import "../search_util.js";
import "js/keydown_util.js"; import "../keydown_util.js";
import "js/lightbox_canvas.js"; import "../lightbox_canvas.js";
import "js/rtl.js"; import "../rtl.js";
import "js/dict.ts"; import "../dict.ts";
import "js/scroll_util.js"; import "../scroll_util.js";
import "js/components.js"; import "../components.js";
import "js/feedback_widget.js"; import "../feedback_widget.js";
import "js/localstorage.js"; import "../localstorage.js";
import "js/drafts.js"; import "../drafts.js";
import "js/input_pill.js"; import "../input_pill.js";
import "js/user_pill.js"; import "../user_pill.js";
import "js/compose_pm_pill.js"; import "../compose_pm_pill.js";
import "js/channel.js"; import "../channel.js";
import "js/csrf.js"; import "../csrf.js";
import "js/setup.js"; import "../setup.js";
import "js/unread_ui.js"; import "../unread_ui.js";
import "js/unread_ops.js"; import "../unread_ops.js";
import "js/muting.js"; import "../muting.js";
import "js/muting_ui.js"; import "../muting_ui.js";
import "js/message_viewport.js"; import "../message_viewport.js";
import "js/rows.js"; import "../rows.js";
import "js/people.js"; import "../people.js";
import "js/user_groups.js"; import "../user_groups.js";
import "js/unread.js"; import "../unread.js";
import "js/topic_list.js"; import "../topic_list.js";
import "js/pm_list.js"; import "../pm_list.js";
import "js/pm_conversations.js"; import "../pm_conversations.js";
import "js/recent_senders.js"; import "../recent_senders.js";
import "js/stream_sort.js"; import "../stream_sort.js";
import "js/topic_generator.js"; import "../topic_generator.js";
import "js/top_left_corner.js"; import "../top_left_corner.js";
import "js/stream_list.js"; import "../stream_list.js";
import "js/topic_zoom.js"; import "../topic_zoom.js";
import "js/filter.js"; import "../filter.js";
import 'js/poll_widget.js'; import "../poll_widget.js";
import 'js/todo_widget.js'; import "../todo_widget.js";
import 'js/tictactoe_widget.js'; import "../tictactoe_widget.js";
import 'js/zform.js'; import "../zform.js";
import 'js/widgetize.js'; import "../widgetize.js";
import 'js/submessage.js'; import "../submessage.js";
import "js/fetch_status.js"; import "../fetch_status.js";
import "js/message_list_data.js"; import "../message_list_data.js";
import "js/message_list_view.js"; import "../message_list_view.js";
import "js/message_list.js"; import "../message_list.js";
import "js/message_live_update.js"; import "../message_live_update.js";
import "js/narrow_state.js"; import "../narrow_state.js";
import "js/narrow.js"; import "../narrow.js";
import "js/reload_state.js"; import "../reload_state.js";
import "js/reload.js"; import "../reload.js";
import "js/compose_fade.js"; import "../compose_fade.js";
import "js/fenced_code.js"; import "../fenced_code.js";
import "js/markdown.js"; import "../markdown.js";
import 'js/local_message.js'; import "../local_message.js";
import "js/echo.js"; import "../echo.js";
import "js/socket.js"; import "../socket.js";
import "js/sent_messages.js"; import "../sent_messages.js";
import "js/compose_state.js"; import "../compose_state.js";
import "js/compose_actions.js"; import "../compose_actions.js";
import "js/transmit.js"; import "../transmit.js";
import "js/zcommand.js"; import "../zcommand.js";
import "js/compose.js"; import "../compose.js";
import "js/upload.js"; import "../upload.js";
import "js/color_data.js"; import "../color_data.js";
import "js/stream_color.js"; import "../stream_color.js";
import "js/stream_data.js"; import "../stream_data.js";
import "js/topic_data.js"; import "../topic_data.js";
import "js/stream_muting.js"; import "../stream_muting.js";
import "js/stream_events.js"; import "../stream_events.js";
import "js/stream_create.js"; import "../stream_create.js";
import "js/stream_edit.js"; import "../stream_edit.js";
import "js/subs.js"; import "../subs.js";
import "js/message_edit.js"; import "../message_edit.js";
import "js/condense.js"; import "../condense.js";
import "js/resize.js"; import "../resize.js";
import "js/list_render.js"; import "../list_render.js";
import "js/floating_recipient_bar.js"; import "../floating_recipient_bar.js";
import "js/lightbox.js"; import "../lightbox.js";
import "js/ui_report.js"; import "../ui_report.js";
import "js/message_scroll.js"; import "../message_scroll.js";
import "js/info_overlay.js"; import "../info_overlay.js";
import "js/ui.js"; import "../ui.js";
import "js/night_mode.js"; import "../night_mode.js";
import "js/ui_util.js"; import "../ui_util.js";
import "js/pointer.js"; import "../pointer.js";
import "js/click_handlers.js"; import "../click_handlers.js";
import "js/settings_panel_menu.js"; import "../settings_panel_menu.js";
import "js/settings_toggle.js"; import "../settings_toggle.js";
import "js/scroll_bar.js"; import "../scroll_bar.js";
import "js/gear_menu.js"; import "../gear_menu.js";
import "js/copy_and_paste.js"; import "../copy_and_paste.js";
import "js/stream_popover.js"; import "../stream_popover.js";
import "js/popovers.js"; import "../popovers.js";
import "js/overlays.js"; import "../overlays.js";
import "js/typeahead_helper.js"; import "../typeahead_helper.js";
import "js/search_suggestion.js"; import "../search_suggestion.js";
import "js/search.js"; import "../search.js";
import "js/composebox_typeahead.js"; import "../composebox_typeahead.js";
import "js/navigate.js"; import "../navigate.js";
import "js/list_util.js"; import "../list_util.js";
import "js/hotkey.js"; import "../hotkey.js";
import "js/favicon.js"; import "../favicon.js";
import "js/notifications.js"; import "../notifications.js";
import "js/hash_util.js"; import "../hash_util.js";
import "js/hashchange.js"; import "../hashchange.js";
import "js/invite.js"; import "../invite.js";
import "js/message_flags.js"; import "../message_flags.js";
import "js/starred_messages.js"; import "../starred_messages.js";
import "js/alert_words.js"; import "../alert_words.js";
import "js/alert_words_ui.js"; import "../alert_words_ui.js";
import "js/attachments_ui.js"; import "../attachments_ui.js";
import "js/message_store.js"; import "../message_store.js";
import "js/message_util.js"; import "../message_util.js";
import "js/message_events.js"; import "../message_events.js";
import "js/message_fetch.js"; import "../message_fetch.js";
import "js/server_events.js"; import "../server_events.js";
import "js/server_events_dispatch.js"; import "../server_events_dispatch.js";
import "js/zulip.js"; import "../zulip.js";
import "js/presence.js"; import "../presence.js";
import "js/user_search.js"; import "../user_search.js";
import "js/user_status.js"; import "../user_status.js";
import "js/user_status_ui.js"; import "../user_status_ui.js";
import "js/buddy_data.js"; import "../buddy_data.js";
import "js/padded_widget.js"; import "../padded_widget.js";
import "js/buddy_list.js"; import "../buddy_list.js";
import "js/list_cursor.js"; import "../list_cursor.js";
import "js/activity.js"; import "../activity.js";
import "js/user_events.js"; import "../user_events.js";
import "js/colorspace.js"; import "../colorspace.js";
import "js/timerender.js"; import "../timerender.js";
import "js/tutorial.js"; import "../tutorial.js";
import "js/hotspots.js"; import "../hotspots.js";
import "js/templates.js"; import "../templates.js";
import "js/upload_widget.js"; import "../upload_widget.js";
import "js/avatar.js"; import "../avatar.js";
import "js/realm_icon.js"; import "../realm_icon.js";
import "js/realm_logo.js"; import "../realm_logo.js";
import 'js/reminder.js'; import "../reminder.js";
import 'js/confirm_dialog.js'; import "../confirm_dialog.js";
import "js/settings_account.js"; import "../settings_account.js";
import "js/settings_display.js"; import "../settings_display.js";
import "js/settings_notifications.js"; import "../settings_notifications.js";
import "js/settings_bots.js"; import "../settings_bots.js";
import "js/settings_muting.js"; import "../settings_muting.js";
import "js/settings_sections.js"; import "../settings_sections.js";
import "js/settings_emoji.js"; import "../settings_emoji.js";
import "js/settings_org.js"; import "../settings_org.js";
import "js/settings_users.js"; import "../settings_users.js";
import "js/settings_streams.js"; import "../settings_streams.js";
import "js/settings_linkifiers.js"; import "../settings_linkifiers.js";
import "js/settings_invites.js"; import "../settings_invites.js";
import "js/settings_user_groups.js"; import "../settings_user_groups.js";
import "js/settings_profile_fields.js"; import "../settings_profile_fields.js";
import "js/settings.js"; import "../settings.js";
import "js/admin.js"; import "../admin.js";
import "js/tab_bar.js"; import "../tab_bar.js";
import "js/emoji.js"; import "../emoji.js";
import "js/bot_data.js"; import "../bot_data.js";
import "js/reactions.js"; import "../reactions.js";
import "js/typing.js"; import "../typing.js";
import "js/typing_status.js"; import "../typing_status.js";
import "js/typing_data.js"; import "../typing_data.js";
import "js/typing_events.js"; import "../typing_events.js";
import "js/ui_init.js"; import "../ui_init.js";
import "js/emoji_picker.js"; import "../emoji_picker.js";
import "js/compose_ui.js"; import "../compose_ui.js";
import "js/panels.js"; import "../panels.js";
import 'js/settings_ui.js'; import "../settings_ui.js";
import 'js/search_pill.js'; import "../search_pill.js";
import 'js/search_pill_widget.js'; import "../search_pill_widget.js";
import 'js/stream_ui_updates.js'; import "../stream_ui_updates.js";
// Import Styles // Import Styles
import "third/bootstrap-notify/css/bootstrap-notify.css"; import "../../third/bootstrap-notify/css/bootstrap-notify.css";
import "third/spectrum/spectrum.css"; import "../../third/spectrum/spectrum.css";
import "katex/dist/katex.css"; import "katex/dist/katex.css";
import "flatpickr/dist/flatpickr.css"; import "flatpickr/dist/flatpickr.css";
import "flatpickr/dist/plugins/confirmDate/confirmDate.css"; import "flatpickr/dist/plugins/confirmDate/confirmDate.css";
import "styles/components.scss"; import "../../styles/components.scss";
import "styles/app_components.scss"; import "../../styles/app_components.scss";
import "styles/zulip.scss"; import "../../styles/zulip.scss";
import "styles/alerts.scss"; import "../../styles/alerts.scss";
import "styles/settings.scss"; import "../../styles/settings.scss";
import "styles/subscriptions.scss"; import "../../styles/subscriptions.scss";
import "styles/drafts.scss"; import "../../styles/drafts.scss";
import "styles/input_pill.scss"; import "../../styles/input_pill.scss";
import "styles/informational-overlays.scss"; import "../../styles/informational-overlays.scss";
import "styles/compose.scss"; import "../../styles/compose.scss";
import "styles/reactions.scss"; import "../../styles/reactions.scss";
import "styles/user_circles.scss"; import "../../styles/user_circles.scss";
import "styles/left-sidebar.scss"; import "../../styles/left-sidebar.scss";
import "styles/right-sidebar.scss"; import "../../styles/right-sidebar.scss";
import "styles/lightbox.scss"; import "../../styles/lightbox.scss";
import "styles/popovers.scss"; import "../../styles/popovers.scss";
import "styles/media.scss"; import "../../styles/media.scss";
import "styles/typing_notifications.scss"; import "../../styles/typing_notifications.scss";
import "styles/hotspots.scss"; import "../../styles/hotspots.scss";
import "styles/night_mode.scss"; import "../../styles/night_mode.scss";
import "styles/user_status.scss"; import "../../styles/user_status.scss";
import "styles/widgets.scss"; import "../../styles/widgets.scss";

View File

@ -3,18 +3,18 @@ import "string.prototype.startswith";
import "string.prototype.codepointat"; import "string.prototype.codepointat";
import "jquery/dist/jquery.js"; import "jquery/dist/jquery.js";
import "underscore/underscore.js"; import "underscore/underscore.js";
import "js/blueslip.js"; import "../blueslip.js";
import "third/bootstrap/js/bootstrap.js"; import "../../third/bootstrap/js/bootstrap.js";
import "third/bootstrap-typeahead/typeahead.js"; import "../../third/bootstrap-typeahead/typeahead.js";
import "js/common.js"; import "../common.js";
import "moment/min/moment.min.js"; import "moment/min/moment.min.js";
import "moment-timezone/builds/moment-timezone-with-data.min.js"; import "moment-timezone/builds/moment-timezone-with-data.min.js";
import "sortablejs/Sortable.js"; import "sortablejs/Sortable.js";
import "third/bootstrap/css/bootstrap.css"; import "../../third/bootstrap/css/bootstrap.css";
import "third/bootstrap/css/bootstrap-btn.css"; import "../../third/bootstrap/css/bootstrap-btn.css";
import "third/bootstrap/css/bootstrap-responsive.css"; import "../../third/bootstrap/css/bootstrap-responsive.css";
import "simplebar/dist/simplebar.css"; import "simplebar/dist/simplebar.css";
import "font-awesome/css/font-awesome.css"; import "font-awesome/css/font-awesome.css";
import "generated/icons/style.css"; import "../../generated/icons/style.css";
import "source-sans-pro/source-sans-pro.css"; import "source-sans-pro/source-sans-pro.css";
import "styles/pygments.scss"; import "../../styles/pygments.scss";

View File

@ -107,7 +107,6 @@ from tools.lib.test_script import assert_provisioning_status_ok
assert_provisioning_status_ok(options.force) assert_provisioning_status_ok(options.force)
os.environ['NODE_PATH'] = 'static'
os.environ['TZ'] = 'UTC' os.environ['TZ'] = 'UTC'
INDEX_JS = 'frontend_tests/zjsunit/index.js' INDEX_JS = 'frontend_tests/zjsunit/index.js'

View File

@ -107,11 +107,6 @@ export default (env?: string): webpack.Configuration => {
filename: production ? '[name].[chunkhash].js' : '[name].js', filename: production ? '[name].[chunkhash].js' : '[name].js',
}, },
resolve: { resolve: {
modules: [
resolve(__dirname, "../static"),
"node_modules",
resolve(__dirname, "../"),
],
extensions: [".ts", ".js"], extensions: [".ts", ".js"],
}, },
// We prefer cheap-module-source-map over any eval-** options // We prefer cheap-module-source-map over any eval-** options