-
-
Notifications
You must be signed in to change notification settings - Fork 201
Clean up the public API file and improve a few other things #550
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
Conversation
@@ -12,7 +12,7 @@ | |||
|
|||
const parseRuntime = require('../lib/config/parse-runtime'); | |||
const context = require('../lib/context'); | |||
const chalk = require('chalk'); | |||
const chalk = require('chalk').default; |
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.
.default
?
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.
initializeWebpackConfig(); | ||
} | ||
let runtimeConfig = context.runtimeConfig; | ||
let webpackConfig = runtimeConfig ? new WebpackConfig(runtimeConfig, true) : null; |
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.
If there is no runtimeConfig, when is this variable initialized?
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.
In Encore.configureRuntimeEnvironment(...)
That was already the case before, I basically just replaced calls to initializeWebpackConfig(...)
by new WebpackConfig(...)
(since the whole "validation" part is now done by the constructor).
@@ -9,6 +9,7 @@ | |||
|
|||
'use strict'; | |||
|
|||
const WebpackConfig = require('./WebpackConfig'); //eslint-disable-line no-unused-vars |
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 didn't realize we needed to import the class in order for the jsdoc to function below. If that's the case, I'm surprised eslint isn't smart enough to know that this really is "used"
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.
well, everything is scoped in JS. As our class is not a global variable, you cannot use it globally.
Thank you @Lyrkan! |
@Lyrkan microsoft/TypeScript#14377 seems to suggest a way to reference a type from another module in jsdoc without importing the file at runtime. It might be worth trying it. |
@stof Yep, in a first version I actually used: /** @typedef {import('./WebpackConfig')} WebpackConfig */ It works fine in VSCode but since that's not valid JSDoc I went for |
Now that we don't have many active PRs anymore I figured it was a good time to do some spring cleaning, especially in the
index.js
file (since we often recommend users to look at its content).This PR:
Moves the proxy creation into its own file (
lib/EncoreProxy.js
)Moves the content of
initializeWebpackConfig(...)
inside of theWebpackConfig
's constructor (we already had some checks related to theRuntimeConfig
there anyway)Fixes a few JSDoc issues (missing or misplaced comments, types not resolving correctly, etc.)
Puts examples from the
index.js
file's comments inside of Markdown code-blocks, which are supported by at least PHPStorm and VSCode:Indicates that
Encore.getWebpackConfig()
returns a Webpack configuration, which allows IDEs' autocompletion to work on it: