From e17831c10d91ee0bc20e38adb7197b56f0a2b895 Mon Sep 17 00:00:00 2001 From: Bitaru Date: Fri, 13 Jan 2023 11:23:59 +0100 Subject: [PATCH] support es2015 --- README.md | 92 ++++++++++++++++++++++++++++++++++++++++++++++ index.html | 2 +- package.json | 5 ++- vite.config.ts | 4 +- vite.lib.config.ts | 4 +- 5 files changed, 100 insertions(+), 7 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..c0408ab --- /dev/null +++ b/README.md @@ -0,0 +1,92 @@ + + +
+ +

<monaco-editor>

+ +

+ Monaco Editor as a web-component +
+
+ View Demo + ยท + Report Bug +

+
+ +## About + +This is a minimal setup of [Monaco Editor](https://microsoft.github.io/monaco-editor/) in a shape of web-component. The main idea behind this repo is to skip building process of editor on the local environment. + + + +## Getting Started + +### Prerequisites + +To make it properly load from CDN you have to set a `window.__monaco_component_base` function that resolves a **url** + +```javascript +window.__monaco_component_base = function(filename) { + return 'https://unpkg.com/monaco-component@latest/dist/' + filename +} +``` + +### Installation + +Load from a CDN +```html + + + +``` +Install using NPM packages +```sh +npm install monaco-component +``` + +

(back to top)

+ + + + +## Usage + +```html + +``` +

(back to top)

+ + +## Contributing + +Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**. + +If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". +Don't forget to give the project a star! Thanks again! + +1. Fork the Project +2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`) +3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`) +4. Push to the Branch (`git push origin feature/AmazingFeature`) +5. Open a Pull Request + +

(back to top)

+ + + + +## License + +Distributed under the MIT License. See `LICENSE.txt` for more information. + +

(back to top)

diff --git a/index.html b/index.html index 98e626b..5b68600 100644 --- a/index.html +++ b/index.html @@ -12,6 +12,6 @@ - + diff --git a/package.json b/package.json index 10d886c..904a70e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "monaco-component", - "version": "0.0.1", + "version": "0.0.2", "description": "Monaco editor as web-component", "type": "module", "main": "lib/monaco-component.es.js", @@ -15,7 +15,7 @@ ], "scripts": { "dev": "vite", - "build": "tsc & vite build & vite build -c vite.lib.config.ts", + "build": "tsc && vite build && vite build -c vite.lib.config.ts", "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [ @@ -24,6 +24,7 @@ "web-component" ], "author": "Uscreen (https://www.uscreen.tv)", + "homepage": "https://github.com/Uscreen-video/monaco-component#readme", "license": "MIT", "dependencies": { "lit": "^2.6.1", diff --git a/vite.config.ts b/vite.config.ts index 9d11b7b..43835b2 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -13,8 +13,9 @@ export default defineConfig({ } } }, - build: { + target: 'es2015', + minify: 'terser', rollupOptions: { plugins: [ license({ @@ -32,3 +33,4 @@ export default defineConfig({ }, }, }) + diff --git a/vite.lib.config.ts b/vite.lib.config.ts index d62ae13..45c8d55 100644 --- a/vite.lib.config.ts +++ b/vite.lib.config.ts @@ -5,14 +5,12 @@ export default defineConfig({ experimental: { renderBuiltUrl(filename: string, { hostType }: { hostType: 'js' | 'css' | 'html' }) { if (hostType === 'js') { - return { runtime: `window.__monaco_component_base(${JSON.stringify(filename)})` } + return { runtime: `window.__monaco_component_module_base(${JSON.stringify(filename)})` } } else { return { relative: true } } } }, - - build: { rollupOptions: { output: {