Skip to content
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

Update to new renderer API and update webpack from 4 => 5 #46

Merged
merged 3 commits into from
May 23, 2021

Conversation

IanMatthewHuff
Copy link
Member

microsoft/vscode#93265 (comment)

This change required webpack as ES6 module, which required moving from webpack 4 => 5.

I'm a webpack noob, so I'll call out in comments some of the changes that I made. I was seeing one issue with plotly that I want to look into, looks like it wasn't loading the plotly bundle correctly. But considering that I also need to do this for Jupyter (which might be harder) I'd rather get both extensions up and generally running before digging into issues, since this change is expected to be breaking Friday or Monday.

While I saw a plotly issue the general transforms were working. I'll test more output types as I go.

@@ -2,10 +2,10 @@
// Licensed under the MIT License.

const common = require('./common');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This had a loading error and from the docs didn't look relevant to ES6 module, so I removed:
https://www.npmjs.com/package/webpack-fix-default-import-plugin

@@ -18,21 +18,25 @@ module.exports = {
output: {
path: path.join(constants.ExtensionRootDir, 'out', 'client_renderer'),
filename: '[name].js',
chunkFilename: `[name].bundle.js`
chunkFilename: `[name].bundle.js`,
libraryTarget: 'module'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

experiments: {
outputModule: true
},
target: 'node',
Copy link
Member Author

@IanMatthewHuff IanMatthewHuff May 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Webpack 5 doesn't shim build in node modules. Per the warning message here it seems like we could either reference the shim package and add a fallback or if we target 'node' I don't believe that it's needed. Was a tiny bit unsure on this, but this seemed to work with the node loaded, so went with this for now versus referencing shim packages.

Here is an example of the type of error we would see after the 4-5 update.
https://stackoverflow.com/questions/64402821/module-not-found-error-cant-resolve-util-in-webpack

new ForkTsCheckerWebpackPlugin({
checkSyntacticErrors: true,
tsconfig: configFileName,
reportFiles: ['src/client/**/*.{ts,tsx}'],
memoryLimit: 9096
}),
new DefinePlugin({
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glad that Conner called this out this change specifically in the issue, would have bit me otherwise.

output: OldNotebookOutput;
mimeType: string;
}
export const activate: ActivationFunction = () => ({
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actual code change was super simple. Webpack was the only real pain. At one point we used to maintain back compat on this extension, hence the old API classes here. But I just don't see that being very possible with the new changes, so explicitly moving to 1.57 and removing the old BC code path.

return {
data: {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[cellInfo.mime]: cellInfo.value as any
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The any types are a bit ugly here, but it's actually going to those super loose Jupyter JSONObjects and I didn't want to import phosphor and whatnot for something that didn't really give any type safety. So went with any for now, but not adverse to looking if we can make these stronger types in a follow up.

@IanMatthewHuff IanMatthewHuff marked this pull request as ready for review May 21, 2021 16:34
@IanMatthewHuff
Copy link
Member Author

Note: Build all looks fine here: https://dev.azure.com/ms/vscode-notebook-renderers/_build/results?buildId=169252&view=results

Some results don't seem to be linked here though. So doing an admin push. Will check on why the CI doesn't seem tied to the github status reporting.

@IanMatthewHuff IanMatthewHuff merged commit f245b5a into main May 23, 2021
@IanMatthewHuff IanMatthewHuff deleted the dev/ianhu/newRendererAPI branch May 23, 2021 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants