-
Notifications
You must be signed in to change notification settings - Fork 662
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
See #1290 for context. Major thanks to @pderaaij that did all the hard work here. * using js-sha1 instead of node's crypto to compute sha1 * Using esbuild to bundle native and web extension (WIP) * Added message regarding unsupported embeds in web extension * support for graph webview in web extension
- Loading branch information
1 parent
cd9ee4d
commit dde11f8
Showing
23 changed files
with
207 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
node_modules | ||
.DS_Store | ||
.vscode-test/ | ||
.vscode-test-web/ | ||
*.tsbuildinfo | ||
*.vsix | ||
*.log | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
// also see https://code.visualstudio.com/api/working-with-extensions/bundling-extension | ||
const assert = require('assert'); | ||
const esbuild = require('esbuild'); | ||
|
||
// pass the platform to esbuild as an argument | ||
|
||
function getPlatform() { | ||
const args = process.argv.slice(2); | ||
const pArg = args.find(arg => arg.startsWith('--platform=')); | ||
if (pArg) { | ||
return pArg.split('=')[1]; | ||
} | ||
throw new Error('No platform specified. Pass --platform <web|node>.'); | ||
} | ||
|
||
const platform = getPlatform(); | ||
assert(['web', 'node'].includes(platform), 'Platform must be "web" or "node".'); | ||
|
||
const production = process.argv.includes('--production'); | ||
const watch = process.argv.includes('--watch'); | ||
|
||
const config = { | ||
web: { | ||
platform: 'browser', | ||
format: 'cjs', | ||
outfile: `out/bundles/extension-web.js`, | ||
plugins: [ | ||
{ | ||
name: 'path-browserify', | ||
setup(build) { | ||
build.onResolve({ filter: /^path$/ }, args => { | ||
return { path: require.resolve('path-browserify') }; | ||
}); | ||
}, | ||
}, | ||
{ | ||
name: 'wikilink-embed', | ||
setup(build) { | ||
build.onResolve({ filter: /wikilink-embed/ }, args => { | ||
return { | ||
path: require.resolve( | ||
args.resolveDir + '/wikilink-embed-web-extension.ts' | ||
), | ||
}; | ||
}); | ||
}, | ||
}, | ||
], | ||
}, | ||
node: { | ||
platform: 'node', | ||
format: 'cjs', | ||
outfile: `out/bundles/extension-node.js`, | ||
plugins: [], | ||
}, | ||
}; | ||
|
||
async function main() { | ||
const ctx = await esbuild.context({ | ||
...config[platform], | ||
entryPoints: ['src/extension.ts'], | ||
bundle: true, | ||
minify: production, | ||
sourcemap: !production, | ||
sourcesContent: false, | ||
external: ['vscode'], | ||
logLevel: 'silent', | ||
plugins: [ | ||
...config[platform].plugins, | ||
/* add to the end of plugins array */ | ||
esbuildProblemMatcherPlugin, | ||
], | ||
}); | ||
if (watch) { | ||
await ctx.watch(); | ||
} else { | ||
await ctx.rebuild(); | ||
await ctx.dispose(); | ||
} | ||
} | ||
|
||
/** | ||
* @type {import('esbuild').Plugin} | ||
*/ | ||
const esbuildProblemMatcherPlugin = { | ||
name: 'esbuild-problem-matcher', | ||
|
||
setup(build) { | ||
build.onStart(() => { | ||
console.log('[watch] build started'); | ||
}); | ||
build.onEnd(result => { | ||
result.errors.forEach(({ text, location }) => { | ||
console.error(`✘ [ERROR] ${text}`); | ||
console.error( | ||
` ${location.file}:${location.line}:${location.column}:` | ||
); | ||
}); | ||
console.log('[watch] build finished'); | ||
}); | ||
}, | ||
}; | ||
|
||
main().catch(e => { | ||
console.error(e); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.