Skip to content
Open
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
5 changes: 2 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,10 @@ lazy val cli = project
val targetDir = (npmUpdate in (js, Compile)).value
// scalajs-bundler does not support setting a custom output path so
// explicitly include only those files that are generated by webpack.
val includes: FileFilter = "index.html" | "metadoc.*.css" | "*-bundle.js" | "favicon.png"
val includes: FileFilter = "index.html" | "metadoc.*.css" | "*-bundle.js" | "favicon.png" | "editor.worker.js"
val paths: PathFinder =
(
targetDir./("assets").allPaths +++
targetDir./("vs").allPaths +++
targetDir.*(includes)
) --- targetDir
val mappings = paths.get pair Path.relativeTo(targetDir)
Expand Down Expand Up @@ -117,7 +116,7 @@ lazy val js = project
"org.scalatest" %%% "scalatest" % "3.0.5" % Test
),
npmDevDependencies in Compile ++= Seq(
"copy-webpack-plugin" -> "4.5.2",
"monaco-editor-webpack-plugin" -> "1.4.0",
"css-loader" -> "0.28.11",
"mini-css-extract-plugin" -> "0.4.3",
"file-loader" -> "1.1.11",
Expand Down
1 change: 0 additions & 1 deletion metadoc-js/src/main/resources/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="theme-color" content="#002b36">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<script src="vs/loader.js"></script>
</head>
<body class="mdc-typography">
<header class="mdc-toolbar mdc-toolbar--fixed">
Expand Down
4 changes: 4 additions & 0 deletions metadoc-js/src/main/resources/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,9 @@ window.ScalaLanguage = require('./scala.ts')
* Load additional resources.
*/

// Import special entry point to only include a subset of the features & languages
// as configured via the Monaco Webpack plugin.
window.monaco = require('node_modules/monaco-editor/esm/vs/editor/editor.api.js');

require('node_modules/material-components-web/dist/material-components-web.css')
require('./index.css')
18 changes: 0 additions & 18 deletions metadoc-js/src/main/scala/metadoc/MetadocApp.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ object MetadocApp {
}

for {
_ <- loadMonaco()
workspace <- MetadocFetch.workspace()
} {
val index = new MutableBrowserIndex(MetadocState(s.TextDocument()))
Expand Down Expand Up @@ -193,23 +192,6 @@ object MetadocApp {
}
}

/**
* Load the Monaco Editor AMD bundle using `require`.
*
* The AMD bundle is not compatible with Webpack and must be loaded
* dynamically at runtime to avoid errors:
* https://github.com/Microsoft/monaco-editor/issues/18
*/
def loadMonaco(): Future[Unit] = {
val promise = Promise[Unit]()
js.Dynamic.global.require(js.Array("vs/editor/editor.main"), {
ctx: js.Dynamic =>
println("Monaco Editor loaded")
promise.success(())
}: js.ThisFunction)
promise.future
}

val ScalaLanguageExtensionPoint = {
val language = jsObject[ILanguageExtensionPoint]
language.id = "scala"
Expand Down
10 changes: 2 additions & 8 deletions metadoc-js/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const merge = require("webpack-merge")
const config = require('./scalajs.webpack.config')

const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");

const RootDir = path.resolve(__dirname, '../../../..')
Expand Down Expand Up @@ -55,13 +55,7 @@ module.exports = merge(config, {
]
},
plugins: [
new CopyWebpackPlugin([
{
from: path.resolve(MonacoEditorBaseDir, 'vs'),
to: 'vs',
ignore: [ 'basic-languages/**/*', 'language/**/*' ]
}
]),
new MonacoWebpackPlugin({ languages: [] }),
new MiniCssExtractPlugin({
filename: DevMode ? '[name].css' : '[name].[hash].css',
chunkFilename: DevMode ? '[id].css' : '[id].[hash].css',
Expand Down