-
Notifications
You must be signed in to change notification settings - Fork 37
test: added esbuild example #1713
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f3de8d4
test: added esbuild example
kirrg001 991a98d
chore: example-2
kirrg001 7f46bc9
chore: lint
kirrg001 28c1289
chore: lint
kirrg001 9ae70bc
chore: clean
kirrg001 4ef44c5
chore: x
kirrg001 96eba5e
chore: cleanup
kirrg001 0c4f120
docs: readme
kirrg001 1b4229a
docs: added note
kirrg001 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
3 changes: 3 additions & 0 deletions
3
packages/collector/test/tracing/misc/esbuild-external/.env.template
This file contains hidden or 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,3 @@ | ||
|
||
INSTANA_ENDPOINT= | ||
INSTANA_AGENT_KEY= |
16 changes: 16 additions & 0 deletions
16
packages/collector/test/tracing/misc/esbuild-external/README.md
This file contains hidden or 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,16 @@ | ||
# Notes | ||
|
||
For `esbuild` you MUST define the NPM production dependencies in the `external` configuration, otherwise `esbuild` will bundle **all** production dependencies into | ||
one dist file and it will no longer use `require` or `import`, because the code | ||
is accessible in the dist file itself. | ||
|
||
# Build | ||
|
||
```sh | ||
npm i | ||
cp .env.template .env | ||
npm run build | ||
npm run package | ||
``` | ||
|
||
kirrg001 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Optionally, upload `dist/instana-test-esbuild-0.17.19.vsix` to VSCode and run the command "Run Instana Axios Demo". |
29 changes: 29 additions & 0 deletions
29
packages/collector/test/tracing/misc/esbuild-external/build.mjs
This file contains hidden or 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,29 @@ | ||
import esbuild from 'esbuild'; | ||
import pkg from './package.json' assert { type: 'json' }; | ||
|
||
async function build() { | ||
/** @type {esbuild.BuildOptions} */ | ||
const options = { | ||
entryPoints: ['./extension.ts'], | ||
outfile: `./dist/extension.js`, | ||
bundle: true, | ||
format: 'cjs', | ||
platform: 'node', | ||
minify: false, | ||
define: { | ||
'process.env.NODE_OPTIONS': JSON.stringify('--require ./node_modules/@instana/serverless-collector/src/index.js'), | ||
'process.env.INSTANA_ENDPOINT': JSON.stringify(process.env.INSTANA_ENDPOINT), | ||
'process.env.INSTANA_AGENT_KEY': JSON.stringify(process.env.INSTANA_AGENT_KEY) | ||
}, | ||
sourcemap: 'inline', | ||
sourcesContent: false, | ||
external: ['vscode', ...Object.keys(pkg.dependencies)] | ||
}; | ||
|
||
await esbuild.build(options); | ||
} | ||
|
||
build().catch(err => { | ||
console.error(err); | ||
process.exit(1); | ||
}); |
19 changes: 19 additions & 0 deletions
19
packages/collector/test/tracing/misc/esbuild-external/extension.ts
This file contains hidden or 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,19 @@ | ||
import * as vscode from 'vscode'; | ||
import { runInstanaJob } from './server'; | ||
|
||
export function activate(context: vscode.ExtensionContext) { | ||
console.log('Extension "instana-axios-demo" is now active!'); | ||
|
||
const disposable = vscode.commands.registerCommand('instanaAxiosDemo.run', async () => { | ||
vscode.window.showInformationMessage('Running Instana Axios Job...'); | ||
vscode.window.showInformationMessage(process.env.NODE_OPTIONS); | ||
vscode.window.showInformationMessage(process.env.INSTANA_ENDPOINT); | ||
await runInstanaJob(); | ||
}); | ||
|
||
context.subscriptions.push(disposable); | ||
} | ||
|
||
export function deactivate() { | ||
console.log('Extension "instana-axios-demo" is now deactivated.'); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Qs: why this sample app is placed here? I’m wondering if I might be missing a corresponding test file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where do you want to put it elsewise?
We can later connect it with a test if we want, but the effort is too high right now.
This esbuild folder is code knowledge sharing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
packages/collector/test/tracing
normally contains integration tests. Would it be more appropriate to place this in theexample-apps
instead?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm IMO misc is the right place (we have all kinds of build pipeline examples in here), but I agree with you too that it also could be moved to examples. But IMO its a bit too small and too special for examples.