Skip to content

Commit

Permalink
Fix the code to generate a proper ESM output
Browse files Browse the repository at this point in the history
  • Loading branch information
banderror committed Sep 19, 2019
1 parent 638ded2 commit 30fd975
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,17 @@
"bugs": {
"url": "https://github.com/pengx17/monaco-yaml/issues"
},
"dependencies": {
"js-yaml": "3.12.0"
},
"peerDependencies": {
"monaco-editor": "^0.16.2"
},
"devDependencies": {
"@types/jest": "^23.3.10",
"@types/node": "^10.9.3",
"husky": "^1.2.1",
"jest": "^23.6.0",
"js-yaml": "^3.12.0",
"jsonc-parser": "^2.0.2",
"lint-staged": "^8.1.0",
"monaco-editor-core": "0.15.5",
Expand Down
2 changes: 1 addition & 1 deletion scripts/bundle-esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ helpers.packageESM({
resolveAlias: {
"vscode-nls": path.join(REPO_ROOT, "out/esm/fillers/vscode-nls.js")
},
resolveSkip: ["monaco-editor-core", "js-yaml"],
resolveSkip: ["monaco-editor", "monaco-editor-core", "js-yaml"],
destinationFolderSimplification: {
node_modules: "_deps",
"jsonc-parser/lib/esm": "jsonc-parser",
Expand Down
9 changes: 3 additions & 6 deletions src/monaco.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
'use strict';

import * as mode from './yamlMode';
import { setupMode } from './yamlMode';

import Emitter = monaco.Emitter;
import IEvent = monaco.IEvent;
Expand Down Expand Up @@ -70,16 +70,13 @@ monaco.languages.yaml = createAPI();

// --- Registration to monaco editor ---

function withMode(callback: (module: typeof mode) => void): void {
require<typeof mode>(['vs/language/yaml/yamlMode'], callback);
}

monaco.languages.register({
id: 'yaml',
extensions: ['.yaml', '.yml'],
aliases: ['YAML', 'yaml', 'YML', 'yml'],
mimetypes: ['application/x-yaml'],
});

monaco.languages.onLanguage('yaml', () => {
withMode(mode => mode.setupMode(yamlDefaults));
setupMode(yamlDefaults);
});
2 changes: 1 addition & 1 deletion src/yaml.worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
'use strict';

import * as worker from 'monaco-editor-core/esm/vs/editor/editor.worker';
import * as worker from 'monaco-editor/esm/vs/editor/editor.worker';
import { YAMLWorker } from './yamlWorker';

self.onmessage = () => {
Expand Down
7 changes: 6 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2341,7 +2341,7 @@ js-tokens@^3.0.2:
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"
integrity sha1-mGbfOVECEw449/mWvOtlRDIJwls=

js-yaml@^3.12.0, js-yaml@^3.7.0, js-yaml@^3.9.0:
js-yaml@3.12.0, js-yaml@^3.12.0, js-yaml@^3.7.0, js-yaml@^3.9.0:
version "3.12.0"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.12.0.tgz#eaed656ec8344f10f527c6bfa1b6e2244de167d1"
dependencies:
Expand Down Expand Up @@ -2811,6 +2811,11 @@ [email protected]:
resolved "https://registry.yarnpkg.com/monaco-editor-core/-/monaco-editor-core-0.15.5.tgz#145f1953a8e319282d92502252d68ef3486b6875"
integrity sha512-kM3KHRjj16cFdK5Z0EppKUu793JVMpsEesBSWlqdgrxcmjyDMXV6xK0oatPcAYp3eOfbbyjPhruxDXj85FKyIg==

monaco-editor@^0.16.2:
version "0.16.2"
resolved "https://registry.yarnpkg.com/monaco-editor/-/monaco-editor-0.16.2.tgz#950084ed82eeaef1c8c9d3c1bcab849fe11b2415"
integrity sha512-NtGrFzf54jADe7qsWh3lazhS7Kj0XHkJUGBq9fA/Jbwc+sgVcyfsYF6z2AQ7hPqDC+JmdOt/OwFjBnRwqXtx6w==

[email protected]:
version "1.6.0"
resolved "https://registry.yarnpkg.com/monaco-languages/-/monaco-languages-1.6.0.tgz#54ec5510b31f3132939014f171ade235e84ef0bc"
Expand Down

0 comments on commit 30fd975

Please sign in to comment.