before_code stringlengths 14 465k | reviewer_comment stringlengths 16 64.5k | after_code stringlengths 9 467k | diff_context stringlengths 0 97k | file_path stringlengths 5 226 | comment_line int32 0 26 | language stringclasses 37
values | quality_score float32 0.07 1 | comment_type stringclasses 9
values | comment_length int32 16 64.5k | before_lines int32 1 17.2k | after_lines int32 1 12.1k | is_negative bool 2
classes | pr_title stringlengths 1 308 | pr_number int32 1 299k | repo_name stringclasses 533
values | repo_stars int64 321 419k | repo_language stringclasses 27
values | reviewer_username stringlengths 0 39 | author_username stringlengths 2 39 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
* "default-with-named": Provide a namespace object with named and default export. namespace = { ...exports, default: exports }
*/
getExportsType(moduleGraph, strict) {
switch (this.buildMeta && this.buildMeta.exportsType) {
case "flagged":
return strict ? "default-with-named" : "namespace";
case "names... | Honestly I think current `redirect-warn` actually means `redirect-error`, because if parent is `strict`, `redirect-warn` do nothing but throw the linking error, but I don't want to break current users, so I added a new `redirect-warn-only` which is equal to `redirect`, just add warning if user use named exports | * "default-with-named": Provide a namespace object with named and default export. namespace = { ...exports, default: exports }
*/
getExportsType(moduleGraph, strict) {
switch (this.buildMeta && this.buildMeta.exportsType) {
case "flagged":
return strict ? "default-with-named" : "namespace";
case "names... | @@ -575,6 +576,7 @@ class Module extends DependenciesBlock {
switch (/** @type {BuildMeta} */ (this.buildMeta).defaultObject) {
case "redirect":
case "redirect-warn":
+ case "redirect-warn-only": | lib/Module.js | 26 | JavaScript | 1 | suggestion | 312 | 51 | 51 | false | fix: should support named export json all time and onlyDefault for import attributes | 20,031 | webpack/webpack | 65,000 | JavaScript | JSerFeng | JSerFeng |
}
const dep = new ExternalModuleDependency(
"url",
[
{
name: "fileURLToPath",
value: "__webpack_fileURLToPath__"
}
],
undefined,
fn("__webpack_fileURLToPath__"),
/** @type {Range} */ (expr.range),
i... | Don't replace `import.meta.dirname` and `import.meta.filename` when env supports them |
return true;
});
};
/**
* @param {string} expressionName expression name
* @param {(value: string) => string} fn function
* @param {"dirname" | "filename"} property property
* @returns {void}
*/
const setUrlModuleConstant = (expressionName, fn, property) => ... | @@ -147,33 +155,33 @@ class NodeStuffPlugin {
/**
* @param {string} expressionName expression name
* @param {(value: string) => string} fn function
+ * @param {string} identifier identifier
* @returns {void}
*/
- const setUrlModuleConstant = (expressionName, fn) => {
+ con... | lib/NodeStuffPlugin.js | 26 | JavaScript | 0.571 | suggestion | 85 | 51 | 51 | false | feat: added support for `import.meta.dirname` and `import.meta.filename` | 20,050 | webpack/webpack | 65,000 | JavaScript | alexander-akait | alexander-akait |
if (localOptions.__dirname) {
switch (localOptions.__dirname) {
case "mock":
setConstant(dirname, "/", "__dirname");
break;
case "warn-mock":
setConstant(
dirname,
"/",
"__dirname",
"__dirname is a Node.js feature and isn't available i... | Prevent removing `import.meta.filename` | "filename"
);
break;
}
case "eval-only":
// Keep `import.meta.filename` in the source code for the ES module output
if (compilation.outputOptions.module) {
const { importMetaName } = compilation.outputOptions;
parser.hooks.expression
.f... | @@ -184,41 +192,64 @@ class NodeStuffPlugin {
/**
* @param {string} expressionName expression name
* @param {string} value value
+ * @param {string} identifier identifier
* @param {string=} warning warning
* @returns {void}
*/
- const setConstant = (expressionName, valu... | lib/NodeStuffPlugin.js | 26 | JavaScript | 0.286 | suggestion | 39 | 51 | 51 | false | feat: added support for `import.meta.dirname` and `import.meta.filename` | 20,050 | webpack/webpack | 65,000 | JavaScript | alexander-akait | alexander-akait |
.tap(PLUGIN_NAME, (parser, parserOptions) => {
handler(parser, parserOptions, {
dirname: "__dirname",
filename: "__filename"
});
handler(parser, parserOptions, {
dirname: "import.meta.dirname",
filename: "import.meta.filename"
});
});
normalModuleFactory... | Prevent removing `import.meta.dirname` | `${functionName}(${importMetaName}.url.replace(/\\/(?:[^\\/]*)$/, ""))`,
"dirname"
);
break;
}
case "eval-only":
// Keep `import.meta.dirname` in the source code for the ES module output and replace `__dirname` on `import.meta.dirname`
if (compilation.out... | @@ -234,38 +265,59 @@ class NodeStuffPlugin {
if (localOptions.__dirname) {
switch (localOptions.__dirname) {
case "mock":
- setConstant("__dirname", "/");
+ setConstant(dirname, "/", "__dirname");
break;
case "warn-mock":
setConstant(
- "__dirname",
... | lib/NodeStuffPlugin.js | 26 | JavaScript | 0.286 | suggestion | 38 | 33 | 51 | false | feat: added support for `import.meta.dirname` and `import.meta.filename` | 20,050 | webpack/webpack | 65,000 | JavaScript | alexander-akait | alexander-akait |
parser.hooks.evaluateIdentifier
.for(dirname)
.tap(PLUGIN_NAME, (expr) => {
if (!parser.state.module) return;
return evaluateToString(
/** @type {string} */
(parser.state.module.context)
)(expr);
});
}
parser.hooks.expression
.for("r... | Using regexp to replace the last `/file.ext` to get a right value for dirname | ) {
parser.hooks.expression
.for(dirname)
.tap(PLUGIN_NAME, toConstantDependency(parser, dirname));
}
if (localOptions.__dirname) {
switch (localOptions.__dirname) {
case "mock":
setConstant(dirname, "/", "__webpack_dirname__");
break;
case "warn-m... | @@ -234,38 +265,59 @@ class NodeStuffPlugin {
if (localOptions.__dirname) {
switch (localOptions.__dirname) {
case "mock":
- setConstant("__dirname", "/");
+ setConstant(dirname, "/", "__dirname");
break;
case "warn-mock":
setConstant(
- "__dirname",
... | lib/NodeStuffPlugin.js | 26 | JavaScript | 0.571 | suggestion | 77 | 51 | 51 | false | feat: added support for `import.meta.dirname` and `import.meta.filename` | 20,050 | webpack/webpack | 65,000 | JavaScript | alexander-akait | alexander-akait |
{ dirname, filename }
) => {
if (parserOptions.node === false) return;
let localOptions = options;
if (parserOptions.node) {
localOptions = { ...localOptions, ...parserOptions.node };
}
/**
* @param {string} expressionName expression name
* @param {(module: NormalM... | for tap ordering, we should have a constant instead of hard-setting it to a value | { dirname, filename }
) => {
if (parserOptions.node === false) return;
let localOptions = options;
if (parserOptions.node) {
localOptions = { ...localOptions, ...parserOptions.node };
}
/**
* @param {string} expressionName expression name
* @param {(module: NormalM... | @@ -106,29 +107,56 @@ class NodeStuffPlugin {
);
}
});
+
parser.hooks.rename.for("global").tap(PLUGIN_NAME, (expr) => {
const dep = getGlobalDep(expr);
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
parser.state.module.addPresentationalDependency(dep);
... | lib/NodeStuffPlugin.js | 26 | JavaScript | 0.357 | suggestion | 81 | 51 | 51 | false | feat: added support for `import.meta.dirname` and `import.meta.filename` | 20,050 | webpack/webpack | 65,000 | JavaScript | evenstensberg | alexander-akait |
if (enabled.has(type)) return;
enabled.add(type);
if (typeof type === "string") {
switch (type) {
case "fetch": {
if (compiler.options.experiments.syncWebAssembly) {
// TODO webpack 6 remove FetchCompileWasmPlugin
const FetchCompileWasmPlugin = require("../web/FetchCompileWasmPlugin");
... | Just moved all todo to `defaults` | if (enabled.has(type)) return;
enabled.add(type);
if (typeof type === "string") {
switch (type) {
case "fetch": {
if (compiler.options.experiments.syncWebAssembly) {
const FetchCompileWasmPlugin = require("../web/FetchCompileWasmPlugin");
new FetchCompileWasmPlugin({
mangleImports... | @@ -95,7 +94,6 @@ class EnableWasmLoadingPlugin {
}
case "async-node": {
if (compiler.options.experiments.syncWebAssembly) {
- // TODO webpack 6 remove ReadFileCompileWasmPlugin | lib/wasm/EnableWasmLoadingPlugin.js | 26 | JavaScript | 0.5 | suggestion | 33 | 51 | 51 | false | refactor: use `globalThis` for universal target | 20,061 | webpack/webpack | 65,000 | JavaScript | alexander-akait | alexander-akait |
compiler.options.output.environment.dynamicImport
}).apply(compiler);
}
if (compiler.options.experiments.asyncWebAssembly) {
const ReadFileCompileAsyncWasmPlugin = require("../node/ReadFileCompileAsyncWasmPlugin");
new ReadFileCompileAsyncWasmPlugin({
import:
compile... | Do not use this plugin when `asyncWebAssembly` is not enabled | }
if (compiler.options.experiments.asyncWebAssembly) {
const ReadFileCompileAsyncWasmPlugin = require("../node/ReadFileCompileAsyncWasmPlugin");
new ReadFileCompileAsyncWasmPlugin({
import:
compiler.options.output.module &&
compiler.options.output.environment.dynamicImport... | @@ -119,9 +117,17 @@ class EnableWasmLoadingPlugin {
break;
}
case "universal": {
- const UniversalCompileAsyncWasmPlugin = require("../wasm-async/UniversalCompileAsyncWasmPlugin");
+ if (compiler.options.experiments.syncWebAssembly) {
+ throw new Error(
+ "Universal wasm loading type... | lib/wasm/EnableWasmLoadingPlugin.js | 26 | JavaScript | 0.571 | suggestion | 61 | 35 | 41 | false | refactor: use `globalThis` for universal target | 20,061 | webpack/webpack | 65,000 | JavaScript | alexander-akait | alexander-akait |
"use strict";
const webpack = require("../../../../");
/** @type {import("../../../../").Configuration[]} */
module.exports = [
{
devtool: false,
entry: {
bundle0: "./entry1.js"
},
output: {
filename: "[name].js"
},
optimization: {
runtimeChunk: true
},
plugins: [
new webpack.SourceMapDev... | Let's add an extra test when we have two `SourceMapDevToolPlugin` plugins with different configurations | chunkFilename: "[name].js"
},
plugins: [
new webpack.SourceMapDevToolPlugin({
filename: "[file].test.map",
test: "bundle2.js",
columns: false,
append: false,
namespace: "test",
sourceRoot: "test",
ignoreList: /entry3\.js/
}),
new webpack.SourceMapDevToolPlugin({
filename:... | @@ -0,0 +1,51 @@
+"use strict";
+
+const webpack = require("../../../../");
+
+/** @type {import("../../../../").Configuration[]} */
+module.exports = [
+ {
+ devtool: false,
+ entry: {
+ bundle0: "./entry1.js"
+ },
+ output: {
+ filename: "[name].js"
+ },
+ optimization: {
+ runtimeChunk: true
+ },
+ plu... | test/configCases/source-map/dual-source-map-plugins/webpack.config.js | 26 | JavaScript | 0.5 | suggestion | 104 | 52 | 27 | false | test: dual sourcemap plugins | 20,063 | webpack/webpack | 65,000 | JavaScript | alexander-akait | hai-x |
\`\`\`shell
yarn add -D ${output.packages.map((p) => p.url).join(" ")}
\`\`\`
- pnpm
\`\`\`shell
pnpm add -D ${output.packages.map((p) => p.url).join(" ")}
\`\`\`
`;
/**
* @param {number=} issueNumber PR number
* @re... | What happens if a user maliciously posts a comment containing the `botCommentIdentifier`? The current logic might mistakenly overwrite it.
We could potentially use https://github.com/peter-evans/create-or-update-comment or maybe adopt a similar pattern here? | \`\`\`shell
yarn add -D webpack@${output.packages.map((p) => p.url).join(" ")}
\`\`\`
- pnpm
\`\`\`shell
pnpm add -D webpack@${output.packages.map((p) => p.url).join(" ")}
\`\`\`
`;
/**
* @param {number=} issueNumber P... | @@ -0,0 +1,125 @@
+/* eslint-disable no-console */
+/* eslint-disable camelcase */
+
+import fs from "fs";
+
+/**
+ * @param {{github: EXPECTED_ANY, context: EXPECTED_ANY}} params params
+ */
+export async function run({ github, context }) {
+ const output = JSON.parse(fs.readFileSync("output.json", "utf8"));
+
+ const... | .github/scripts/publish-to-pkg-pr-new.mjs | 26 | JavaScript | 0.786 | question | 259 | 51 | 51 | false | refactor: pkg.pr.new publish | 20,093 | webpack/webpack | 65,000 | JavaScript | 3ru | hai-x |
dependency,
initFragments,
source,
generateContext
);
}
if (module.presentationalDependencies !== undefined) {
for (const dependency of module.presentationalDependencies) {
this.sourceDependency(
module,
dependency,
initFragments,
source,
generateContext
);
... | Looks good now, but I think we will need to refactor it after implementation of all export types, maybe simplify it | const isEmpty =
generateContext.type === "javascript" && exportType === "link";
if (!this._sourceModuleCache.has(generateContext.runtimeRequirements)) {
this._sourceModuleCache.set(
generateContext.runtimeRequirements,
/** @type {Source[]} */ ([])
);
}
const cachedIndex = isEmpty ? 0 : 1;
c... | @@ -220,14 +223,49 @@ class CssGenerator extends Generator {
template.apply(dependency, source, templateContext);
}
+ /**
+ * @param {NormalModule} module the module to generate
+ * @param {InitFragment<GenerateContext>[]} initFragments mutable list of init fragments
+ * @param {GenerateContext & { cssData: C... | lib/css/CssGenerator.js | 26 | JavaScript | 0.786 | refactor | 115 | 51 | 51 | false | perf(css): avoid rendering the same Source multiple times | 20,106 | webpack/webpack | 65,000 | JavaScript | alexander-akait | xiaoxiaojx |
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
const Dependency = require("../Dependency");
const DependencyTemplate = require("../DependencyTemplate");
/** @typedef {import("../Dependency").TRANSITIVE} TRANSITIVE */
/** @typedef {import("../Module")} M... | Don't forget to write it in serilizer and deserilizer | MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
const Dependency = require("../Dependency");
const DependencyTemplate = require("../DependencyTemplate");
/** @typedef {import("../Dependency").TRANSITIVE} TRANSITIVE */
/** @typedef {import("../Module")} M... | @@ -18,11 +18,13 @@ const DependencyTemplate = require("../DependencyTemplate");
class ModuleDependency extends Dependency {
/**
* @param {string} request request path which needs resolving
+ * @param {number} sourceOrder source order
*/
- constructor(request) {
+ constructor(request, sourceOrder = Number.NaN... | lib/dependencies/ModuleDependency.js | 26 | JavaScript | 0.143 | suggestion | 53 | 51 | 51 | false | fix: delay HMR accept dependencies to preserve import attributes | 20,124 | webpack/webpack | 65,000 | JavaScript | alexander-akait | xiaoxiaojx |
To fix this, make sure to include [runtime] in the output.hotUpdateMainFilename option, or use the default config.`)
);
for (const chunkId of removedChunkIds) {
old.removedChunkIds.add(chunkId);
}
for (const chunkId of removedModules) {
old.removedModules.add(chunkId);
... | I like when we have more types :+1: | This might lead to incorrect runtime behavior of the applied update.
To fix this, make sure to include [runtime] in the output.hotUpdateMainFilename option, or use the default config.`)
);
for (const chunkId of removedChunkIds) {
old.removedChunkIds.add(chunkId);
}
for (const ch... | @@ -817,6 +818,7 @@ To fix this, make sure to include [runtime] in the output.hotUpdateMainFilename
filename,
{ removedChunkIds, removedModules, updatedChunkIds, assetInfo }
] of hotUpdateMainContentByFilename) {
+ /** @type {{c: ChunkId[], r: ChunkId[], m: ModuleId[], css?: {r: ChunkId[]}}... | lib/HotModuleReplacementPlugin.js | 26 | JavaScript | 0.357 | suggestion | 36 | 51 | 51 | false | fix(hmr): remove CSS link tags when CSS imports are removed | 20,154 | webpack/webpack | 65,000 | JavaScript | alexander-akait | xiaoxiaojx |
!allStrict &&
allModules.every((m) => /** @type {BuildInfo} */ (m.buildInfo).strict)
) {
const strictBailout = hooks.strictRuntimeBailout.call(renderContext);
strictHeader = strictBailout
? `// runtime can't be in strict mode because ${strictBailout}.\n`
: '"use strict";\n';
if (!strictBailout)... | This is a breaking change, I add explicitly parameter `renderInObject` in `renderModule`, to inform that the module is rendered in object container. Because in array container, we cannot use method shorthand. | if (
!allStrict &&
allModules.every((m) => /** @type {BuildInfo} */ (m.buildInfo).strict)
) {
const strictBailout = hooks.strictRuntimeBailout.call(renderContext);
strictHeader = strictBailout
? `// runtime can't be in strict mode because ${strictBailout}.\n`
: '"use strict";\n';
if (!strictB... | @@ -759,12 +772,16 @@ class JavascriptModulesPlugin {
strictMode: allStrict
};
const moduleSources =
- Template.renderChunkModules(chunkRenderContext, allModules, (module) =>
- this.renderModule(
- module,
- { ...chunkRenderContext, factory: true },
- hooks
- )
+ Template.renderChunkModu... | lib/javascript/JavascriptModulesPlugin.js | 26 | JavaScript | 0.786 | suggestion | 208 | 51 | 51 | false | refactor: use method shorthand syntax to render module content in __webpack_modules__ object | 20,158 | webpack/webpack | 65,000 | JavaScript | JSerFeng | JSerFeng |
"module",
"renderContext"
]),
chunkHash: new SyncHook(["chunk", "hash", "context"])
};
compilationHooksMap.set(compilation, hooks);
}
return hooks;
}
constructor() {
/** @type {WeakMap<Source, ModuleFactoryCacheEntry>} */
this._moduleFactoryCache = new WeakMap();
}
/**
* Apply th... | Why we need to change stage here? | }
return hooks;
}
constructor() {
/** @type {WeakMap<Source, ModuleFactoryCacheEntry>} */
this._moduleFactoryCache = new WeakMap();
}
/**
* Apply the plugin
* @param {Compiler} compiler the compiler instance
* @returns {void}
*/
apply(compiler) {
compiler.hooks.compilation.tap(
PLUGIN_NAME,
... | @@ -217,10 +218,17 @@ class CssModulesPlugin {
*/
apply(compiler) {
compiler.hooks.compilation.tap(
- PLUGIN_NAME,
+ {
+ name: PLUGIN_NAME,
+ stage: 100
+ }, | lib/css/CssModulesPlugin.js | 26 | JavaScript | 0.286 | question | 33 | 51 | 51 | false | feat: remove empty needless js output for normal css module | 20,162 | webpack/webpack | 65,000 | JavaScript | alexander-akait | JSerFeng |
return hooks;
}
constructor() {
/** @type {WeakMap<Source, ModuleFactoryCacheEntry>} */
this._moduleFactoryCache = new WeakMap();
}
/**
* Apply the plugin
* @param {Compiler} compiler the compiler instance
* @returns {void}
*/
apply(compiler) {
compiler.hooks.compilation.tap(
{
name: PLUGI... | There is another question, what about `require` or other things, I think we should try to solve it for any cases, not just for side effect imports... | }
/**
* Apply the plugin
* @param {Compiler} compiler the compiler instance
* @returns {void}
*/
apply(compiler) {
compiler.hooks.compilation.tap(
PLUGIN_NAME,
(compilation, { normalModuleFactory }) => {
const hooks = CssModulesPlugin.getCompilationHooks(compilation);
compilation.dependencyF... | @@ -217,10 +218,17 @@ class CssModulesPlugin {
*/
apply(compiler) {
compiler.hooks.compilation.tap(
- PLUGIN_NAME,
+ {
+ name: PLUGIN_NAME,
+ stage: 100 // ensure we set compilation.dependencyTemplates after JavascriptModulesPlugin
+ },
(compilation, { normalModuleFactory }) => {
const hook... | lib/css/CssModulesPlugin.js | 26 | JavaScript | 0.714 | suggestion | 149 | 51 | 51 | false | feat: remove empty needless js output for normal css module | 20,162 | webpack/webpack | 65,000 | JavaScript | alexander-akait | JSerFeng |
}
default:
return null;
}
}
/**
* @param {NormalModule} module fresh module
* @returns {SourceTypes} available types (do not mutate)
*/
getTypes(module) {
// if use style-sheet or string exportsType of CSS module, we always need to generate JavaScript output.
if (this._generatesJsOnly(module))... | It seems we can remove the `module.hot !== true` line.
Since we no longer generate JS code for `import "./index.css"`, it doesn’t exist in the output `__webpack_modules__`, Its behavior is closer to being self-accepted. Then will skip generating the side-effect [hmrCode](https://github.com/webpack/webpack/blob/main/li... | }
default:
return null;
}
}
/**
* @param {NormalModule} module fresh module
* @returns {SourceTypes} available types (do not mutate)
*/
getTypes(module) {
const exportType = /** @type {BuildMeta} */ (module.buildMeta).exportType;
const sourceTypes = new Set();
const connections = this._modu... | @@ -467,19 +468,37 @@ class CssGenerator extends Generator {
* @returns {SourceTypes} available types (do not mutate)
*/
getTypes(module) {
+ // if use style-sheet or string exportsType of CSS module, we always need to generate JavaScript output.
if (this._generatesJsOnly(module)) {
return JAVASCRIPT_TY... | lib/css/CssGenerator.js | 26 | JavaScript | 0.857 | suggestion | 370 | 51 | 51 | false | feat: remove empty needless js output for normal css module | 20,162 | webpack/webpack | 65,000 | JavaScript | xiaoxiaojx | JSerFeng |
* @param {ModuleLibraryPluginOptions} options the plugin options
*/
constructor(options) {
super({
pluginName: "ModuleLibraryPlugin",
type: options.type
});
}
/**
* Apply the plugin
* @param {Compiler} compiler the compiler instance
* @returns {void}
*/
apply(compiler) {
super.apply(compile... | Sometimes I think we should improve buildMeta and buildInfo types, I think we have it here always, anyway let's do it separately | /**
* @param {ModuleLibraryPluginOptions} options the plugin options
*/
constructor(options) {
super({
pluginName: "ModuleLibraryPlugin",
type: options.type
});
}
/**
* Apply the plugin
* @param {Compiler} compiler the compiler instance
* @returns {void}
*/
apply(compiler) {
super.apply(co... | @@ -69,7 +70,28 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
const { onDemandExportsGeneration } =
ConcatenatedModule.getCompilationHooks(compilation);
- onDemandExportsGeneration.tap(PLUGIN_NAME, (_module) => true);
+ on... | lib/library/ModuleLibraryPlugin.js | 26 | JavaScript | 0.786 | suggestion | 128 | 51 | 51 | false | fix: module library export definitions when multiple runtimes | 20,179 | webpack/webpack | 65,000 | JavaScript | alexander-akait | hai-x |
`__webpack_modules__[moduleId](module, module.exports, ${RuntimeGlobals.require});`
]);
const needModuleId = runtimeRequirements.has(RuntimeGlobals.moduleId);
const needModuleLoaded = runtimeRequirements.has(
RuntimeGlobals.moduleLoaded
);
const needModuleDefer = runtimeRequirements.has(
Runtim... | It should be only for development mode | const needModuleId = runtimeRequirements.has(RuntimeGlobals.moduleId);
const needModuleLoaded = runtimeRequirements.has(
RuntimeGlobals.moduleLoaded
);
const needModuleDefer = runtimeRequirements.has(
RuntimeGlobals.makeDeferredNamespaceObject
);
const content = Template.asString([
"// Check if mod... | @@ -1561,6 +1563,12 @@ class JavascriptModulesPlugin {
])
: Template.indent("return cachedModule.exports;"),
"}",
+ "// Check if module exists",
+ "if (__webpack_modules__[moduleId] === undefined) {",
+ Template.indent([
+ "throw new Error('Cannot find module with id \"' + moduleId + '\". The mo... | lib/javascript/JavascriptModulesPlugin.js | 26 | JavaScript | 0.286 | suggestion | 38 | 51 | 51 | false | fix: add null check for module existence with helpful error message | 20,221 | webpack/webpack | 65,000 | JavaScript | alexander-akait | samarthsinh2660 |
]);
const needModuleId = runtimeRequirements.has(RuntimeGlobals.moduleId);
const needModuleLoaded = runtimeRequirements.has(
RuntimeGlobals.moduleLoaded
);
const needModuleDefer = runtimeRequirements.has(
RuntimeGlobals.makeDeferredNamespaceObject
);
const content = Template.asString([
"// Che... | This seems good — we can make the error message fully match Node.js and set the error code to MODULE_NOT_FOUND.

| ]);
const needModuleId = runtimeRequirements.has(RuntimeGlobals.moduleId);
const needModuleLoaded = runtimeRequirements.has(
RuntimeGlobals.moduleLoaded
);
const needModuleDefer = runtimeRequirements.has(
RuntimeGlobals.makeDeferredNamespaceObject
);
const content = Template.asString([
"// Che... | @@ -1561,6 +1561,17 @@ class JavascriptModulesPlugin {
])
: Template.indent("return cachedModule.exports;"),
"}",
+ // Add helpful error message in development mode when module is not found
+ ...(outputOptions.pathinfo
+ ? [
+ "// Check if module exists (development only)",
+ "if (__webp... | lib/javascript/JavascriptModulesPlugin.js | 26 | JavaScript | 0.857 | suggestion | 248 | 51 | 51 | false | fix: add null check for module existence with helpful error message | 20,221 | webpack/webpack | 65,000 | JavaScript | xiaoxiaojx | samarthsinh2660 |
import fs from "fs";
it(`should generate import statement for built-in module in node`, () => {
const path = require("path");
const content = fs.readFileSync(__filename, "utf-8");
expect(content).toMatch(/import(.*)from(\s*)"fs"/);
expect(content).toMatch(/import(.*)from(\s*)"path"/);
expect(path.basename(__file... | Let's add a test case where we import all Node.js modules (just take them from NodeTargetPlugin and generate a module with require's) just to ensure we can replace `require` on `import` for all Node.js modules (It seems like there was a bug with this once, but I could be wrong, let's check it out.) | const assertBuiltin = require("assert");
const asyncHooks = require("async_hooks");
const buffer = require("buffer");
const childProcess = require("child_process");
const cluster = require("cluster");
const consoleBuiltin = require("console");
const constants = require("constants");
const crypto = require("crypto");
co... | @@ -0,0 +1,10 @@
+import fs from "fs"; | test/configCases/node/output-module-external/index.js | 1 | JavaScript | 1 | bug | 299 | 11 | 26 | false | feat: improve rendering node built-in module | 20,255 | webpack/webpack | 65,000 | JavaScript | alexander-akait | hai-x |
* @param {ModuleGraph} moduleGraph the module graph
* @param {boolean | undefined} strict the importing module is strict
* @returns {ExportsType} export type
* "namespace": Exports is already a namespace object. namespace = exports.
* "dynamic": Check at runtime if __esModule is set. When set: namespace = { .... | Do you think we need some cache here? | if (dep) {
fallbackModule = moduleGraph.getModule(dep);
}
} else {
const block = this.blocks[0];
if (block && block.dependencies.length > 0) {
fallbackModule = moduleGraph.getModule(block.dependencies[0]);
}
}
}
moduleCache.set(this, fallbackModule);
return fallbackModule;
}
... | @@ -179,17 +174,24 @@ class ConsumeSharedModule extends Module {
fallbackModule = moduleGraph.getModule(block.dependencies[0]);
}
}
-
- if (
- fallbackModule &&
- fallbackModule.buildMeta &&
- fallbackModule.buildMeta.exportsType === "namespace"
- ) {
- return "namespace";
- }
}
- ... | lib/sharing/ConsumeSharedModule.js | 26 | JavaScript | 0.071 | performance | 37 | 51 | 51 | false | refactor: improve interop for ConsumeSharedModule | 20,268 | webpack/webpack | 65,000 | JavaScript | hai-x | hai-x |
const dep = new ConstDependency(
stringify,
/** @type {Range} */ (expr.range)
);
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
parser.state.module.addPresentationalDependency(dep);
return true;
});
parser.hooks.evaluateTypeof
.for("import.met... | Looks good, but let's do it under the option, we have `D(parserOptions, "importMeta", true);` right now, but we need `importMeta: boolean | "preserve-unknown"`, let's set `preserve-unknown` when `output.module` is `true`, we still should replace it when `output.module` is `false`, otherwise code will not work | return true;
}
}
});
parser.hooks.expression
.for("import.meta.env")
.tap(PLUGIN_NAME, (expr) => {
const { stringify } =
collectImportMetaEnvDefinitions(compilation);
const dep = new ConstDependency(
stringify,
/** @type {Range} */ (e... | @@ -380,27 +378,11 @@ class ImportMetaPlugin {
);
// Unknown properties
- parser.hooks.unhandledExpressionMemberChain
- .for("import.meta")
- .tap(PLUGIN_NAME, (expr, members) => {
- // keep import.meta.env unknown property
- // don't evaluate import.meta.env.UNKNOWN_PROPERTY ->... | lib/dependencies/ImportMetaPlugin.js | 26 | JavaScript | 0.857 | suggestion | 310 | 51 | 51 | false | feat: keep unknown import.meta properties | 20,312 | webpack/webpack | 65,000 | JavaScript | alexander-akait | xiaoxiaojx |
)
);
} else {
entryOptions.name = importOptions.webpackChunkName;
}
}
}
if (
!Object.prototype.hasOwnProperty.call(entryOptions, "name") &&
options &&
typeof options.name === "string"
) {
entryOptions.name = options.name;
... | Just idea - what it we will add the `circular` property with `true` value for such case(s) and when ignore chunk creation in buildGraph, so we will not have circular dependency warning | }
}
}
if (
!Object.prototype.hasOwnProperty.call(entryOptions, "name") &&
options &&
typeof options.name === "string"
) {
entryOptions.name = options.name;
}
if (entryOptions.runtime === undefined) {
const i = workerIndexMap.get(parser.st... | @@ -370,37 +374,51 @@ class WorkerPlugin {
entryOptions.name = options.name;
}
- if (entryOptions.runtime === undefined) {
- const i = workerIndexMap.get(parser.state) || 0;
- workerIndexMap.set(parser.state, i + 1);
- const name = `${cachedContextify(
- parser.state.modul... | lib/dependencies/WorkerPlugin.js | 26 | JavaScript | 0.5 | suggestion | 184 | 51 | 51 | false | fix: reuse async entrypoint for same Worker URL within a module | 20,345 | webpack/webpack | 65,000 | JavaScript | alexander-akait | xiaoxiaojx |
conditionNames: ["import", "module", "..."],
extensions: [...jsExtensions]
});
/** @type {() => ResolveOptions} */
const workerDeps = () => {
const options = esmDeps();
const conditionNames = options.conditionNames
? ["worker", ...options.conditionNames]
: options.conditionNames;
return {
...opt... | We should not lose `preferRelative` | conditionNames: ["import", "module", "..."],
extensions: [...jsExtensions]
});
/** @type {() => ResolveOptions} */
const workerDeps = () => {
const options = esmDeps();
const conditionNames = options.conditionNames
? ["worker", ...options.conditionNames]
: options.conditionNames;
return {
...opt... | @@ -2005,10 +2018,7 @@ const getResolveDefaults = ({
url: {
preferRelative: true
},
- worker: {
- ...esmDeps(),
- preferRelative: true | lib/config/defaults.js | 26 | JavaScript | 0.5 | suggestion | 35 | 51 | 51 | false | feat: resolve worker via condition name | 20,347 | webpack/webpack | 65,000 | JavaScript | alexander-akait | hai-x |
import bytes from "./unused.png?bytes";
import inlined from "./unused.png?inline";
import source from "./unused.png?source";
import resource from "./used.png";
it("should not include unused assets", () => {
expect(resource).toMatch(/\.png/);
expect(__STATS__.modules.find((m) => m.name.includes("/used.png"))).toEqual... | What about to rewrite test to see that unused module was removed, we have `__webpack_modules__` to check them in chunk | import asset from "./unused.png?asset";
import bytes from "./unused.png?bytes";
import inlined from "./unused.png?inline";
import source from "./unused.png?source";
import resource from "./used.png";
it("should not include unused assets", () => {
expect(resource).toMatch(/\.png/);
expect(__webpack_modules__["./used... | @@ -0,0 +1,23 @@
+import bytes from "./unused.png?bytes";
+import inlined from "./unused.png?inline";
+import source from "./unused.png?source";
+import resource from "./used.png";
+
+it("should not include unused assets", () => {
+ expect(resource).toMatch(/\.png/);
+ expect(__STATS__.modules.find((m) => m.name.includ... | test/configCases/side-effects/asset-module/index.js | 15 | JavaScript | 0.714 | suggestion | 118 | 24 | 16 | false | feat: consider asset module as side-effect-free | 20,352 | webpack/webpack | 65,000 | JavaScript | alexander-akait | hai-x |
options: CleanOptions & { dry: boolean };
/**
* Apply the plugin
*/
apply(compiler: Compiler): void;
static getCompilationHooks(
compilation: Compilation
): CleanPluginCompilationHooks;
}
declare interface CleanPluginCompilationHooks {
/**
* when returning true the file/directory will be kept during clea... | Looks like our types generator is broken here, WIP | hash: {
tap: <AdditionalOptions>(
options:
| string
| (TapOptions & { name: string } & IfSet<AdditionalOptions>),
fn: (hash: Hash) => void
) => void;
};
hashForChunk: {
tap: <AdditionalOptions>(
options:
| string
| (TapOptions & { name: string } & IfSet<AdditionalOptions>)... | @@ -1929,6 +1920,16 @@ declare interface CleanPluginCompilationHooks {
*/
keep: SyncBailHook<[string], boolean | void>;
}
+declare interface CodeGenMapOverloads {
+ get: <K extends string>(key: K) => undefined | CodeGenValue<K>;
+ set: <K extends string>(
+ key: K,
+ value: CodeGenValue<K>
+ ) => CodeGeneration... | types.d.ts | 26 | TypeScript | 0.429 | bug | 50 | 51 | 51 | false | refactor: fix some types | 20,412 | webpack/webpack | 65,000 | JavaScript | alexander-akait | alexander-akait |
"use strict";
const fs = require("fs");
const path = require("path");
// When --write is set, files will be written in place
// Otherwise it only prints outdated files
const doWrite = process.argv.includes("--write");
const files = ["lib/util/hash/xxhash64.js", "lib/util/hash/md4.js"];
(async () => {
const ascFile... | keeping only the Node syntax lint suppression for dynamic import.
| "use strict";
const fs = require("fs");
const path = require("path");
// When --write is set, files will be written in place
// Otherwise it only prints outdated files
const doWrite = process.argv.includes("--write");
const files = ["lib/util/hash/xxhash64.js", "lib/util/hash/md4.js"];
(async () => {
// eslint-dis... | @@ -10,11 +10,9 @@ const doWrite = process.argv.includes("--write");
const files = ["lib/util/hash/xxhash64.js", "lib/util/hash/md4.js"];
(async () => {
- // TODO: fix me after update typescript to v5
- // eslint-disable-next-line no-warning-comments
- // @ts-ignore
- // eslint-disable-next-line import/no-unresolve... | tooling/generate-wasm-code.js | 14 | JavaScript | 0.143 | style | 66 | 39 | 39 | false | refactor: remove stale ts-ignore statements | 20,502 | webpack/webpack | 65,000 | JavaScript | stefanbinoj | stefanbinoj |
"use strict";
const fs = require("fs");
const path = require("path");
// When --write is set, files will be written in place
// Otherwise it only prints outdated files
const doWrite = process.argv.includes("--write");
const files = ["lib/util/hash/xxhash64.js", "lib/util/hash/md4.js"];
(async () => {
const ascFile... | Introduced variable so `checkJs` doesn't raise TS2307 on a literal | "use strict";
const fs = require("fs");
const path = require("path");
// When --write is set, files will be written in place
// Otherwise it only prints outdated files
const doWrite = process.argv.includes("--write");
const files = ["lib/util/hash/xxhash64.js", "lib/util/hash/md4.js"];
(async () => {
// eslint-dis... | @@ -10,11 +10,9 @@ const doWrite = process.argv.includes("--write");
const files = ["lib/util/hash/xxhash64.js", "lib/util/hash/md4.js"];
(async () => {
- // TODO: fix me after update typescript to v5
- // eslint-disable-next-line no-warning-comments
- // @ts-ignore
- // eslint-disable-next-line import/no-unresolve... | tooling/generate-wasm-code.js | 13 | JavaScript | 0.357 | suggestion | 66 | 38 | 38 | false | refactor: remove stale ts-ignore statements | 20,502 | webpack/webpack | 65,000 | JavaScript | stefanbinoj | stefanbinoj |
}
}
declare module "typescript-iterable" {
// New iterator interfaces from `lib.es2015.iterable.d.ts` for compatibility with old typescript versions and `dispose`
interface Disposable {
[Symbol.dispose](): void;
}
export interface IteratorObject<T, TReturn = unknown, TNext = unknown>
extends Iterator<T, TRet... | ts was complaining about dynamic import added declaration here to remove the error | interface ProcessVersions {
pnp: "1" | "3";
}
}
declare module "typescript-iterable" {
// New iterator interfaces from `lib.es2015.iterable.d.ts` for compatibility with old typescript versions and `dispose`
interface Disposable {
[Symbol.dispose](): void;
}
export interface IteratorObject<T, TReturn = unkno... | @@ -34,6 +34,11 @@ declare module "typescript-iterable" {
}
}
+declare module "assemblyscript/asc" { | declarations.d.ts | 26 | TypeScript | 0.643 | suggestion | 82 | 51 | 51 | false | refactor: remove stale ts-ignore statements | 20,502 | webpack/webpack | 65,000 | JavaScript | stefanbinoj | stefanbinoj |
// New iterator interfaces from `lib.es2015.iterable.d.ts` for compatibility with old typescript versions and `dispose`
interface Disposable {
[Symbol.dispose](): void;
}
export interface IteratorObject<T, TReturn = unknown, TNext = unknown>
extends Iterator<T, TReturn, TNext>, Disposable {
[Symbol.iterator]... | `assemblyscript/asc` has own types, we need to use it - https://github.com/AssemblyScript/assemblyscript/blob/main/dist/asc.d.ts |
declare module "typescript-iterable" {
// New iterator interfaces from `lib.es2015.iterable.d.ts` for compatibility with old typescript versions and `dispose`
interface Disposable {
[Symbol.dispose](): void;
}
export interface IteratorObject<T, TReturn = unknown, TNext = unknown>
extends Iterator<T, TReturn, ... | @@ -34,6 +34,11 @@ declare module "typescript-iterable" {
}
}
+declare module "assemblyscript/asc" {
+ const asc: any;
+ export default asc;
+} | declarations.d.ts | 26 | TypeScript | 1 | suggestion | 128 | 51 | 51 | false | refactor: remove stale ts-ignore statements | 20,502 | webpack/webpack | 65,000 | JavaScript | alexander-akait | stefanbinoj |
import bytes from "./file.bin";
it("should work", () => {
expect(bytes).toBeInstanceOf(Uint8Array);
expect(bytes.length).toBe(8);
expect(Array.from(bytes)).toEqual([0, 0x61, 0x73, 0x6d, 1, 2, 3, 4]);
});
| it should be `import bytes from "./file.bin" with { type: "bytes" } ;` | import bytes from "./file.bin" with { type: "bytes" };
it("should work", () => {
expect(bytes).toBeInstanceOf(Uint8Array);
expect(bytes.length).toBe(8);
expect(Array.from(bytes)).toEqual([0, 0x61, 0x73, 0x6d, 1, 2, 3, 4]);
});
| @@ -0,0 +1,7 @@
+import bytes from "./file.bin"; | test/configCases/target/universal-to-binary/index.js | 1 | JavaScript | 0.857 | suggestion | 70 | 8 | 8 | false | test: add integration test for universal ToBinaryRuntimeModule env sw… | 20,507 | webpack/webpack | 65,000 | JavaScript | alexander-akait | aryanraj45 |
{
"module-rules-test": ["/\\.css$/", "/\\.js$/"],
"module-rules-use": ["css-loader", "babel-loader"]
},
{},
e =>
e.toMatchInlineSnapshot(`
Object {
"module": Object {
"rules": Array [
Object {
"test": /\\\\\\.css\\$/,
"use": "css-loader",
},
... | No issues found. | {
"module-rules-test": ["/\\.css$/", "/\\.js$/"],
"module-rules-use": ["css-loader", "babel-loader"]
},
{},
e =>
e.toMatchInlineSnapshot(`
Object {
"module": Object {
"rules": Array [
Object {
"test": /\\\\\\.css\\$/,
"use": "css-loader",
},
... | @@ -5,6 +5,50 @@ describe("Cli", () => {
expect(getArguments()).toMatchSnapshot();
});
+ it("should generate the correct cli flags with custom schema", () => {
+ const schema = {
+ title: "custom CLI options",
+ type: "object",
+ additionalProperties: false,
+ properties: {
+ "with-reset-description"... | test/Cli.basictest.js | 0 | JavaScript | 1 | none | 16 | 51 | 51 | true | feat: allow specific description for CLI options | 14,953 | webpack/webpack | 65,000 | JavaScript | snitin315 | |
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Alexander Akait @alexander-akait
*/
"use strict";
const createHash = require("./createHash");
/**
* @param {string | Buffer} content content
* @param {string} file file
* @returns {string} generated debug id
*/
module.exports = (content, ... | No issues found. | /*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Alexander Akait @alexander-akait
*/
"use strict";
const createHash = require("./createHash");
/**
* @param {string | Buffer} content content
* @param {string} file file
* @returns {string} generated debug id
*/
module.exports = (content, ... | @@ -0,0 +1,33 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Alexander Akait @alexander-akait
+*/
+
+"use strict";
+
+const createHash = require("./createHash");
+
+/**
+ * @param {string | Buffer} content content
+ * @param {string} file file
+ * @returns {string} generated debug id
+... | lib/util/generateDebugId.js | 0 | JavaScript | 1 | none | 16 | 34 | 34 | true | feat: Add support for injecting sourcemap debug ids | 18,947 | webpack/webpack | 65,000 | JavaScript | timfish | |
case 1:
return {
main: ["./main1.js"]
};
case 2:
return {
main: ["./main2.js"]
};
}
};
/**
* @param {number} i param
* @returns {import("../../../../").Configuration} return
*/
const common = i => ({
entry: {
...entry(i)
},
target: "web",
devtool: false,
experiments: {
css: true
}... | No issues found. | case 1:
return {
main: ["./main1.js"]
};
case 2:
return {
main: ["./main2.js"]
};
}
};
/**
* @param {number} i param
* @returns {import("../../../../").Configuration} return
*/
const common = i => ({
entry: {
...entry(i)
},
target: "web",
devtool: false,
experiments: {
css: true
}... | @@ -0,0 +1,69 @@
+const path = require("path");
+const fs = require("fs");
+const webpack = require("../../../../");
+
+const entry = i => {
+ switch (i) {
+ case 0:
+ return {
+ main: ["./main.css"]
+ };
+ case 1:
+ return {
+ main: ["./main1.js"]
+ };
+ case 2:
+ return {
+ main: ["./main2.js"]
... | test/configCases/css/no-extra-js-exports-output/webpack.config.js | 0 | JavaScript | 1 | none | 16 | 51 | 51 | true | fix(css): avoid extra module.export output for css module | 19,265 | webpack/webpack | 65,000 | JavaScript | hai-x | |
},
output: {
library: {
type: "modern-module",
export: ["lib2"]
}
},
experiments: {
outputModule: true
}
},
{
entry: "./commonjs-static.js",
optimization: {
providedExports: false
},
output: {
library: {
type: "commonjs-static"
}
}
},
{
entry: "./run.js",
plugin... | No issues found. | },
output: {
library: {
type: "modern-module",
export: ["lib2"]
}
},
experiments: {
outputModule: true
}
},
{
entry: "./commonjs-static.js",
optimization: {
providedExports: false
},
output: {
library: {
type: "commonjs-static"
}
}
},
{
entry: "./run.js",
plugin... | @@ -0,0 +1,97 @@
+var webpack = require("../../../../");
+
+/** @type {import("../../../../").Configuration[]} */
+module.exports = [
+ {
+ entry: "./module.js",
+ optimization: {
+ providedExports: false
+ },
+ output: {
+ library: {
+ type: "module"
+ }
+ },
+ experiments: {
+ outputModule: true
+ }... | test/configCases/library/disable-provided-export/webpack.config.js | 0 | JavaScript | 1 | none | 16 | 51 | 51 | true | fix: library module without export statement | 19,411 | webpack/webpack | 65,000 | JavaScript | hai-x | |
/** @type {LoaderContext<EXPECTED_ANY>} */
(loaderContext),
this
);
return /** @type {LoaderContext<EXPECTED_ANY>} */ (loaderContext);
}
// TODO remove `loaderContext` in webpack@6
/**
* @param {LoaderContext<EXPECTED_ANY>} loaderContext loader context
* @param {number} index index
* @returns {L... | No issues found. | /** @type {LoaderContext<EXPECTED_ANY>} */
(loaderContext),
this
);
return /** @type {LoaderContext<EXPECTED_ANY>} */ (loaderContext);
}
// TODO remove `loaderContext` in webpack@6
/**
* @param {LoaderContext<EXPECTED_ANY>} loaderContext loader context
* @param {number} index index
* @returns {L... | @@ -81,11 +81,13 @@ const memoize = require("./util/memoize");
/** @typedef {import("./ModuleTypeConstants").JavaScriptModuleTypes} JavaScriptModuleTypes */
/** @typedef {import("./NormalModuleFactory")} NormalModuleFactory */
/** @typedef {import("./NormalModuleFactory").ResourceDataWithData} ResourceDataWithData *... | lib/NormalModule.js | 0 | JavaScript | 1 | none | 16 | 51 | 51 | true | fix: better types | 19,512 | webpack/webpack | 65,000 | JavaScript | hai-x | |
/** @type {import("../../../../").Configuration} */
module.exports = {
optimization: {
concatenateModules: true
}
};
| No issues found. | /** @type {import("../../../../").Configuration} */
module.exports = {
optimization: {
concatenateModules: true
}
};
| @@ -0,0 +1,6 @@
+/** @type {import("../../../../").Configuration} */
+module.exports = {
+ optimization: {
+ concatenateModules: true
+ }
+}; | test/configCases/parsing/destructuring-namespace-import/webpack.config.js | 0 | JavaScript | 1 | none | 16 | 7 | 7 | true | fix: destructuring namespace import with default | 19,526 | webpack/webpack | 65,000 | JavaScript | alexander-akait | |
expect(() => {
a;
b;
c;
d;
e;
f;
g;
h;
i;
j;
k;
l;
m;
n;
o;
}).not.toThrow();
expect(() => {
withVar;
}).toThrow();
try {
} finally {
return;
}
expect(true).toBe(false);
var a,
[, , b] = [],
{ c, D: d, ["E"]: e = 2 } = {};
var [{ ["_"]: f }, ...g] = [];
do {
switch (g)... | No issues found. | expect(() => {
a;
b;
c;
d;
e;
f;
g;
h;
i;
j;
k;
l;
m;
n;
o;
}).not.toThrow();
expect(() => {
withVar;
}).toThrow();
try {
} finally {
return;
}
expect(true).toBe(false);
var a,
[, , b] = [],
{ c, D: d, ["E"]: e = 2 } = {};
var [{ ["_"]: f }, ...g] = [];
do {
switch (g)... | @@ -0,0 +1,118 @@
+const esm1 = require("./esm1");
+
+expect(esm1.default).toBe("esm1");
+
+it("Shouldn't eliminate hoisted function in current block scope", () => {
+ expect(() => {
+ funcDecl;
+ }).not.toThrow();
+
+ funcDecl();
+ if (true) return;
+ function funcDecl() {}
+ import("./esm3").then(() => {
+ expect(t... | test/configCases/parsing/dead-code-elimination/index.js | 0 | JavaScript | 1 | none | 16 | 51 | 51 | true | fix: eliminate unused statements in certain scenarios | 19,536 | webpack/webpack | 65,000 | JavaScript | hai-x | |
const result = _getDirectories(assets);
expect(Array.from(result)).toEqual(["."]);
});
it("should extract all parent directories from deep nested path", () => {
const assets = new Map([["this/dir/should/not/be/removed/file.ext", 0]]);
const result = _getDirectories(assets);
expect(Array.from(result)... | No issues found. | const result = _getDirectories(assets);
expect(Array.from(result)).toEqual(["."]);
});
it("should extract all parent directories from deep nested path", () => {
const assets = new Map([["this/dir/should/not/be/removed/file.ext", 0]]);
const result = _getDirectories(assets);
expect(Array.from(result)... | @@ -0,0 +1,87 @@
+"use strict";
+
+const {
+ _getDirectories,
+ _hasFile,
+ _isEqualPath
+} = require("../lib/CleanPlugin");
+
+describe("CleanPlugin", () => {
+ describe("_getDirectories", () => {
+ it("should return empty set when assets map is empty", () => {
+ const assets = new Map();
+ const result = _getDir... | test/CleanPlugin.unittest.js | 0 | JavaScript | 1 | none | 16 | 51 | 51 | true | fix: CleanPlugin unlink same file twice | 19,595 | webpack/webpack | 65,000 | JavaScript | xiaoxiaojx | |
import { foo } from "./foo.mjs"
it("Should work with export a function when using CreateFakeNamespaceObjectRuntimeModule", async function(done) {
expect(foo).toBe("foo")
const myModule = await import("module");
// namespace object
expect(typeof myModule).toBe("object");
expect(myModule.builtinModules).toBeDefined... | No issues found. | import { foo } from "./foo.mjs"
it("Should work with export a function when using CreateFakeNamespaceObjectRuntimeModule", async function(done) {
expect(foo).toBe("foo")
const myModule = await import("module");
// namespace object
expect(typeof myModule).toBe("object");
expect(myModule.builtinModules).toBeDefined... | @@ -0,0 +1,17 @@
+import { foo } from "./foo.mjs"
+
+it("Should work with export a function when using CreateFakeNamespaceObjectRuntimeModule", async function(done) {
+ expect(foo).toBe("foo")
+ const myModule = await import("module");
+ // namespace object
+ expect(typeof myModule).toBe("object");
+ expect(myModule.bu... | test/configCases/externals/export-fn-esm/index.js | 0 | JavaScript | 1 | none | 16 | 17 | 17 | true | fix: CreateFakeNamespaceObject supports the export is a function | 19,609 | webpack/webpack | 65,000 | JavaScript | xiaoxiaojx | |
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Haijie Xie @hai-x
*/
"use strict";
const RuntimeGlobals = require("../RuntimeGlobals");
const Template = require("../Template");
/**
* @param {string} type unique identifier used for HMR runtime properties
* @returns {string} HMR runtime c... | No issues found. | /*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Haijie Xie @hai-x
*/
"use strict";
const RuntimeGlobals = require("../RuntimeGlobals");
const Template = require("../Template");
/**
* @param {string} type unique identifier used for HMR runtime properties
* @returns {string} HMR runtime c... | @@ -0,0 +1,37 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Haijie Xie @hai-x
+*/
+
+"use strict";
+
+const RuntimeGlobals = require("../RuntimeGlobals");
+
+const Template = require("../Template");
+
+/**
+ * @param {string} type unique identifier used for HMR runtime properties
+ * ... | lib/hmr/JavascriptHotModuleReplacementHelper.js | 0 | JavaScript | 1 | none | 16 | 38 | 38 | true | refactor: consolidate HMR code | 19,629 | webpack/webpack | 65,000 | JavaScript | hai-x | |
@@ ... @@
- "aliasFields": Array [
- "browser",
- ],
+ "aliasFields": Array [],
@@ ... @@
- "browser",
@@ ... @@
- "aliasFields": Array [
- "browser",
- ],
+ "aliasFields": Array [],
@@ ... @@
- "browser"... | No issues found. | @@ ... @@
- "aliasFields": Array [
- "browser",
- ],
+ "aliasFields": Array [],
@@ ... @@
- "browser",
@@ ... @@
- "aliasFields": Array [
- "browser",
- ],
+ "aliasFields": Array [],
@@ ... @@
- "browser"... | @@ -2659,6 +2659,183 @@ describe("snapshots", () => {
+ /^(.+?[\\\\/]node_modules[\\\\/])/,
`)
);
+
+ test(
+ "target node with ESM output",
+ { target: "node14", experiments: { outputModule: true } },
+ e =>
+ e.toMatchInlineSnapshot(`
+ - Expected
+ + Received
+
+ @@ ... @@
+ - "output... | test/Defaults.unittest.js | 0 | JavaScript | 1 | none | 16 | 51 | 51 | true | feat: enable ESM worker chunk loading for Node.js targets | 19,640 | webpack/webpack | 65,000 | JavaScript | 3ru | |
}
);
const hooks = getCompilationHooks(compilation);
/**
* @param {Set<Chunk>} chunks the chunks to render
* @param {ChunkGraph} chunkGraph the chunk graph
* @param {Chunk=} runtimeChunk the runtime chunk
* @returns {Source|undefined} the source
*/
const withDependentChunks = (chunks... | No issues found. | }
);
const hooks = getCompilationHooks(compilation);
/**
* @param {Set<Chunk>} chunks the chunks to render
* @param {ChunkGraph} chunkGraph the chunk graph
* @param {Chunk=} runtimeChunk the runtime chunk
* @returns {Source|undefined} the source
*/
const withDependentChunks = (chunks... | @@ -164,24 +164,33 @@ class ModuleChunkFormatPlugin {
return source;
}
};
- hooks.renderMain.tap(PLUGIN_NAME, (modules, renderContext) => {
- const { chunk, chunkGraph } = renderContext;
- const entryDependentChunks =
- chunkGraph.getChunkEntryDependentChunksIterable(chunk);
- const source... | lib/esm/ModuleChunkFormatPlugin.js | 0 | JavaScript | 1 | none | 16 | 51 | 51 | true | fix(esm): ensure dependent chunks are imported before startup & fix duplicate export of 'default' | 19,661 | webpack/webpack | 65,000 | JavaScript | xiaoxiaojx | |
"use strict";
const webpack = require("../../../../");
/** @type {import("../../../../").Configuration} */
module.exports = {
entry: "./test.js",
resolve: {
alias: {
"ignored-module": false,
"./ignored-module": false
}
},
plugins: [new webpack.IgnorePlugin({ resourceRegExp: /(b\.js|b)$/ })],
optimizati... | No issues found. | "use strict";
const webpack = require("../../../../");
/** @type {import("../../../../").Configuration} */
module.exports = {
entry: "./test.js",
resolve: {
alias: {
"ignored-module": false,
"./ignored-module": false
}
},
plugins: [new webpack.IgnorePlugin({ resourceRegExp: /(b\.js|b)$/ })],
optimizati... | @@ -0,0 +1,18 @@
+"use strict";
+
+const webpack = require("../../../../");
+
+/** @type {import("../../../../").Configuration} */
+module.exports = {
+ entry: "./test.js",
+ resolve: {
+ alias: {
+ "ignored-module": false,
+ "./ignored-module": false
+ }
+ },
+ plugins: [new webpack.IgnorePlugin({ resourceRegExp... | test/configCases/ignore/side-effects/webpack.config.js | 0 | JavaScript | 1 | none | 16 | 19 | 19 | true | fix: tree-shaking unused `RawModule` | 19,671 | webpack/webpack | 65,000 | JavaScript | colinaaa | |
): string | void | Buffer | Promise<string | Buffer>;
}
declare interface LoaderItem {
loader: string;
options?: null | string | Record<string, any>;
ident: null | string;
type: null | string;
}
declare interface LoaderModule<OptionsType = {}, ContextAdditions = {}> {
default?:
| RawLoaderDefinitionFunction<Opt... | No issues found. | ): string | void | Buffer | Promise<string | Buffer>;
}
declare interface LoaderItem {
loader: string;
options?: null | string | Record<string, any>;
ident: null | string;
type: null | string;
}
declare interface LoaderModule<OptionsType = {}, ContextAdditions = {}> {
default?:
| RawLoaderDefinitionFunction<Opt... | @@ -4,6 +4,7 @@
* Run `yarn fix:special` to update
*/
+import { Parser as ParserImport } from "acorn";
import { Buffer } from "buffer";
import { Scope } from "eslint-scope";
import {
@@ -6436,7 +6437,7 @@ declare class JavascriptModulesPlugin {
): TemplatePath;
static chunkHasJs: (chunk: Chunk, chunkGraph:... | types.d.ts | 0 | TypeScript | 1 | none | 16 | 51 | 51 | true | refactor: extend importPhasesPlugin only when enable deferImport | 19,689 | webpack/webpack | 65,000 | JavaScript | hai-x | |
"}",
`if(${RuntimeGlobals.esmRuntime}) ${RuntimeGlobals.esmRuntime}(${RuntimeGlobals.require});`,
`for(;i < ${RuntimeGlobals.esmIds}.length; i++) {`,
Template.indent([
`chunkId = ${RuntimeGlobals.esmIds}[i];`,
`if(${RuntimeGlobals.hasOwnProperty}(installedChunks, chunkId) && instal... | No issues found. | "}",
`if(${RuntimeGlobals.esmRuntime}) ${RuntimeGlobals.esmRuntime}(${RuntimeGlobals.require});`,
`for(;i < ${RuntimeGlobals.esmIds}.length; i++) {`,
Template.indent([
`chunkId = ${RuntimeGlobals.esmIds}[i];`,
`if(${RuntimeGlobals.hasOwnProperty}(installedChunks, chunkId) && instal... | @@ -168,29 +168,33 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
withLoading || withExternalInstallChunk
? `var installChunk = ${runtimeTemplate.basicFunction("data", [
runtimeTemplate.destructureObject(
- ["__webpack_ids__", "__webpack_modules__", "__webpack_runtime__"],
+ ... | lib/esm/ModuleChunkLoadingRuntimeModule.js | 0 | JavaScript | 1 | none | 16 | 51 | 51 | true | perf: standardize ESM naming management | 19,730 | webpack/webpack | 65,000 | JavaScript | xiaoxiaojx | |
const { _getDirectories } = require("../lib/CleanPlugin");
describe("CleanPlugin", () => {
describe("_getDirectories", () => {
it("should return empty set when assets map is empty", () => {
const assets = new Map();
const result = _getDirectories(assets);
expect(result).toBeInstanceOf(Set);
expect(resul... | No issues found. | const { _getDirectories } = require("../lib/CleanPlugin");
describe("CleanPlugin", () => {
describe("_getDirectories", () => {
it("should return empty set when assets map is empty", () => {
const assets = new Map();
const result = _getDirectories(assets);
expect(result).toBeInstanceOf(Set);
expect(resul... | @@ -1,10 +1,6 @@
"use strict";
-const {
- _getDirectories,
- _hasFile,
- _isEqualPath
-} = require("../lib/CleanPlugin");
+const { _getDirectories } = require("../lib/CleanPlugin");
describe("CleanPlugin", () => {
describe("_getDirectories", () => {
@@ -54,29 +50,4 @@ describe("CleanPlugin", () => {
expect(... | test/CleanPlugin.unittest.js | 0 | JavaScript | 1 | none | 16 | 51 | 51 | true | fix: fix potential performance issue in CleanPlugin | 19,735 | webpack/webpack | 65,000 | JavaScript | xiaoxiaojx | |
break;
}
},
// Management API
check: hotCheck,
apply: hotApply,
status: function (l) {
if (!l) return currentStatus;
registeredStatusHandlers.push(l);
},
addStatusHandler: function (l) {
registeredStatusHandlers.push(l);
},
removeStatusHandler: function (l) {
var id... | No issues found. | break;
}
},
// Management API
check: hotCheck,
apply: hotApply,
status: function (l) {
if (!l) return currentStatus;
registeredStatusHandlers.push(l);
},
addStatusHandler: function (l) {
registeredStatusHandlers.push(l);
},
removeStatusHandler: function (l) {
var id... | @@ -354,38 +354,50 @@ module.exports = function () {
};
var outdatedModules = [];
- results.forEach(function (result) {
- if (result.apply) {
- var modules = result.apply(reportError);
- if (modules) {
- for (var i = 0; i < modules.length; i++) {
- outdatedModules.push(modules[i]);
- }
- ... | lib/hmr/HotModuleReplacement.runtime.js | 0 | JavaScript | 1 | none | 16 | 51 | 51 | true | feat: Support accept asyncModule | 19,741 | webpack/webpack | 65,000 | JavaScript | xiaoxiaojx | |
const webpack = require("../../../../");
/** @type {import("../../../../").Configuration[]} */
module.exports = [
{
output: {
module: true
},
target: ["node"],
experiments: {
outputModule: true
},
plugins: [
{
apply(compiler) {
compiler.hooks.compilation.tap("Test", (compilation) => {
... | No issues found. | const webpack = require("../../../../");
/** @type {import("../../../../").Configuration[]} */
module.exports = [
{
output: {
module: true
},
target: ["node"],
experiments: {
outputModule: true
},
plugins: [
{
apply(compiler) {
compiler.hooks.compilation.tap("Test", (compilation) => {
... | @@ -0,0 +1,53 @@
+"use strict";
+
+const webpack = require("../../../../");
+
+/** @type {import("../../../../").Configuration[]} */
+module.exports = [
+ {
+ output: {
+ module: true
+ },
+ target: ["node"],
+ experiments: {
+ outputModule: true
+ },
+ plugins: [
+ {
+ apply(compiler) {
+ compiler.h... | test/configCases/module/non-webpack-require-warning/webpack.config.js | 0 | JavaScript | 1 | none | 16 | 51 | 51 | true | fix: `needCreateRequire` should be set to true only when module output and node target | 19,761 | webpack/webpack | 65,000 | JavaScript | hai-x | |
type: "umd"
}
},
resolve: {
alias: {
external: "./non-external",
"external-named": "./non-external-named"
}
}
},
{
output: {
uniqueName: "true-iife-umd",
filename: "true-iife-umd.js",
library: {
type: "umd"
},
iife: true
},
resolve: {
alias: {
external: "./no... | No issues found. | type: "umd"
}
},
resolve: {
alias: {
external: "./non-external",
"external-named": "./non-external-named"
}
}
},
{
output: {
uniqueName: "true-iife-umd",
filename: "true-iife-umd.js",
library: {
type: "umd"
},
iife: true
},
resolve: {
alias: {
external: "./no... | @@ -806,7 +806,64 @@ module.exports = (env, { testPath }) => [
{
entry: "./class-commonjs",
output: {
- filename: "commonjs-bundle-to-esm.mjs",
+ uniqueName: "class-commonjs",
+ filename: "commonjs-bundle-to-esm-1.mjs",
+ module: true,
+ library: {
+ type: "module"
+ }
+ },
+ experiments: {
+ ... | test/configCases/library/0-create-library/webpack.config.js | 0 | JavaScript | 1 | none | 16 | 51 | 51 | true | test: more case about cjs bundle to esm lib | 19,787 | webpack/webpack | 65,000 | JavaScript | hai-x | |
it("should compile fine (warmup)", async () => {
const data = {
"index.js": `import file from "./file.js";
export default 40 + file;
`,
"file.js": "export default 2;"
};
await updateSrc(data);
await compile();
expect(execute()).toBe(42);
}, 100000);
it("should merge multiple small files", async () ... | No issues found. |
it("should compile fine (warmup)", async () => {
const data = {
"index.js": `import file from "./file.js";
export default 40 + file;
`,
"file.js": "export default 2;"
};
await updateSrc(data);
await compile();
expect(execute()).toBe(42);
}, 100000);
it("should merge multiple small files", async () ... | @@ -82,6 +82,16 @@ describe("Persistent Caching", () => {
);
});
+ const getCacheFileTimes = async () => {
+ const cacheFiles = (await readdir(cachePath)).sort();
+ return new Map(
+ cacheFiles.map((f) => [
+ f,
+ fs.statSync(path.join(cachePath, f)).mtime.toString()
+ ])
+ );
+ };
+
const execu... | test/PersistentCaching.test.js | 0 | JavaScript | 1 | none | 16 | 51 | 51 | true | feat: add snapshot.contextModule to configure snapshots for context m… | 19,798 | webpack/webpack | 65,000 | JavaScript | xiaoxiaojx | |
expect(m.default).toBe(3);
expect(m.usedExports).toEqual(["default", "usedExports"]);
done();
});
it("should get warning on using 'webpackExports' with statically analyze-able dynamic import", async (done) => {
const m = await import(/* webpackExports: ["default"] */"./dir1/a?2");
expect(m.a).toBe(1);
done();
})... | No issues found. | expect(m.default).toBe(3);
expect(m.usedExports).toEqual(["default", "usedExports"]);
done();
});
it("should get warning on using 'webpackExports' with statically analyze-able dynamic import", async (done) => {
const m = await import(/* webpackExports: ["default"] */"./dir1/a?2");
expect(m.a).toBe(1);
done();
})... | @@ -0,0 +1,53 @@
+it("should load only used exports", async (done) => {
+ const m = await import("./dir1/a");
+ expect(m.default).toBe(3);
+ expect(m.usedExports).toEqual(["default", "usedExports"]);
+ done();
+});
+
+it("should get warning on using 'webpackExports' with statically analyze-able dynamic import", async (... | test/cases/chunks/statical-dynamic-import/index.js | 0 | JavaScript | 1 | none | 16 | 51 | 51 | true | feat: static analyze member expression for dynamic import | 19,818 | webpack/webpack | 65,000 | JavaScript | ahabhgk | |
throw new Error(
`Library name must be unset. ${AbstractLibraryPlugin.COMMON_LIBRARY_NAME_MESSAGE}`
);
}
const _name = /** @type {string} */ (name);
return {
name: _name,
export: library.export
};
}
/**
* @param {Source} source source
* @param {Module} module module
* @param {StartupRen... | No issues found. | throw new Error(
`Library name must be unset. ${AbstractLibraryPlugin.COMMON_LIBRARY_NAME_MESSAGE}`
);
}
const _name = /** @type {string} */ (name);
return {
name: _name,
export: library.export
};
}
/**
* @param {Source} source source
* @param {Module} module module
* @param {StartupRen... | @@ -6,11 +6,12 @@
"use strict";
const { ConcatSource } = require("webpack-sources");
+const { UsageState } = require("../ExportsInfo");
const RuntimeGlobals = require("../RuntimeGlobals");
const Template = require("../Template");
-const CommonJsSelfReferenceDependency = require("../dependencies/CommonJsSelfRefere... | lib/library/ModuleLibraryPlugin.js | 0 | JavaScript | 1 | none | 16 | 51 | 51 | true | fix: improve CommonJs bundle to ESM library | 19,847 | webpack/webpack | 65,000 | JavaScript | hai-x | |
"use strict";
/** @type {import("../../../../").Configuration} */
module.exports = {
mode: "development",
devtool: false,
module: {
parser: {
asset: {
dataUrlCondition() {
return true;
}
}
},
rules: [
{
test: /file-global\.txt$/,
type: "asset"
},
{
test: /file-local\.tx... | No issues found. | "use strict";
/** @type {import("../../../../").Configuration} */
module.exports = {
mode: "development",
devtool: false,
module: {
parser: {
asset: {
dataUrlCondition() {
return true;
}
}
},
rules: [
{
test: /file-global\.txt$/,
type: "asset"
},
{
test: /file-local\.tx... | @@ -0,0 +1,31 @@
+"use strict";
+
+/** @type {import("../../../../").Configuration} */
+module.exports = {
+ mode: "development",
+ devtool: false,
+ module: {
+ parser: {
+ asset: {
+ dataUrlCondition() {
+ return true;
+ }
+ }
+ },
+ rules: [
+ {
+ test: /file-global\.txt$/,
+ type: "asset"
+... | test/configCases/asset-modules/global-and-local-options/webpack.config.js | 0 | JavaScript | 1 | none | 16 | 32 | 32 | true | Refactor remove unused code | 19,857 | webpack/webpack | 65,000 | JavaScript | alexander-akait | |
return {
path: possibleRequests[0],
data: result.toString("utf8")
};
}
/**
* Fetch source content from URL
* @param {ReadResource} readResource The read resource function
* @param {string} context context directory
* @param {string} url source URL
* @param {string=} sourceRoot source root directory
* @par... | No issues found. |
return {
path: possibleRequests[0],
data: result.toString("utf8")
};
}
/**
* Fetch source content from URL
* @param {ReadResource} readResource The read resource function
* @param {string} context context directory
* @param {string} url source URL
* @param {string=} sourceRoot source root directory
* @par... | @@ -7,7 +7,6 @@
const path = require("path");
const urlUtils = require("url");
-const { decodeDataURI } = require("./dataURL");
const { isAbsolute, join } = require("./fs");
/** @typedef {import("../../declarations/WebpackOptions").RuleSetRule["extractSourceMap"]} ExtractSourceMapOptions */
@@ -19,6 +18,10 @@ c... | lib/util/extractSourceMap.js | 0 | JavaScript | 1 | none | 16 | 51 | 51 | true | feat: extractSourceMap supports HTTP URLs | 19,882 | webpack/webpack | 65,000 | JavaScript | xiaoxiaojx | |
library: {
type: "module"
}
},
target: ["web", "node"],
experiments: {
outputModule: true
},
optimization: {
minimize: true,
runtimeChunk: "single",
splitChunks: {
cacheGroups: {
separate: {
test: /separate/,
chunks: "all",
filename: "separate.mjs",
enfor... | No issues found. | library: {
type: "module"
}
},
target: ["web", "node"],
experiments: {
outputModule: true
},
optimization: {
minimize: true,
runtimeChunk: "single",
splitChunks: {
cacheGroups: {
separate: {
test: /separate/,
chunks: "all",
filename: "separate.mjs",
enfor... | @@ -1,32 +1,65 @@
"use strict";
-/** @type {import("../../../../").Configuration} */
-module.exports = {
- output: {
- filename: "[name].mjs",
- library: {
- type: "module"
+/** @type {import("../../../../").Configuration[]} */
+module.exports = [
+ {
+ name: "web",
+ output: {
+ filename: "[name].mjs",
+ ... | test/configCases/target/universal/webpack.config.js | 0 | JavaScript | 1 | none | 16 | 51 | 51 | true | fix: support web workers loading for jsonp format | 19,916 | webpack/webpack | 65,000 | JavaScript | alexander-akait | |
const PLUGIN_NAME = "EnvironmentPlugin";
class EnvironmentPlugin {
/**
* @param {(string | string[] | Record<string, EXPECTED_ANY>)[]} keys keys
*/
constructor(...keys) {
if (keys.length === 1 && Array.isArray(keys[0])) {
/** @type {string[]} */
this.keys = keys[0];
this.defaultValues = {};
} else ... | No issues found. |
const PLUGIN_NAME = "EnvironmentPlugin";
class EnvironmentPlugin {
/**
* @param {(string | string[] | Record<string, EXPECTED_ANY>)[]} keys keys
*/
constructor(...keys) {
if (keys.length === 1 && Array.isArray(keys[0])) {
/** @type {string[]} */
this.keys = keys[0];
this.defaultValues = {};
} else ... | @@ -39,16 +39,18 @@ class EnvironmentPlugin {
* @returns {void}
*/
apply(compiler) {
- /** @type {Record<string, CodeValue>} */
- const definitions = {};
- for (const key of this.keys) {
- const value =
- process.env[key] !== undefined
- ? process.env[key]
- : this.defaultValues[key];
+ const d... | lib/EnvironmentPlugin.js | 0 | JavaScript | 1 | none | 16 | 51 | 51 | true | feat: add import.meta.env support for environment variables | 19,996 | webpack/webpack | 65,000 | JavaScript | xiaoxiaojx | |
*/
loaders: {
request: string;
path: string;
query: string;
fragment: string;
options?: string | object;
ident: string;
normal?: Function;
pitch?: Function;
raw?: boolean;
data?: object;
pitchExecuted: boolean;
normalExecuted: boolean;
type?: "module" | "commonjs";
}[];
/**
* The resou... | No issues found. | */
loaders: {
request: string;
path: string;
query: string;
fragment: string;
options?: string | object;
ident: string;
normal?: Function;
pitch?: Function;
raw?: boolean;
data?: object;
pitchExecuted: boolean;
normalExecuted: boolean;
type?: "module" | "commonjs";
}[];
/**
* The resou... | @@ -4426,11 +4426,11 @@ declare interface DllReferencePluginOptionsManifest {
}
declare class DotenvPlugin {
constructor(options?: DotenvPluginOptions);
- config: {
+ options: {
/**
- * The directory from which .env files are loaded. Can be an absolute path, or a path relative to the project root. false will d... | types.d.ts | 0 | TypeScript | 1 | none | 16 | 51 | 51 | true | Refactor dovenv plugin | 20,006 | webpack/webpack | 65,000 | JavaScript | alexander-akait | |
"use strict";
const fs = require("fs");
const path = require("path");
require("./test3");
it("should extract source map - 3", () => {
const fileData = fs.readFileSync(__filename + ".map").toString("utf-8");
const { sources } = JSON.parse(fileData);
expect(sources).toContain("webpack:///./external-source-map.txt")... | No issues found. | "use strict";
const fs = require("fs");
const path = require("path");
require("./test3");
it("should extract source map - 3", () => {
const fileData = fs.readFileSync(__filename + ".map").toString("utf-8");
const { sources } = JSON.parse(fileData);
expect(sources).toContain("webpack:///./external-source-map.txt")... | @@ -6,7 +6,8 @@ const path = require("path");
require("./test3");
it("should extract source map - 3", () => {
- const fileData = fs.readFileSync(path.resolve(__dirname, "bundle2.js.map")).toString("utf-8");
+ const fileData = fs.readFileSync(__filename + ".map").toString("utf-8");
const { sources } = JSON.parse(f... | test/configCases/source-map/extract-source-map/extract3.js | 0 | JavaScript | 1 | none | 16 | 14 | 14 | true | test: make extract source map tests correct | 20,008 | webpack/webpack | 65,000 | JavaScript | colinaaa | |
const hasAsync = this.hasAsyncRuntime;
const init = runtimeTemplate.supportsOptionalChaining()
? "init?.();"
: "if (init) init();";
return `${fn} = ${runtimeTemplate.basicFunction("moduleId, mode", [
"// mode: 0 => namespace (esm)",
"// mode: 1 => default-only (esm strict cjs)",
"// mode: 2 => defa... | No issues found. | const hasAsync = this.hasAsyncRuntime;
const init = runtimeTemplate.supportsOptionalChaining()
? "init?.();"
: "if (init) init();";
return `${fn} = ${runtimeTemplate.basicFunction("moduleId, mode", [
"// mode: 0 => namespace (esm)",
"// mode: 1 => default-only (esm strict cjs)",
"// mode: 2 => defa... | @@ -60,21 +60,6 @@ function getOptimizedDeferredModule(
return Template.asString(["{", Template.indent(props), "}"]);
}
-const strictModuleCache = [
- "if (cachedModule && cachedModule.error === undefined) {",
- Template.indent([
- "var exports = cachedModule.exports;",
- "if (mode == 0) return exports;",
- `if... | lib/runtime/MakeDeferredNamespaceObjectRuntime.js | 0 | JavaScript | 1 | none | 16 | 51 | 51 | true | fix: async modules in defer import | 20,020 | webpack/webpack | 65,000 | JavaScript | ahabhgk | |
"use strict";
/** @type {import("../../../../").Configuration} */
module.exports = {
mode: "production",
module: {
parser: {
json: {
namedExports: true
}
}
}
};
| No issues found. | "use strict";
/** @type {import("../../../../").Configuration} */
module.exports = {
mode: "production",
module: {
parser: {
json: {
namedExports: true
}
}
}
};
| @@ -0,0 +1,13 @@
+"use strict";
+
+/** @type {import("../../../../").Configuration} */
+module.exports = {
+ mode: "production",
+ module: {
+ parser: {
+ json: {
+ namedExports: true
+ }
+ }
+ }
+}; | test/configCases/json/named-exports/webpack.config.js | 0 | JavaScript | 1 | none | 16 | 14 | 14 | true | fix: should support named export json all time and onlyDefault for import attributes | 20,031 | webpack/webpack | 65,000 | JavaScript | JSerFeng | |
}))
);
// ES modules
config.push(
...values.map((value) => ({
target: "node",
node: {
__filename: value,
__dirname: value
},
output: {
module: true
},
experiments: {
outputModule: true
},
plugins: [
new webpack.DefinePlugin({
NODE_VALUE: typeof value === "boolean" ? value : JSON.s... | No issues found. | }))
);
// ES modules
config.push(
...values.map((value) => ({
target: "node",
node: {
__filename: value,
__dirname: value
},
output: {
module: true
},
experiments: {
outputModule: true
},
plugins: [
new webpack.DefinePlugin({
NODE_VALUE: typeof value === "boolean" ? value : JSON.s... | @@ -0,0 +1,104 @@
+"use strict";
+
+const webpack = require("../../../../");
+
+/** @type {(boolean | "warn-mock" | "mock" | "node-module" | "eval-only")[]} */
+const values = [true, "warn-mock", "mock", "node-module", "eval-only"];
+
+/** @type {import("../../../../").Configuration[]} */
+const config = [];
+
+// Comm... | test/configCases/node/filename-and-dirname/webpack.config.js | 0 | JavaScript | 1 | none | 16 | 51 | 51 | true | feat: added support for `import.meta.dirname` and `import.meta.filename` | 20,050 | webpack/webpack | 65,000 | JavaScript | alexander-akait | |
@@ ... @@
+ "worker",
@@ ... @@
- "target": "web",
+ "target": "webworker",
`)
);
test("target electron-main", { target: "electron-main" }, (e) =>
e.toMatchInlineSnapshot(`
- Expected
+ Received
@@ ... @@
- "electron": false,
- "electronMain": false,
+ "electron": true... | No issues found. | @@ ... @@
+ "worker",
@@ ... @@
- "target": "web",
+ "target": "webworker",
`)
);
test("target electron-main", { target: "electron-main" }, (e) =>
e.toMatchInlineSnapshot(`
- Expected
+ Received
@@ ... @@
- "electron": false,
- "electronMain": false,
+ "electron": true... | @@ -1797,6 +1797,169 @@ describe("snapshots", () => {
`)
);
+ test(
+ "target node and web (universal)",
+ {
+ target: ["web", "node"],
+ output: { module: true },
+ experiments: { outputModule: true }
+ },
+ (e) =>
+ e.toMatchInlineSnapshot(`
+ - Expected
+ + Received
+
+ @@ ... @@
+ - "o... | test/Defaults.unittest.js | 0 | JavaScript | 1 | none | 16 | 51 | 51 | true | refactor: use `globalThis` for universal target | 20,061 | webpack/webpack | 65,000 | JavaScript | alexander-akait | |
return fs.readFileSync(path.join(__dirname, filename), "utf-8");
};
const getSourceMap = (filename) => {
return JSON.parse(readFile(filename));
};
it("should compile successfully and have dual sourcemap", async () => {
import(/* webpackChunkName: "chunk-foo" */ "./foo").then(
({ default: foo }) => {
expect(fo... | No issues found. | return fs.readFileSync(path.join(__dirname, filename), "utf-8");
};
const getSourceMap = (filename) => {
return JSON.parse(readFile(filename));
};
it("should compile successfully and have dual sourcemap", async () => {
import(/* webpackChunkName: "chunk-foo" */ "./foo").then(
({ default: foo }) => {
expect(fo... | @@ -0,0 +1,58 @@
+import fs from "fs";
+import path from "path";
+
+const readFile = (filename) => {
+ return fs.readFileSync(path.join(__dirname, filename), "utf-8");
+};
+
+const getSourceMap = (filename) => {
+ return JSON.parse(readFile(filename));
+};
+
+it("should compile successfully and have dual sourcemap", as... | test/configCases/source-map/dual-source-map-plugins/entry3.js | 0 | JavaScript | 1 | none | 16 | 51 | 51 | true | test: dual sourcemap plugins | 20,063 | webpack/webpack | 65,000 | JavaScript | hai-x | |
pitch?: Function;
raw?: boolean;
data?: object;
pitchExecuted: boolean;
normalExecuted: boolean;
type?: "module" | "commonjs";
}[];
/**
* The resource path.
* In the example: "/abc/resource.js"
*/
resourcePath: string;
/**
* The resource query string.
* Example: "?query"
*/
resourceQuery:... | No issues found. | pitch?: Function;
raw?: boolean;
data?: object;
pitchExecuted: boolean;
normalExecuted: boolean;
type?: "module" | "commonjs";
}[];
/**
* The resource path.
* In the example: "/abc/resource.js"
*/
resourcePath: string;
/**
* The resource query string.
* Example: "?query"
*/
resourceQuery:... | @@ -3661,9 +3661,8 @@ declare abstract class CssGenerator extends Generator {
sourceModule(
module: NormalModule,
initFragments: InitFragment<GenerateContext>[],
- source: ReplaceSource,
generateContext: GenerateContext & { cssData: CssData }
- ): void;
+ ): ReplaceSource;
generateError(
error: Error,
... | types.d.ts | 0 | TypeScript | 1 | none | 16 | 51 | 51 | true | perf(css): avoid rendering the same Source multiple times | 20,106 | webpack/webpack | 65,000 | JavaScript | xiaoxiaojx | |
const p = new ParallelismFactorCalculator();
const moduleGraph = this.moduleGraph;
/** @type {Map<Module, ModuleProfile>} */
const modulesWithProfiles = new Map();
for (const module of this.modules) {
const profile = moduleGraph.getProfile(module);
if (!profile) continue;
modulesWithProfiles.... | No issues found. | const p = new ParallelismFactorCalculator();
const moduleGraph = this.moduleGraph;
/** @type {Map<Module, ModuleProfile>} */
const modulesWithProfiles = new Map();
for (const module of this.modules) {
const profile = moduleGraph.getProfile(module);
if (!profile) continue;
modulesWithProfiles.... | @@ -134,6 +134,7 @@ const { isSourceEqual } = require("./util/source");
/** @typedef {import("./stats/DefaultStatsFactoryPlugin").StatsModule} StatsModule */
/** @typedef {import("./TemplatedPathPlugin").TemplatePath} TemplatePath */
/** @typedef {import("./util/Hash")} Hash */
+
/**
* @template T
* @typedef {i... | lib/Compilation.js | 0 | JavaScript | 1 | none | 16 | 51 | 51 | true | fix: delay HMR accept dependencies to preserve import attributes | 20,124 | webpack/webpack | 65,000 | JavaScript | xiaoxiaojx | |
class FakeSheet {
constructor(element, basePath) {
this._element = element;
this._basePath = basePath;
// We cannot lazily load file content in getter because in HMR scenarios,
// the file path will have ?hmr=timestamp appended. If we load lazily,
// we can only get the latest file content, and the previou... | No issues found. |
class FakeSheet {
constructor(element, basePath) {
this._element = element;
this._basePath = basePath;
// We cannot lazily load file content in getter because in HMR scenarios,
// the file path will have ?hmr=timestamp appended. If we load lazily,
// we can only get the latest file content, and the previou... | @@ -161,27 +161,52 @@ class FakeElement {
set href(value) {
if (this._type === "link") {
this._href = this._toRealUrl(value);
+ try {
+ this.sheet._css = this.sheet.css;
+ this.sheet._cssRules = this.sheet.cssRules;
+ } catch (_error) {
+ // Ignore error
+ }
}
}
get href() {
return t... | test/helpers/FakeDocument.js | 0 | JavaScript | 1 | none | 16 | 51 | 51 | true | fix(hmr): remove CSS link tags when CSS imports are removed | 20,154 | webpack/webpack | 65,000 | JavaScript | xiaoxiaojx | |
],
"assetsSize": 195,
"auxiliaryAssets": undefined,
"auxiliaryAssetsSize": 0,
"childAssets": undefined,
"children": undefined,
"chunks": undefined,
"filteredAssets": 0,
"filteredAuxiliaryAssets": 0,
"name": "entryA",
},
... | No issues found. | ],
"assetsSize": 195,
"auxiliaryAssets": undefined,
"auxiliaryAssetsSize": 0,
"childAssets": undefined,
"children": undefined,
"chunks": undefined,
"filteredAssets": 0,
"filteredAuxiliaryAssets": 0,
"name": "entryA",
},
... | @@ -150,10 +150,10 @@ describe("Stats", () => {
"assets": Array [
Object {
"name": "entryA.js",
- "size": 196,
+ "size": 195,
},
],
- "assetsSize": 196,
+ "assetsSize": 195,
"auxiliaryAssets": undefined,
... | test/Stats.test.js | 0 | JavaScript | 1 | none | 16 | 51 | 51 | true | refactor: use method shorthand syntax to render module content in __webpack_modules__ object | 20,158 | webpack/webpack | 65,000 | JavaScript | JSerFeng | |
* @param {ImportPhaseType} phase import phase
* @param {ImportAttributes=} attributes import attributes
*/
constructor(request, sourceOrder, phase, attributes) {
super(request, sourceOrder, phase, attributes);
}
get type() {
return "harmony side effect evaluation";
}
/**
* @param {ModuleGraph} module... | No issues found. | * @param {ImportPhaseType} phase import phase
* @param {ImportAttributes=} attributes import attributes
*/
constructor(request, sourceOrder, phase, attributes) {
super(request, sourceOrder, phase, attributes);
}
get type() {
return "harmony side effect evaluation";
}
/**
* @param {ModuleGraph} module... | @@ -5,6 +5,7 @@
"use strict";
+const { CSS_TYPE } = require("../ModuleSourceTypeConstants");
const makeSerializable = require("../util/makeSerializable");
const HarmonyImportDependency = require("./HarmonyImportDependency");
@@ -61,6 +62,14 @@ makeSerializable(
"webpack/lib/dependencies/HarmonyImportSideEffe... | lib/dependencies/HarmonyImportSideEffectDependency.js | 0 | JavaScript | 1 | none | 16 | 51 | 51 | true | feat: remove empty needless js output for normal css module | 20,162 | webpack/webpack | 65,000 | JavaScript | JSerFeng | |
nonDeferAccess
});
} else {
/** @type {RuntimeSpec | boolean} */
let reducedRuntimeCondition;
/** @type {NonDeferAccess} */
let reducedNonDeferAccess;
if (existingEntry !== undefined) {
reducedRuntimeCondition = subtractRuntimeCondition(
runtimeCondition,
existingEntry.r... | No issues found. | nonDeferAccess
});
} else {
/** @type {RuntimeSpec | boolean} */
let reducedRuntimeCondition;
/** @type {NonDeferAccess} */
let reducedNonDeferAccess;
if (existingEntry !== undefined) {
reducedRuntimeCondition = subtractRuntimeCondition(
runtimeCondition,
existingEntry.r... | @@ -687,7 +687,7 @@ const getFinalName = (
/**
* @typedef {object} ConcatenateModuleHooks
- * @property {SyncBailHook<[ConcatenatedModule], boolean>} onDemandExportsGeneration
+ * @property {SyncBailHook<[ConcatenatedModule, RuntimeSpec[], string, Record<string,string>], boolean>} onDemandExportsGeneration
* @pr... | lib/optimize/ConcatenatedModule.js | 0 | JavaScript | 1 | none | 16 | 51 | 51 | true | fix: module library export definitions when multiple runtimes | 20,179 | webpack/webpack | 65,000 | JavaScript | hai-x | |
* @param {Compilation} compilation the compilation
* @param {ResolverWithOptions} resolver the resolver
* @param {InputFileSystem} fs the file system
* @param {BuildCallback} callback callback function
* @returns {void}
*/
build(options, compilation, resolver, fs, callback) {
this.buildMeta = {};
this.... | No issues found. | * @param {Compilation} compilation the compilation
* @param {ResolverWithOptions} resolver the resolver
* @param {InputFileSystem} fs the file system
* @param {BuildCallback} callback callback function
* @returns {void}
*/
build(options, compilation, resolver, fs, callback) {
this.buildMeta = {};
this.... | @@ -28,6 +28,8 @@ const ConsumeSharedFallbackDependency = require("./ConsumeSharedFallbackDependen
/** @typedef {import("../Module").NeedBuildCallback} NeedBuildCallback */
/** @typedef {import("../Module").NeedBuildContext} NeedBuildContext */
/** @typedef {import("../Module").SourceTypes} SourceTypes */
+/** @type... | lib/sharing/ConsumeSharedModule.js | 0 | JavaScript | 1 | none | 16 | 51 | 51 | true | fix ESM default export handling for .mjs files in Module Federation | 20,189 | webpack/webpack | 65,000 | JavaScript | y-okt | |
it("should throw helpful error when module is not found at runtime", function () {
// First, require the helper module to get its id
const helper = require("./helper");
expect(helper).toBe("helper");
// Find the module id for helper.js
const moduleId = Object.keys(__webpack_modules__).find(
id => id.includes("h... | No issues found. | it("should throw helpful error when module is not found at runtime", function () {
// First, require the helper module to get its id
const helper = require("./helper");
expect(helper).toBe("helper");
// Find the module id for helper.js
const moduleId = Object.keys(__webpack_modules__).find(
id => id.includes("h... | @@ -0,0 +1,27 @@
+it("should throw helpful error when module is not found at runtime", function () {
+ // First, require the helper module to get its id
+ const helper = require("./helper");
+ expect(helper).toBe("helper");
+
+ // Find the module id for helper.js
+ const moduleId = Object.keys(__webpack_modules__).find... | test/configCases/runtime/module-not-found-error/index.js | 0 | JavaScript | 1 | none | 16 | 28 | 28 | true | fix: add null check for module existence with helpful error message | 20,221 | webpack/webpack | 65,000 | JavaScript | samarthsinh2660 | |
"use strict";
const { DefinePlugin } = require("../../../../");
/** @type {import("../../../../").Configuration} */
module.exports = {
target: "node",
experiments: {
outputModule: true
},
output: {
module: true
},
plugins: [
new DefinePlugin({
NODE_VERSION: JSON.stringify(
process.versions.node.spl... | No issues found. | "use strict";
const { DefinePlugin } = require("../../../../");
/** @type {import("../../../../").Configuration} */
module.exports = {
target: "node",
experiments: {
outputModule: true
},
output: {
module: true
},
plugins: [
new DefinePlugin({
NODE_VERSION: JSON.stringify(
process.versions.node.spl... | @@ -0,0 +1,21 @@
+"use strict";
+
+const { DefinePlugin } = require("../../../../");
+
+/** @type {import("../../../../").Configuration} */
+module.exports = {
+ target: "node",
+ experiments: {
+ outputModule: true
+ },
+ output: {
+ module: true
+ },
+ plugins: [
+ new DefinePlugin({
+ NODE_VERSION: JSON.stringi... | test/configCases/node/output-module-external/webpack.config.js | 0 | JavaScript | 1 | none | 16 | 22 | 22 | true | feat: improve rendering node built-in module | 20,255 | webpack/webpack | 65,000 | JavaScript | hai-x | |
"use strict";
const { WebpackError } = require("../../../");
/** @type {import("../../../").Configuration} */
module.exports = {
mode: "development",
entry: "./index.js",
stats: {
errorStack: true
},
plugins: [
(compiler) => {
compiler.hooks.compilation.tap("Test", (compilation) => {
const err = new W... | No issues found. | "use strict";
const { WebpackError } = require("../../../");
/** @type {import("../../../").Configuration} */
module.exports = {
mode: "development",
entry: "./index.js",
stats: {
errorStack: true
},
plugins: [
(compiler) => {
compiler.hooks.compilation.tap("Test", (compilation) => {
const err = new W... | @@ -0,0 +1,22 @@
+"use strict";
+
+const { WebpackError } = require("../../../");
+
+/** @type {import("../../../").Configuration} */
+module.exports = {
+ mode: "development",
+ entry: "./index.js",
+ stats: {
+ errorStack: true
+ },
+ plugins: [
+ (compiler) => {
+ compiler.hooks.compilation.tap("Test", (compilat... | test/statsCases/error-stack-enabled-error/webpack.config.js | 0 | JavaScript | 1 | none | 16 | 23 | 23 | true | fix: respect errorStack option in stats output (#15980) | 20,258 | webpack/webpack | 65,000 | JavaScript | samarthsinh2660 | |
"use strict";
const { ConsumeSharedPlugin, ProvideSharedPlugin } =
require("../../../../").sharing;
/** @type {import("../../../../").Configuration} */
module.exports = {
mode: "production",
plugins: [
new ProvideSharedPlugin({
provides: {
cjs: {
version: "0.0.0"
}
}
}),
new ConsumeSharedP... | No issues found. | "use strict";
const { ConsumeSharedPlugin, ProvideSharedPlugin } =
require("../../../../").sharing;
/** @type {import("../../../../").Configuration} */
module.exports = {
mode: "production",
plugins: [
new ProvideSharedPlugin({
provides: {
cjs: {
version: "0.0.0"
}
}
}),
new ConsumeSharedP... | @@ -0,0 +1,25 @@
+"use strict";
+
+const { ConsumeSharedPlugin, ProvideSharedPlugin } =
+ require("../../../../").sharing;
+
+/** @type {import("../../../../").Configuration} */
+module.exports = {
+ mode: "production",
+ plugins: [
+ new ProvideSharedPlugin({
+ provides: {
+ cjs: {
+ version: "0.0.0"
+ }
... | test/configCases/sharing/consume-module-export-interop/webpack.config.js | 0 | JavaScript | 1 | none | 16 | 26 | 26 | true | refactor: improve interop for ConsumeSharedModule | 20,268 | webpack/webpack | 65,000 | JavaScript | hai-x | |
if (!import.meta.UNKNOWN_PROPERTY) {
// runtime assignment
import.meta.UNKNOWN_PROPERTY = "HELLO";
}
const { pathToFileURL } = require("url");
const url = pathToFileURL(
require("path").resolve("./test/configCases/module/import-meta/index.js")
).toString();
it("should keep import.meta.UNKNOWN_PROPERTY", () =... | No issues found. | if (!import.meta.UNKNOWN_PROPERTY) {
// runtime assignment
import.meta.UNKNOWN_PROPERTY = "HELLO";
}
const { pathToFileURL } = require("url");
const url = pathToFileURL(
require("path").resolve("./test/configCases/module/import-meta/index.js")
).toString();
it("should keep import.meta.UNKNOWN_PROPERTY", () =... | @@ -0,0 +1,41 @@
+if (!import.meta.UNKNOWN_PROPERTY) {
+ // runtime assignment
+ import.meta.UNKNOWN_PROPERTY = "HELLO";
+}
+
+const { pathToFileURL } = require("url");
+const url = pathToFileURL(
+ require("path").resolve("./test/configCases/module/import-meta/index.js")
+).toString();
+
+it("should keep import.... | test/configCases/module/import-meta/index.js | 0 | JavaScript | 1 | none | 16 | 41 | 41 | true | feat: keep unknown import.meta properties | 20,312 | webpack/webpack | 65,000 | JavaScript | xiaoxiaojx | |
/**
* @param {string | undefined} value The new chunk name
* @returns {void}
*/
set chunkName(value) {
if (this.groupOptions.name !== value) {
this.groupOptions.name = value;
this._stringifiedGroupOptions = undefined;
}
}
/**
* @returns {boolean} Whether to deduplicate to avoid circular referenc... | No issues found. |
/**
* @param {string | undefined} value The new chunk name
* @returns {void}
*/
set chunkName(value) {
if (this.groupOptions.name !== value) {
this.groupOptions.name = value;
this._stringifiedGroupOptions = undefined;
}
}
/**
* @returns {boolean} Whether to deduplicate to avoid circular referenc... | @@ -16,7 +16,7 @@ const makeSerializable = require("./util/makeSerializable");
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
/** @typedef {import("./util/Hash")} Hash */
-/** @typedef {(ChunkGroupOptions & { entryOptions?: EntryOptions }) | string} Grou... | lib/AsyncDependenciesBlock.js | 0 | JavaScript | 1 | none | 16 | 51 | 51 | true | fix: reuse async entrypoint for same Worker URL within a module | 20,345 | webpack/webpack | 65,000 | JavaScript | xiaoxiaojx | |
it("should resolve to create a WebWorker", async () => {
const worker = new Worker(new URL("foo", import.meta.url), {
type: "module"
});
worker.postMessage("ok");
const result = await new Promise((resolve) => {
worker.onmessage = (event) => {
resolve(event.data);
};
});
expect(result).toBe("index.worker.... | No issues found. | it("should resolve to create a WebWorker", async () => {
const worker = new Worker(new URL("foo", import.meta.url), {
type: "module"
});
worker.postMessage("ok");
const result = await new Promise((resolve) => {
worker.onmessage = (event) => {
resolve(event.data);
};
});
expect(result).toBe("index.worker.... | @@ -0,0 +1,13 @@
+it("should resolve to create a WebWorker", async () => {
+ const worker = new Worker(new URL("foo", import.meta.url), {
+ type: "module"
+ });
+ worker.postMessage("ok");
+ const result = await new Promise((resolve) => {
+ worker.onmessage = (event) => {
+ resolve(event.data);
+ };
+ });
+ expect... | test/configCases/worker/resolve-condition/index.js | 0 | JavaScript | 1 | none | 16 | 14 | 14 | true | feat: resolve worker via condition name | 20,347 | webpack/webpack | 65,000 | JavaScript | hai-x | |
"use strict";
/** @type {import("../../../../").Configuration} */
module.exports = {
mode: "production",
module: {
rules: [
{
oneOf: [
{
test: /\.png$/i,
resourceQuery: /asset/,
type: "asset"
},
{
test: /\.png$/i,
resourceQuery: /bytes/,
type: "asset/bytes"... | No issues found. | "use strict";
/** @type {import("../../../../").Configuration} */
module.exports = {
mode: "production",
module: {
rules: [
{
oneOf: [
{
test: /\.png$/i,
resourceQuery: /asset/,
type: "asset"
},
{
test: /\.png$/i,
resourceQuery: /bytes/,
type: "asset/bytes"... | @@ -0,0 +1,40 @@
+"use strict";
+
+/** @type {import("../../../../").Configuration} */
+module.exports = {
+ mode: "production",
+ module: {
+ rules: [
+ {
+ oneOf: [
+ {
+ test: /\.png$/i,
+ resourceQuery: /asset/,
+ type: "asset"
+ },
+ {
+ test: /\.png$/i,
+ resourceQuery: ... | test/configCases/side-effects/asset-module/webpack.config.js | 0 | JavaScript | 1 | none | 16 | 41 | 41 | true | feat: consider asset module as side-effect-free | 20,352 | webpack/webpack | 65,000 | JavaScript | hai-x | |
"use strict";
/** @type {import("../../../../").Configuration[]} */
module.exports = [
{
target: "web"
},
{
output: {
filename: "[name].bundle1.js"
},
target: "web",
optimization: {
runtimeChunk: "single"
}
},
{
target: "web",
experiments: {
outputModule: true
}
},
{
target: "web",
... | No issues found. | "use strict";
/** @type {import("../../../../").Configuration[]} */
module.exports = [
{
target: "web"
},
{
output: {
filename: "[name].bundle1.js"
},
target: "web",
optimization: {
runtimeChunk: "single"
}
},
{
target: "web",
experiments: {
outputModule: true
}
},
{
target: "web",
... | @@ -0,0 +1,35 @@
+"use strict";
+
+/** @type {import("../../../../").Configuration[]} */
+module.exports = [
+ {
+ target: "web"
+ },
+ {
+ output: {
+ filename: "[name].bundle1.js"
+ },
+ target: "web",
+ optimization: {
+ runtimeChunk: "single"
+ }
+ },
+ {
+ target: "web",
+ experiments: {
+ outputModu... | test/configCases/dynamic-import/self-import/webpack.config.js | 0 | JavaScript | 1 | none | 16 | 36 | 36 | true | test: add self-import test case for dynamic import | 20,389 | webpack/webpack | 65,000 | JavaScript | xiaoxiaojx | |
const target = exportInfo.getTarget(moduleGraph);
if (
!target ||
!target.export ||
target.export.length !== 1 ||
target.export[0] !== "__esModule"
) {
return "dynamic";
}
switch (
target.module.buildMeta &&
target.module.buildMeta.exportsType
) {
case "fl... | No issues found. | const target = exportInfo.getTarget(moduleGraph);
if (
!target ||
!target.export ||
target.export.length !== 1 ||
target.export[0] !== "__esModule"
) {
return "dynamic";
}
switch (
target.module.buildMeta &&
target.module.buildMeta.exportsType
) {
case "fl... | @@ -104,11 +104,36 @@ const makeSerializable = require("./util/makeSerializable");
/** @typedef {Set<string>} RuntimeRequirements */
/** @typedef {ReadonlySet<string>} ReadOnlyRuntimeRequirements */
-/** @typedef {Map<"topLevelDeclarations", Set<string>> & Map<"chunkInitFragments", InitFragment<EXPECTED_ANY>[]>} Kn... | lib/Module.js | 0 | JavaScript | 1 | none | 16 | 51 | 51 | true | refactor: fix some types | 20,412 | webpack/webpack | 65,000 | JavaScript | alexander-akait | |
// cycles will be removed if a new reference to it has been found
// that is not part of the cycle
/** @type {Cycles<T>} */
const rootCycles = new Set();
// For all non-marked nodes
for (const selectedNode of itemToNode.values()) {
if (selectedNode.cycle.marker === NO_MARKER) {
// deep-walk all referenced m... | No issues found. | // cycles will be removed if a new reference to it has been found
// that is not part of the cycle
/** @type {Cycles<T>} */
const rootCycles = new Set();
// For all non-marked nodes
for (const selectedNode of itemToNode.values()) {
if (selectedNode.cycle.marker === NO_MARKER) {
// deep-walk all referenced m... | @@ -9,7 +9,6 @@ const NO_MARKER = 0;
const IN_PROGRESS_MARKER = 1;
const DONE_MARKER = 2;
const DONE_MAYBE_ROOT_CYCLE_MARKER = 3;
-const DONE_AND_ROOT_MARKER = 4;
/**
* @template T
@@ -32,9 +31,9 @@ class Node {
this.item = item;
/** @type {Nodes<T>} */
this.dependencies = new Set();
- this.marker = N... | lib/util/findGraphRoots.js | 0 | JavaScript | 1 | none | 16 | 51 | 51 | true | fix: deterministic findGraphRoots regardless of edge ordering | 20,452 | webpack/webpack | 65,000 | JavaScript | veeceey | |
/** @type {Module} */
this.resolvedModule = module;
/** @type {Module} */
this.module = module;
/** @type {boolean | undefined} */
this.weak = weak;
/** @type {boolean} */
this.conditional = Boolean(condition);
/** @type {boolean} */
this._active = condition !== false;
/** @type {false | null | Ge... | No issues found. | /** @type {Module} */
this.resolvedModule = module;
/** @type {Module} */
this.module = module;
/** @type {boolean | undefined} */
this.weak = weak;
/** @type {boolean} */
this.conditional = Boolean(condition);
/** @type {boolean} */
this._active = condition !== false;
/** @type {false | null | Ge... | @@ -184,15 +184,6 @@ class ModuleGraphConnection {
this.conditional = false;
this._active = value;
}
-
- // TODO webpack 5 remove
- get active() {
- throw new Error("Use getActiveState instead");
- }
-
- set active(value) {
- throw new Error("Use setActive instead");
- }
}
/** @typedef {typeof TRANSITIVE_... | lib/ModuleGraphConnection.js | 0 | JavaScript | 1 | none | 16 | 51 | 51 | true | refactor: remove deprecated ModuleGraphConnection.active | 20,504 | webpack/webpack | 65,000 | JavaScript | stefanbinoj | |
"use strict";
const base = {
target: ["web", "node"],
mode: "development",
experiments: {
outputModule: true
},
output: {
module: true,
filename: "[name].mjs"
},
module: {
rules: [
{
test: /\.bin$/,
type: "asset/bytes"
}
]
}
};
/** @type {import("../../../../").Configuration[]} */
modu... | No issues found. | "use strict";
const base = {
target: ["web", "node"],
mode: "development",
experiments: {
outputModule: true
},
output: {
module: true,
filename: "[name].mjs"
},
module: {
rules: [
{
test: /\.bin$/,
type: "asset/bytes"
}
]
}
};
/** @type {import("../../../../").Configuration[]} */
modu... | @@ -0,0 +1,27 @@
+"use strict";
+
+const base = {
+ target: ["web", "node"],
+ mode: "development",
+ experiments: {
+ outputModule: true
+ },
+ output: {
+ module: true,
+ filename: "[name].mjs"
+ },
+ module: {
+ rules: [
+ {
+ test: /\.bin$/,
+ type: "asset/bytes"
+ }
+ ]
+ }
+};
+
+/** @type {import(... | test/configCases/target/universal-to-binary/webpack.config.js | 0 | JavaScript | 1 | none | 16 | 28 | 28 | true | test: add integration test for universal ToBinaryRuntimeModule env sw… | 20,507 | webpack/webpack | 65,000 | JavaScript | aryanraj45 | |
"use strict";
/**
* Tests that importExportsPresence / reexportExportsPresence correctly override
* exportsPresence and strictExportPresence via resolveFromOptions.
* @type {import("../../../../").Configuration}
*/
module.exports = {
mode: "production",
module: {
rules: [
{
// importExportsPresence="err... | No issues found. | "use strict";
/**
* Tests that importExportsPresence / reexportExportsPresence correctly override
* exportsPresence and strictExportPresence via resolveFromOptions.
* @type {import("../../../../").Configuration}
*/
module.exports = {
mode: "production",
module: {
rules: [
{
// importExportsPresence="err... | @@ -0,0 +1,34 @@
+"use strict";
+
+/**
+ * Tests that importExportsPresence / reexportExportsPresence correctly override
+ * exportsPresence and strictExportPresence via resolveFromOptions.
+ * @type {import("../../../../").Configuration}
+ */
+module.exports = {
+ mode: "production",
+ module: {
+ rules: [
+ {
+ ... | test/configCases/compiletime/exports-presence-overrides/webpack.config.js | 0 | JavaScript | 1 | none | 16 | 35 | 35 | true | fix: deduplicate export presence logic in Harmony dependency classes | 20,521 | webpack/webpack | 65,000 | JavaScript | kartikeyg0104 | |
import type { LogOptions } from './logger';
import type { AstroConfig, CollectionResult, CollectionRSS, CreateCollection, Params, RuntimeMode } from './@types/astro';
import type { CompileError as ICompileError } from 'astro-parser';
import resolve from 'resolve';
import { existsSync, promises as fs } from 'fs';
impor... | `esbuild` didn't like the named import from a CJS package. I think it's actually fine and `esbuild` is being over-cautious, but whatever. | import type { LogOptions } from './logger';
import type { AstroConfig, CollectionResult, CollectionRSS, CreateCollection, Params, RuntimeMode } from './@types/astro';
import type { CompileError as ICompileError } from '@astrojs/parser';
import resolve from 'resolve';
import { existsSync, promises as fs } from 'fs';
im... | @@ -1,14 +1,15 @@
-import 'source-map-support/register.js';
import type { LogOptions } from './logger';
import type { AstroConfig, CollectionResult, CollectionRSS, CreateCollection, Params, RuntimeMode } from './@types/astro';
+import type { CompileError as ICompileError } from 'astro-parser';
import resolve from ... | packages/astro/src/runtime.ts | 20 | TypeScript | 0.5 | suggestion | 137 | 45 | 45 | false | Update build script to avoid bundling | 304 | withastro/astro | 47,179 | TypeScript | natemoo-re | natemoo-re |
import type { LogOptions } from './logger';
import type { AstroConfig, CollectionResult, CollectionRSS, CreateCollection, Params, RuntimeMode } from './@types/astro';
import type { CompileError as ICompileError } from 'astro-parser';
import resolve from 'resolve';
import { existsSync, promises as fs } from 'fs';
impor... | This _does_ need to be imported separately as a type. | import type { LogOptions } from './logger';
import type { AstroConfig, CollectionResult, CollectionRSS, CreateCollection, Params, RuntimeMode } from './@types/astro';
import type { CompileError as ICompileError } from '@astrojs/parser';
import resolve from 'resolve';
import { existsSync, promises as fs } from 'fs';
im... | @@ -1,14 +1,15 @@
-import 'source-map-support/register.js';
import type { LogOptions } from './logger';
import type { AstroConfig, CollectionResult, CollectionRSS, CreateCollection, Params, RuntimeMode } from './@types/astro';
+import type { CompileError as ICompileError } from 'astro-parser'; | packages/astro/src/runtime.ts | 3 | TypeScript | 0.357 | suggestion | 53 | 28 | 28 | false | Update build script to avoid bundling | 304 | withastro/astro | 47,179 | TypeScript | natemoo-re | natemoo-re |
const resolvePackageUrl = async (pkgName: string) => snowpack.getUrlForPackage(pkgName);
timer.backend = performance.now();
const {
snowpack,
snowpackRuntime,
snowpackConfig,
} = await createSnowpack(astroConfig, {
mode,
resolvePackageUrl,
});
debug(logging, 'core', `snowpack created [$... | Maybe remove the `Promise.all()` ? Unless we need to add more cleanup relatively soon | const timer: Record<string, number> = {};
const resolvePackageUrl = async (pkgName: string) => snowpack.getUrlForPackage(pkgName);
timer.backend = performance.now();
const {
snowpack: snowpackInstance,
snowpackRuntime,
snowpackConfig,
} = await createSnowpack(astroConfig, {
mode,
resolveP... | @@ -439,52 +431,31 @@ async function createSnowpack(astroConfig: AstroConfig, options: CreateSnowpackO
/** Core Astro runtime */
export async function createRuntime(astroConfig: AstroConfig, { mode, logging }: RuntimeOptions): Promise<AstroRuntime> {
const timer: Record<string, number> = {};
- const resolvePackag... | packages/astro/src/runtime.ts | 26 | TypeScript | 0.429 | suggestion | 85 | 29 | 31 | false | Remove second snowpack instance | 368 | withastro/astro | 47,179 | TypeScript | drwpow | matthewp |
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
import { suite } from 'uvu';
import execa from 'execa';
import del from 'del';
import * as assert from 'uvu/assert';
import { TEMPLATES } from '../dist/templates.js';
const CreateAstro = suite('npm init astro');
const cwd = fileURLToPa... | Because `uvu` won’t ever finish if there are open threads, this test is super probable to run indefinitely. We had to add the same manual timeout handling here as we do in the astro tests. |
// test
const CreateAstro = suite('npm init astro');
CreateAstro.before(async () => {
// clean install dir
await del(FIXTURES_DIR);
await fs.promises.mkdir(FIXTURES_DIR);
// install all templates & deps before running tests
await Promise.all(
TEMPLATES.map(async ({ value: template }) => {
const t... | @@ -1,46 +1,120 @@
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
+import http from 'http';
import { suite } from 'uvu';
import execa from 'execa';
import del from 'del';
+import glob from 'tiny-glob';
import * as assert from 'uvu/assert';
import { TEMPLATES } from '../dist/t... | packages/create-astro/test/create-astro.test.js | 26 | JavaScript | 0.714 | suggestion | 188 | 47 | 51 | false | Add integration test for templates | 372 | withastro/astro | 47,179 | TypeScript | drwpow | drwpow |
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
import http from 'http';
import { suite } from 'uvu';
import execa from 'execa';
import del from 'del';
import glob from 'tiny-glob';
import * as assert from 'uvu/assert';
import { TEMPLATES } from '../dist/templates.js';
// config
cons... | `uvu` was removed for this test because it was just swallowing error after error, making it impossible to debug in CI | import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
import http from 'http';
import { green, red } from 'kleur/colors';
import execa from 'execa';
import glob from 'tiny-glob';
import { TEMPLATES } from '../dist/templates.js';
// config
const GITHUB_SHA = process.env.GITHUB_SHA || execa.... | @@ -2,119 +2,137 @@ import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
import http from 'http';
-import { suite } from 'uvu'; | packages/create-astro/test/create-astro.test.js | 5 | JavaScript | 0.714 | bug | 117 | 30 | 30 | false | Improve templates test | 377 | withastro/astro | 47,179 | TypeScript | drwpow | drwpow |
{ compileOptions, filename, projectRoot }: { compileOptions: CompileOptions; filename: string; projectRoot: string }
): Promise<TransformResult> {
const fileID = path.relative(projectRoot, filename);
switch (true) {
case filename.slice(-6) === '.astro':
return await convertAstroToJsx(contents, { compile... | Another part of the fix: side-effects are needed to properly polyfill `fetch` in all environments | { compileOptions, filename, projectRoot }: { compileOptions: CompileOptions; filename: string; projectRoot: string }
): Promise<TransformResult> {
const fileID = path.relative(projectRoot, filename);
switch (true) {
case filename.slice(-6) === '.astro':
return await convertAstroToJsx(contents, { compile... | @@ -108,7 +108,7 @@ export async function compileComponent(
// return template
let moduleJavaScript = `
-import fetch from 'node-fetch';
+import 'isomorphic-fetch'; | packages/astro/src/compiler/index.ts | 26 | TypeScript | 0.357 | suggestion | 97 | 51 | 51 | false | Allow createCollection() to fetch remote data | 400 | withastro/astro | 47,179 | TypeScript | drwpow | drwpow |
if (searchResult.statusCode === 301) {
return { statusCode: 301, location: searchResult.pathname };
}
const snowpackURL = searchResult.location.snowpackURL;
let rss: { data: any[] & CollectionRSS } = {} as any;
try {
const mod = await snowpackRuntime.importModule(snowpackURL);
debug(logging, 'r... | Add a few more helpful error messages to `createCollection()` |
if (searchResult.statusCode === 301) {
return { statusCode: 301, location: searchResult.pathname };
}
const snowpackURL = searchResult.location.snowpackURL;
let rss: { data: any[] & CollectionRSS } = {} as any;
try {
const mod = await snowpackRuntime.importModule(snowpackURL);
debug(logging, 'r... | @@ -94,20 +101,22 @@ async function load(config: RuntimeConfig, rawPathname: string | undefined): Pro
if (mod.exports.createCollection) {
const createCollection: CreateCollection = await mod.exports.createCollection();
+ const VALID_KEYS = new Set(['data', 'routes', 'permalink', 'pageSize', 'rss']);
... | packages/astro/src/runtime.ts | 26 | TypeScript | 0.5 | suggestion | 61 | 51 | 51 | false | Allow createCollection() to fetch remote data | 400 | withastro/astro | 47,179 | TypeScript | drwpow | drwpow |
import { Transformer } from '../../@types/transformer';
/** Transform <!doctype> tg */
export default function (_opts: { filename: string; fileID: string }): Transformer {
let hasDoctype = false;
return {
visitors: {
html: {
Element: {
enter(node, parent, _key, index) {
if ... | Just checked the spec. It looks like mixed-case `!doctype` is valid as well, so this should probably check for `node.name.toLowerCase() === '!doctype'`
https://html.spec.whatwg.org/multipage/parsing.html#doctype-name-state | import { Transformer } from '../../@types/transformer';
/** Transform <!doctype> tg */
export default function (_opts: { filename: string; fileID: string }): Transformer {
let hasDoctype = false;
return {
visitors: {
html: {
Element: {
enter(node, parent, _key, index) {
if ... | @@ -9,7 +9,7 @@ export default function (_opts: { filename: string; fileID: string }): Transform
html: {
Element: {
enter(node, parent, _key, index) {
- if (node.name === '!doctype') {
+ if (node.name === '!doctype' || node.name === '!DOCTYPE') { | packages/astro/src/compiler/transform/doctype.ts | 12 | TypeScript | 0.786 | suggestion | 225 | 36 | 36 | false | Make doctype be case insensitive | 419 | withastro/astro | 47,179 | TypeScript | natemoo-re | matthewp |
start: number;
end: number;
value: string;
}
const CSS_SEPARATORS = new Set([' ', ',', '+', '>', '~']);
const KEYFRAME_PERCENT = /\d+\.?\d*%/;
/** HTML tags that should never get scoped classes */
export const NEVER_SCOPED_TAGS = new Set<string>([
'base',
'body',
'font',
'frame',
'frameset',
'head',... | One last place! This probably needs to not be part of this Set, but a separate check. | start: number;
end: number;
value: string;
}
const CSS_SEPARATORS = new Set([' ', ',', '+', '>', '~']);
const KEYFRAME_PERCENT = /\d+\.?\d*%/;
/** HTML tags that should never get scoped classes */
export const NEVER_SCOPED_TAGS = new Set<string>([
'base',
'body',
'font',
'frame',
'frameset',
'head',... | @@ -30,6 +30,7 @@ export const NEVER_SCOPED_TAGS = new Set<string>([
'style',
'title',
'!doctype',
+ '!DOCTYPE' | packages/astro/src/compiler/transform/postcss-scoped-styles/index.ts | 26 | TypeScript | 0.214 | suggestion | 85 | 51 | 51 | false | Make doctype be case insensitive | 419 | withastro/astro | 47,179 | TypeScript | natemoo-re | matthewp |
do {
const char = next_char(state);
if (char === '\n') {
break;
}
} while (in_bounds(state));
}
const voidElements = new Set(['area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr']);
function consume_tag(state: ParseSta... | This was the bug in the parser: we forgot to look for "`" as a valid string character when parsing HTML tags (hence why it only broke when inlined in tags, and wouldn’t break elsewhere)
This behavior was inconsistent with the rest of the parser which usually looks for all 3 string characters. And as far as I can tel... | do {
const char = next_char(state);
if (char === '\n') {
break;
}
} while (in_bounds(state));
}
const voidElements = new Set(['area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr']);
function consume_tag(state: ParseSta... | @@ -84,7 +84,8 @@ function consume_tag(state: ParseState) {
switch (char) {
case "'":
- case '"': {
+ case '"':
+ case '`': { | packages/astro-parser/src/parse/read/expression.ts | 26 | TypeScript | 0.714 | bug | 372 | 51 | 51 | false | Fix parser error on forward slash | 469 | withastro/astro | 47,179 | TypeScript | drwpow | drwpow |
const frontendPath = new URL('./frontend/', import.meta.url);
const resolveDependency = (dep: string) => resolve.sync(dep, { basedir: fileURLToPath(projectRoot) });
const isHmrEnabled = mode === 'development';
// The config manager takes care of the runtime config module (that handles setting renderers, mostl... | `'/_astro' -> '/_astro/src'` is short-term fix since I know some people have hard-coded URLs and we want them to keep working. If we're about to launch `Astro.ref()` to remove those hardcoding in your project, then I'd rather keep this bandaid around until we do that. | const frontendPath = new URL('./frontend/', import.meta.url);
const resolveDependency = (dep: string) => resolve.sync(dep, { basedir: fileURLToPath(projectRoot) });
const isHmrEnabled = mode === 'development';
// The config manager takes care of the runtime config module (that handles setting renderers, mostly... | @@ -335,7 +336,7 @@ async function createSnowpack(astroConfig: AstroConfig, options: CreateSnowpackO
const mountOptions = {
...(existsSync(astroConfig.public) ? { [fileURLToPath(astroConfig.public)]: '/' } : {}),
[fileURLToPath(frontendPath)]: '/_astro_frontend',
- [fileURLToPath(projectRoot)]: '/_astro... | packages/astro/src/runtime.ts | 26 | TypeScript | 0.643 | suggestion | 269 | 51 | 51 | false | fix issues uncovered by snowpack warnings | 511 | withastro/astro | 47,179 | TypeScript | FredKSchott | FredKSchott |
import type { ImportSpecifier, ImportDefaultSpecifier, ImportNamespaceSpecifier } from '@babel/types';
export interface AstroConfigRaw {
dist: string;
projectRoot: string;
srcRoot: string;
pages: string;
public: string;
jsx?: string;
}
export interface AstroMarkdownOptions {
/** Enable or disable footno... | Probably should call this just `src` to match pages/public which don't have the root. only projectRoot does (maybe should change that later, idk) | import type { ImportSpecifier, ImportDefaultSpecifier, ImportNamespaceSpecifier } from '@babel/types';
export interface AstroConfigRaw {
dist: string;
projectRoot: string;
src: string;
pages: string;
public: string;
jsx?: string;
}
export interface AstroMarkdownOptions {
/** Enable or disable footnotes ... | @@ -3,6 +3,7 @@ import type { ImportSpecifier, ImportDefaultSpecifier, ImportNamespaceSpecifier
export interface AstroConfigRaw {
dist: string;
projectRoot: string;
+ srcRoot: string; | packages/astro/src/@types/astro.ts | 6 | TypeScript | 0.571 | suggestion | 145 | 31 | 31 | false | fix issues uncovered by snowpack warnings | 511 | withastro/astro | 47,179 | TypeScript | matthewp | FredKSchott |
let astroPluginOptions: {
resolvePackageUrl?: (s: string) => Promise<string>;
astroConfig: AstroConfig;
hmrPort?: number;
mode: RuntimeMode;
configManager: ConfigManager;
} = {
astroConfig,
mode,
resolvePackageUrl,
configManager,
};
const mountOptions = {
...(existsSync(... | Yeah I just saw this warning. It didn't come up when I was working on the PR because of the workspace stuff :( | resolvePackageUrl?: (s: string) => Promise<string>;
astroConfig: AstroConfig;
hmrPort?: number;
mode: RuntimeMode;
configManager: ConfigManager;
} = {
astroConfig,
mode,
resolvePackageUrl,
configManager,
};
const mountOptions = {
...(existsSync(astroConfig.public) ? { [fil... | @@ -345,7 +346,7 @@ async function createSnowpack(astroConfig: AstroConfig, options: CreateSnowpackO
// Make sure that Snowpack builds our renderer plugins
const rendererInstances = await configManager.buildRendererInstances();
- const knownEntrypoints: string[] = [];
+ const knownEntrypoints: string[] = ['as... | packages/astro/src/runtime.ts | 26 | TypeScript | 0.429 | suggestion | 110 | 51 | 51 | false | fix issues uncovered by snowpack warnings | 511 | withastro/astro | 47,179 | TypeScript | matthewp | FredKSchott |
const globResult = fetchContent(spec, { namespace, filename: state.filename });
let imports = '';
for (const importStatement of globResult.imports) {
imports += importStatement + '\n';
}
createCollection = imports + crea... | ```suggestion
let transpiledScript = transpileExpressionSafe(script, { state, compileOptions, location });
``` | let imports = '';
for (const importStatement of globResult.imports) {
imports += importStatement + '\n';
}
createCollection = imports + createCollection.substring(0, declaration.start || 0) + globResult.code + createCollection.substring(... | @@ -411,12 +409,16 @@ function compileModule(module: Script, state: CodegenState, compileOptions: Comp
for (const [namespace, { spec }] of contentImports.entries()) {
const globResult = fetchContent(spec, { namespace, filename: state.filename });
for (const importStatement of globResult.imports) {
- ... | packages/astro/src/compiler/codegen/index.ts | 26 | TypeScript | 0.714 | suggestion | 113 | 51 | 51 | false | New Props API | 515 | withastro/astro | 47,179 | TypeScript | duncanhealy | natemoo-re |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.