mirror of
https://github.com/danbulant/monaco-yaml
synced 2026-06-24 17:11:59 +00:00
Merge pull request #136 from remcohaszing/flatten-output-paths
Flatten output paths
This commit is contained in:
commit
326a253813
7 changed files with 60 additions and 66 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -1,5 +1,7 @@
|
|||
dist/
|
||||
node_modules/
|
||||
/lib/
|
||||
/index.js
|
||||
/yaml.worker.js
|
||||
*.log
|
||||
*.map
|
||||
*.tgz
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
/dist/
|
||||
/lib/
|
||||
/out/
|
||||
dist/
|
||||
/index.js
|
||||
/yaml.worker.js
|
||||
|
|
|
|||
105
build.js
105
build.js
|
|
@ -1,60 +1,53 @@
|
|||
const { promises: fs } = require('fs');
|
||||
const { join } = require('path');
|
||||
|
||||
const { build } = require('esbuild');
|
||||
|
||||
const { dependencies, peerDependencies } = require('./package.json');
|
||||
|
||||
fs.rm(join(__dirname, 'lib'), { force: true, recursive: true })
|
||||
.then(() =>
|
||||
build({
|
||||
entryPoints: ['src/monaco.contribution.ts', 'src/yaml.worker.ts'],
|
||||
bundle: true,
|
||||
external: Object.keys({ ...dependencies, ...peerDependencies }),
|
||||
logLevel: 'info',
|
||||
outdir: 'lib/esm',
|
||||
sourcemap: true,
|
||||
format: 'esm',
|
||||
target: ['es2019'],
|
||||
plugins: [
|
||||
{
|
||||
name: 'alias',
|
||||
setup({ onResolve }) {
|
||||
// The yaml language service only imports re-exports of vscode-languageserver-types from
|
||||
// vscode-languageserver.
|
||||
onResolve({ filter: /^vscode-languageserver(\/node|-protocol)?$/ }, () => ({
|
||||
path: 'vscode-languageserver-types',
|
||||
external: true,
|
||||
}));
|
||||
// The yaml language service uses path. We can stub it using path-browserify.
|
||||
onResolve({ filter: /^path$/ }, () => ({
|
||||
path: 'path-browserify',
|
||||
external: true,
|
||||
}));
|
||||
// The main prettier entry point contains all of Prettier.
|
||||
// The standalone bundle is smaller and works fine for us.
|
||||
onResolve({ filter: /^prettier/ }, ({ path }) => ({
|
||||
path: path === 'prettier' ? 'prettier/standalone.js' : `${path}.js`,
|
||||
external: true,
|
||||
}));
|
||||
// This tiny filler implementation serves all our needs.
|
||||
onResolve({ filter: /vscode-nls/ }, () => ({
|
||||
path: require.resolve('./src/fillers/vscode-nls.ts'),
|
||||
}));
|
||||
// The language server dependencies tend to write both ESM and UMD output alongside each
|
||||
// other, then use UMD for imports. We prefer ESM.
|
||||
onResolve({ filter: /\/umd\// }, (args) => ({
|
||||
path: require.resolve(args.path.replace(/\/umd\//, '/esm/'), {
|
||||
paths: [args.resolveDir],
|
||||
}),
|
||||
}));
|
||||
},
|
||||
},
|
||||
],
|
||||
}),
|
||||
)
|
||||
.catch((error) => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
});
|
||||
build({
|
||||
entryPoints: ['src/index.ts', 'src/yaml.worker.ts'],
|
||||
bundle: true,
|
||||
external: Object.keys({ ...dependencies, ...peerDependencies }),
|
||||
logLevel: 'info',
|
||||
outdir: '.',
|
||||
sourcemap: true,
|
||||
format: 'esm',
|
||||
target: ['es2019'],
|
||||
plugins: [
|
||||
{
|
||||
name: 'alias',
|
||||
setup({ onResolve }) {
|
||||
// The yaml language service only imports re-exports of vscode-languageserver-types from
|
||||
// vscode-languageserver.
|
||||
onResolve({ filter: /^vscode-languageserver(\/node|-protocol)?$/ }, () => ({
|
||||
path: 'vscode-languageserver-types',
|
||||
external: true,
|
||||
}));
|
||||
// The yaml language service uses path. We can stub it using path-browserify.
|
||||
onResolve({ filter: /^path$/ }, () => ({
|
||||
path: 'path-browserify',
|
||||
external: true,
|
||||
}));
|
||||
// The main prettier entry point contains all of Prettier.
|
||||
// The standalone bundle is smaller and works fine for us.
|
||||
onResolve({ filter: /^prettier/ }, ({ path }) => ({
|
||||
path: path === 'prettier' ? 'prettier/standalone.js' : `${path}.js`,
|
||||
external: true,
|
||||
}));
|
||||
// This tiny filler implementation serves all our needs.
|
||||
onResolve({ filter: /vscode-nls/ }, () => ({
|
||||
path: require.resolve('./src/fillers/vscode-nls.ts'),
|
||||
}));
|
||||
// The language server dependencies tend to write both ESM and UMD output alongside each
|
||||
// other, then use UMD for imports. We prefer ESM.
|
||||
onResolve({ filter: /\/umd\// }, (args) => ({
|
||||
path: require.resolve(args.path.replace(/\/umd\//, '/esm/'), {
|
||||
paths: [args.resolveDir],
|
||||
}),
|
||||
}));
|
||||
},
|
||||
},
|
||||
],
|
||||
}).catch((error) => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ window.MonacoEnvironment = {
|
|||
case 'editorWorkerService':
|
||||
return new Worker(new URL('monaco-editor/esm/vs/editor/editor.worker', import.meta.url));
|
||||
case 'yaml':
|
||||
return new Worker(new URL('monaco-yaml/lib/esm/yaml.worker', import.meta.url));
|
||||
return new Worker(new URL('monaco-yaml/yaml.worker', import.meta.url));
|
||||
default:
|
||||
throw new Error(`Unknown label ${label}`);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { editor, Uri } from 'monaco-editor';
|
||||
import EditorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker';
|
||||
import { setDiagnosticsOptions } from 'monaco-yaml';
|
||||
import YamlWorker from 'monaco-yaml/lib/esm/yaml.worker?worker';
|
||||
import YamlWorker from 'monaco-yaml/yaml.worker?worker';
|
||||
|
||||
window.MonacoEnvironment = {
|
||||
getWorker(moduleId, label) {
|
||||
|
|
|
|||
|
|
@ -7,12 +7,11 @@
|
|||
"prepack": "node build.js",
|
||||
"prepare": "husky install"
|
||||
},
|
||||
"main": "./lib/esm/monaco.contribution.js",
|
||||
"module": "./lib/esm/monaco.contribution.js",
|
||||
"typings": "./index.d.ts",
|
||||
"files": [
|
||||
"lib",
|
||||
"index.d.ts"
|
||||
"index.js",
|
||||
"index.d.ts",
|
||||
"yaml.worker.js"
|
||||
],
|
||||
"workspaces": [
|
||||
"examples/*"
|
||||
|
|
|
|||
Loading…
Reference in a new issue