Skip to content

Optimize javascript bundle #577

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import { Application } from "stimulus"
import { definitionsFromContext } from "stimulus/webpack-helpers"

const application = Application.start()
const context = require.context("controllers", true, /_controller\.js$/)
const context = require.context("controllers/app", true, /_controller\.js$/)
application.load(definitionsFromContext(context))
9 changes: 9 additions & 0 deletions app/javascript/controllers/repl/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Load all the controllers within this directory and all subdirectories.
// Controller files must be named *_controller.js.

import { Application } from "stimulus"
import { definitionsFromContext } from "stimulus/webpack-helpers"

const application = Application.start()
const context = require.context("controllers/repl", true, /_controller\.js$/)
application.load(definitionsFromContext(context))
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Controller } from "stimulus"
import * as monaco from "monaco-editor"
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api.js'
import hotkeys from "hotkeys-js"

export default class extends Controller {
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/packs/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
// layout file, like app/views/layouts/application.html.erb

import "./app"
import "controllers"
import "controllers/app"
11 changes: 11 additions & 0 deletions app/javascript/packs/repl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* eslint no-console:0 */
// This file is automatically compiled by Webpack, along with any other files
// present in this directory. You're encouraged to place your actual application logic in
// a relevant structure within app/javascript and only use these pack files to reference
// that code so it'll be compiled.
//
// To reference this file, add <%= javascript_pack_tag 'application' %> to the appropriate
// layout file, like app/views/layouts/application.html.erb

import "./app"
import "controllers/repl"
1 change: 1 addition & 0 deletions app/views/layouts/application.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ html lang="en"
= stylesheet_pack_tag 'application'
= javascript_pack_tag 'icons'
= javascript_pack_tag 'application', defer: true
= yield(:javascript_packs) if content_for?(:javascript_packs)
= content_for(:head)

body class="bg-white text-gray-700 dark:bg-gray-800 dark:text-gray-400"
Expand Down
3 changes: 3 additions & 0 deletions app/views/repl/index.html.slim
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
- content_for :javascript_packs do
= javascript_pack_tag 'repl', defer: true

div class="mt-16" data-controller="repl"
div class="pt-2 grid md:grid-cols-3 gap-6"
div class="col-span-2 relative"
Expand Down
5 changes: 4 additions & 1 deletion config/webpack/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');

environment.plugins.prepend(
'MonacoWebpackPlugin',
new MonacoWebpackPlugin()
new MonacoWebpackPlugin({
languages: ['ruby'],
features: ['accessibilityHelp', '!anchorSelect', '!bracketMatching', '!caretOperations', '!clipboard', '!codeAction', '!codelens', '!colorDetector', 'comment', '!contextmenu', '!coreCommands', '!cursorUndo', '!dnd', '!find', '!folding', '!fontZoom', '!format', '!gotoError', '!gotoLine', '!gotoSymbol', '!hover', 'iPadShowKeyboard', '!inPlaceReplace', 'indentation', '!inspectTokens', '!linesOperations', '!links', '!multicursor', '!onTypeRename', '!parameterHints', '!quickCommand', '!quickHelp', '!quickOutline', '!referenceSearch', '!rename', '!smartSelect', '!snippets', '!suggest', '!toggleHighContrast', '!toggleTabFocusMode', '!transpose', '!unusualLineTerminators', '!viewportSemanticTokens', '!wordHighlighter', '!wordOperations', '!wordPartOperations']
})
)

module.exports = environment