-
Notifications
You must be signed in to change notification settings - Fork 266
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
fix: get the package build target working #73
Conversation
It is working for me. Hmmm. Did the package script work for you before? I switched it from using the .ts files directly to using the compiled .js in out/ because it would ignore some typscript errors. |
The package script didn't work before, but I pushed some changes that I had lying around from a while ago that fixed it for me. I'll look around at what it's doing some more tomorrow, it's odd that it works for only one of us, package-lock'd installations should be identical. |
Indeed. Are you on Windows or Mac? |
Mac |
Ahh, I'll see if I get the same error in WSL |
I'm still not sure why it works for you--we used to have This webpack config makes it work for me, though I later get an error diff --git a/gulpfile.js b/gulpfile.js
index 73788dc..8397dd5 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -13,6 +13,7 @@ const ts = require('gulp-typescript');
const tslint = require('gulp-tslint');
const typescript = require('typescript');
const vsce = require('vsce');
+const webpack = require('webpack');
const execSync = require('child_process').execSync;
const dirname = 'vscode-node-debug3';
@@ -82,12 +83,42 @@ gulp.task(
gulp.task('compile', gulp.parallel('compile:ts', 'compile:static'));
/** Run parcel to bundle the extension output files */
-gulp.task('bundle', () => {
- const parcelPath = path.join('node_modules', '.bin', 'parcel');
- const extensionPath = path.join(buildSrcDir, 'extension.js');
- const bootloaderPath = path.join(buildSrcDir, nodeTargetsDir, 'bootloader.js');
- const watchdogPath = path.join(buildSrcDir, nodeTargetsDir, 'watchdog.js');
- return runCommand(`${parcelPath} build ${extensionPath} ${bootloaderPath} ${watchdogPath} --target node -d ${distSrcDir} --no-source-maps --bundle-node-modules`, { stdio: 'inherit' })
+gulp.task('bundle', async () => {
+ const packages = [
+ { entry: path.join(buildSrcDir, 'extension.js'), library: true },
+ { entry: path.join(buildSrcDir, nodeTargetsDir, 'bootloader.js'), library: false },
+ { entry: path.join(buildSrcDir, nodeTargetsDir, 'watchdog.js'), library: false },
+ ];
+
+ for (const { entry, library } of packages) {
+ const config = {
+ mode: 'production',
+ target: 'node',
+ entry: path.resolve(entry),
+ output: {
+ path: path.resolve(distSrcDir),
+ filename: path.basename(entry),
+ devtoolModuleFilenameTemplate: '../[resource-path]',
+ },
+ externals: {
+ vscode: 'commonjs vscode',
+ },
+ };
+
+ if (library) {
+ config.output.libraryTarget = 'commonjs2';
+ }
+
+ await new Promise((resolve, reject) => webpack(config, (err, stats) => {
+ if (err) {
+ reject(err);
+ } else if (stats.hasErrors()) {
+ reject(stats);
+ } else {
+ resolve();
+ }
+ }));
+ }
});
// TODO: check the output location of watchdog/bootloader make sure it will work in out/src
@@ -216,4 +247,4 @@ function runCommand(cmd, options) {
}
resolve();
});
-}
\ No newline at end of file
+} |
I'm fine with switching to webpack if it's easier to get working everywhere. I'll try out that config. |
These changes get both the parcel bundling and vsix build targets working together. A few changes to note: - Separated the packaging phase to use the dist folder instead of out. This helps keep packaging completely separate from the normal debug/dev builds - As a result of the above change, the vsce package command now runs inside of the dist folder, so we need to copy any other needed files there as well (atm that's package.json, package.nls.json, and LICENSE) - Changed the gulpfile to use the command-line version of vsce instead of the js lib. I found the js version very hard to debug because gulp tends to swallow console.log statements, so the build would fail with zero diagnostic output. Using the command line api solves that problem and makes builds easier to debug. - Moved the tsconfig out of the src dir and into the root. I did this mainly because we are referencing the package.json in some parts of the code now, and if we use require(''), parcel can't resolve it, because we've gone one level deeper (from src to out/src). The solution to this is to use typescript import to import package.json. On compile, ts knows to change the relative path based on the output dir. But in order to let ts actually do this, we have to change the root of the ts project so that package.json is inside of it.
Parcel seems to have issues with the vscode dependency on Mac/Linux?
gulp seems to be able to handle backslashes on windows, but is not always consistent in behavior (e.g. in this case, on windows gulp would copy the resources directory fully recursively, whereas on mac/linux it would only copy the files, not preserving the directory structure)
951c655
to
c6f1459
Compare
Alright, let's give it another shot. I merged in your webpack config and switched from parcel. Everything is working for me on both Windows and Ubuntu 18.04, hopefully that means it works on Mac too (I don't have a Mac to test on |
Also a note if you install the extension, it will only work when launching with the proposed api flag due to: #80 |
Cool, thanks! I made a couple tweaks to ensure the bootloader and terminateProcess.sh script can be found, seems to work well now. |
"request": "launch", | ||
"runtimeExecutable": "${execPath}", | ||
"args": [ | ||
"--enable-proposed-api=msjsdiag.pwa-debugger", |
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.
I think this shouldn't be necessary?
These changes get both the parcel bundling and vsix build targets working together.
A few important changes to note: