Skip to content

Commit

Permalink
Rename URL to path
Browse files Browse the repository at this point in the history
  • Loading branch information
yoyo930021 committed Nov 10, 2020
1 parent 8fe159d commit cdd6b2b
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 33 deletions.
4 changes: 2 additions & 2 deletions build/rollup-common-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const typescript = require('rollup-plugin-typescript2');
const resolve = require('@rollup/plugin-node-resolve').default;
const { terser } = require('rollup-plugin-terser');

const getRootURL = root => relative => path.resolve(__dirname, '../', root, relative);
const getRootPath = root => relative => path.resolve(__dirname, '../', root, relative);

const clearDist = dist => {
if (fs.existsSync(dist)) {
Expand Down Expand Up @@ -53,7 +53,7 @@ const createPlugins = tsconfig => [
];

module.exports = {
getRootURL,
getRootPath,
clearDist,
onwarn,
external,
Expand Down
16 changes: 8 additions & 8 deletions build/rollup-plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ function linkVlsInCLI() {
};
}

const getServerURL = url => path.resolve(__dirname, '../server', url);
const getServerPath = url => path.resolve(__dirname, '../server', url);

function watchVlsChange() {
return {
buildStart() {
// watch src changed
this.addWatchFile(getServerURL('src/'));
this.addWatchFile(getServerPath('src/'));
}
};
}
Expand All @@ -31,9 +31,9 @@ function generateTypingsVls() {
buildStart() {
return new Promise((resolve, reject) => {
const tsc = spawn(
getServerURL('node_modules/.bin/tsc'),
getServerPath('node_modules/.bin/tsc'),
['--declaration', '--declarationDir', './dist/types', '--emitDeclarationOnly', '--pretty'],
{ cwd: getServerURL('./'), shell: true }
{ cwd: getServerPath('./'), shell: true }
);
tsc.stdout.on('data', data => {
process.stdout.write(data);
Expand Down Expand Up @@ -66,10 +66,10 @@ function bundleVlsWithEsbuild() {
if (!service) {
service = await startService();
}
console.log(`bundles ${getServerURL('src/main.ts')} with esbuild`);
console.log(`bundles ${getServerPath('src/main.ts')} with esbuild`);
await service.build({
entryPoints: [getServerURL('src/main.ts')],
outfile: getServerURL('dist/vls.js'),
entryPoints: [getServerPath('src/main.ts')],
outfile: getServerPath('dist/vls.js'),
/**
* No minify when watch
* reason: https://github.com/microsoft/vscode/issues/12066
Expand Down Expand Up @@ -99,7 +99,7 @@ function bundleVlsWithEsbuild() {
'eslint'
],
format: 'cjs',
tsconfig: getServerURL('tsconfig.json'),
tsconfig: getServerPath('tsconfig.json'),
color: true
});
console.log(`✨ success with esbuild`);
Expand Down
12 changes: 6 additions & 6 deletions client/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
const { getRootURL, clearDist, external, createPlugins } = require('../build/rollup-common-config');
const { getRootPath, clearDist, external, createPlugins } = require('../build/rollup-common-config');
const clientPkg = require('../package.json');

const getClientURL = getRootURL('client');
const getClientPath = getRootPath('client');

clearDist(getClientURL('../dist'));
clearDist(getClientPath('../dist'));
module.exports = {
input: getClientURL('vueMain.ts'),
input: getClientPath('vueMain.ts'),
output: { file: clientPkg.main, name: clientPkg.name, format: 'cjs', sourcemap: true },
external,
watch: {
include: getClientURL('**')
include: getClientPath('**')
},
plugins: createPlugins(getClientURL('tsconfig.json'))
plugins: createPlugins(getClientPath('tsconfig.json'))
};
20 changes: 10 additions & 10 deletions server/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const fs = require('fs-extra');
const path = require('path');
const fg = require('fast-glob');
const { getRootURL, clearDist, external, onwarn, createPlugins } = require('../build/rollup-common-config');
const { getRootPath, clearDist, external, onwarn, createPlugins } = require('../build/rollup-common-config');
const {
linkVlsInCLI,
bundleVlsWithEsbuild,
Expand All @@ -10,15 +10,15 @@ const {
} = require('../build/rollup-plugins.js');
const vlsPkg = require('./package.json');

const getVlsURL = getRootURL('server');
const getVLSPath = getRootPath('server');

clearDist(getVlsURL('dist'));
clearDist(getVLSPath('dist'));

function copySnippets() {
return {
name: 'copy-snippets',
buildEnd() {
fs.copySync(getVlsURL('src/modes/vue/veturSnippets'), getVlsURL('dist/veturSnippets'), {
fs.copySync(getVLSPath('src/modes/vue/veturSnippets'), getVLSPath('dist/veturSnippets'), {
overwrite: true,
recursive: true
});
Expand All @@ -31,24 +31,24 @@ function copyTSDefaultLibs() {
name: 'copy-ts-default-libs',
buildEnd() {
const files = fg.sync('node_modules/typescript/lib/lib*.d.ts', {
cwd: getVlsURL(''),
cwd: getVLSPath(''),
unique: true,
absolute: true
});
files.forEach(file => fs.copySync(file, getVlsURL('dist/' + path.basename(file)), { overwrite: true }));
files.forEach(file => fs.copySync(file, getVLSPath('dist/' + path.basename(file)), { overwrite: true }));
}
};
}

module.exports = [
// vueServerMain
{
input: getVlsURL('src/vueServerMain.ts'),
output: { file: getVlsURL('dist/vueServerMain.js'), name: vlsPkg.name, format: 'cjs', sourcemap: true },
input: getVLSPath('src/vueServerMain.ts'),
output: { file: getVLSPath('dist/vueServerMain.js'), name: vlsPkg.name, format: 'cjs', sourcemap: true },
external,
onwarn,
watch: {
include: getVlsURL('**')
include: getVLSPath('**')
},
plugins: [
watchVlsChange(),
Expand All @@ -57,7 +57,7 @@ module.exports = [
copySnippets(),
copyTSDefaultLibs(),
linkVlsInCLI(),
...createPlugins(getVlsURL('tsconfig.json'))
...createPlugins(getVLSPath('tsconfig.json'))
]
}
];
14 changes: 7 additions & 7 deletions vti/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
const { getRootURL, clearDist, external, onwarn, createPlugins } = require('../build/rollup-common-config');
const { getRootPath, clearDist, external, onwarn, createPlugins } = require('../build/rollup-common-config');
const vtiPkg = require('./package.json');

const getVtiURL = getRootURL('vti');
const getVTIPath = getRootPath('vti');

clearDist(getVtiURL('dist'));
clearDist(getVTIPath('dist'));
module.exports = {
input: getVtiURL('src/cli.ts'),
output: { file: getVtiURL(vtiPkg.main), name: vtiPkg.name, format: 'cjs', sourcemap: true },
input: getVTIPath('src/cli.ts'),
output: { file: getVTIPath(vtiPkg.main), name: vtiPkg.name, format: 'cjs', sourcemap: true },
external: [...external, 'vls'],
onwarn,
watch: {
include: getVtiURL('**')
include: getVTIPath('**')
},
plugins: createPlugins(getVtiURL('tsconfig.json'))
plugins: createPlugins(getVTIPath('tsconfig.json'))
};

0 comments on commit cdd6b2b

Please sign in to comment.