Revert "Merge pull request #12278 from xtuc/sven/import-assertions"

This reverts commit df02bc6c0a, reversing
changes made to a6f341e243.
This commit is contained in:
Tobias Koppers 2021-07-16 21:54:21 +02:00
parent db52c58a4f
commit 61946b7c46
28 changed files with 114 additions and 285 deletions

7
declarations.d.ts vendored
View File

@ -371,13 +371,6 @@ declare module "browserslist" {
export = browserslist;
}
// TODO remove that when @types/estree is updated
interface ImportAttributeNode {
type: "ImportAttribute";
key: import("estree").Identifier | import("estree").Literal;
value: import("estree").Literal;
}
type TODO = any;
type RecursiveArrayOrRecord<T> =

View File

@ -1316,12 +1316,6 @@ export interface ModuleOptions {
* A rule description with conditions and effects for modules.
*/
export interface RuleSetRule {
/**
* Match on import assertions of the dependency.
*/
assert?: {
[k: string]: RuleSetConditionOrConditions;
};
/**
* Match the child compiler name.
*/

View File

@ -293,13 +293,9 @@ class NormalModule extends Module {
*/
identifier() {
if (this.layer === null) {
if (this.type === "javascript/auto") {
return this.request;
} else {
return `${this.type}|${this.request}`;
}
return this.request;
} else {
return `${this.type}|${this.request}|${this.layer}`;
return `${this.request}|${this.layer}`;
}
}

View File

@ -20,7 +20,7 @@ const ModuleGraph = require("./ModuleGraph");
const NormalModule = require("./NormalModule");
const BasicEffectRulePlugin = require("./rules/BasicEffectRulePlugin");
const BasicMatcherRulePlugin = require("./rules/BasicMatcherRulePlugin");
const ObjectMatcherRulePlugin = require("./rules/ObjectMatcherRulePlugin");
const DescriptionDataMatcherRulePlugin = require("./rules/DescriptionDataMatcherRulePlugin");
const RuleSetCompiler = require("./rules/RuleSetCompiler");
const UseEffectRulePlugin = require("./rules/UseEffectRulePlugin");
const LazySet = require("./util/LazySet");
@ -44,7 +44,6 @@ const { parseResource } = require("./util/identifier");
* @property {ModuleFactoryCreateData["resolveOptions"]} resolveOptions
* @property {string} context
* @property {string} request
* @property {Record<string, any> | undefined} assertions
* @property {ModuleDependency[]} dependencies
* @property {Object} createData
* @property {LazySet<string>} fileDependencies
@ -183,8 +182,7 @@ const ruleSetCompiler = new RuleSetCompiler([
new BasicMatcherRulePlugin("issuer"),
new BasicMatcherRulePlugin("compiler"),
new BasicMatcherRulePlugin("issuerLayer"),
new ObjectMatcherRulePlugin("assert", "assertions"),
new ObjectMatcherRulePlugin("descriptionData"),
new DescriptionDataMatcherRulePlugin(),
new BasicEffectRulePlugin("type"),
new BasicEffectRulePlugin("sideEffects"),
new BasicEffectRulePlugin("parser"),
@ -341,7 +339,6 @@ class NormalModuleFactory extends ModuleFactory {
context,
dependencies,
request,
assertions,
resolveOptions,
fileDependencies,
missingDependencies,
@ -450,7 +447,6 @@ class NormalModuleFactory extends ModuleFactory {
resourceQuery: resourceDataForRules.query,
resourceFragment: resourceDataForRules.fragment,
scheme,
assertions,
mimetype: matchResourceData ? "" : resourceData.data.mimetype || "",
dependency: dependencyType,
descriptionData: matchResourceData
@ -698,7 +694,6 @@ class NormalModuleFactory extends ModuleFactory {
const resolveOptions = data.resolveOptions || EMPTY_RESOLVE_OPTIONS;
const dependency = dependencies[0];
const request = dependency.request;
const assertions = dependency.assertions;
const contextInfo = data.contextInfo;
const fileDependencies = new LazySet();
const missingDependencies = new LazySet();
@ -709,7 +704,6 @@ class NormalModuleFactory extends ModuleFactory {
resolveOptions,
context,
request,
assertions,
dependencies,
fileDependencies,
missingDependencies,

View File

@ -482,6 +482,18 @@ const applyModuleDefaults = (
or: ["text/javascript", "application/javascript"]
},
...esm
},
{
dependency: "url",
oneOf: [
{
scheme: /^data$/,
type: "asset/inline"
},
{
type: "asset/resource"
}
]
}
];
if (asyncWebAssembly) {
@ -529,24 +541,6 @@ const applyModuleDefaults = (
...wasm
});
}
rules.push(
{
dependency: "url",
oneOf: [
{
scheme: /^data$/,
type: "asset/inline"
},
{
type: "asset/resource"
}
]
},
{
assert: { type: "json" },
type: "json"
}
);
return rules;
});
};

View File

@ -12,8 +12,7 @@ const HarmonyExportHeaderDependency = require("./HarmonyExportHeaderDependency")
const HarmonyExportImportedSpecifierDependency = require("./HarmonyExportImportedSpecifierDependency");
const HarmonyExportSpecifierDependency = require("./HarmonyExportSpecifierDependency");
const {
harmonySpecifierTag,
getAssertions
harmonySpecifierTag
} = require("./HarmonyImportDependencyParserPlugin");
const HarmonyImportSideEffectDependency = require("./HarmonyImportSideEffectDependency");
@ -49,8 +48,7 @@ module.exports = class HarmonyExportDependencyParserPlugin {
parser.state.module.addPresentationalDependency(clearDep);
const sideEffectDep = new HarmonyImportSideEffectDependency(
source,
parser.state.lastHarmonyImportOrder,
getAssertions(statement)
parser.state.lastHarmonyImportOrder
);
sideEffectDep.loc = Object.create(statement.loc);
sideEffectDep.loc.index = -1;
@ -129,8 +127,7 @@ module.exports = class HarmonyExportDependencyParserPlugin {
harmonyNamedExports,
null,
this.strictExportPresence,
null,
settings.assertions
null
);
} else {
dep = new HarmonyExportSpecifierDependency(id, name);

View File

@ -159,7 +159,6 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
* @param {ReadonlyArray<HarmonyExportImportedSpecifierDependency> | Iterable<HarmonyExportImportedSpecifierDependency>} otherStarExports other star exports in the module before this import
* @param {boolean} strictExportPresence when true, missing exports in the imported module lead to errors instead of warnings
* @param {HarmonyStarExportsList} allStarExports all star exports in the module
* @param {Record<string, any>=} assertions import assertions
*/
constructor(
request,
@ -169,10 +168,9 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
activeExports,
otherStarExports,
strictExportPresence,
allStarExports,
assertions
allStarExports
) {
super(request, sourceOrder, assertions);
super(request, sourceOrder);
this.ids = ids;
this.name = name;

View File

@ -32,12 +32,10 @@ class HarmonyImportDependency extends ModuleDependency {
*
* @param {string} request request string
* @param {number} sourceOrder source order
* @param {Record<string, any>=} assertions import assertions
*/
constructor(request, sourceOrder, assertions) {
constructor(request, sourceOrder) {
super(request);
this.sourceOrder = sourceOrder;
this.assertions = assertions;
}
get category() {
@ -203,14 +201,12 @@ class HarmonyImportDependency extends ModuleDependency {
serialize(context) {
const { write } = context;
write(this.sourceOrder);
write(this.assertions);
super.serialize(context);
}
deserialize(context) {
const { read } = context;
this.sourceOrder = read();
this.assertions = read();
super.deserialize(context);
}
}

View File

@ -14,11 +14,7 @@ const HarmonyExports = require("./HarmonyExports");
const HarmonyImportSideEffectDependency = require("./HarmonyImportSideEffectDependency");
const HarmonyImportSpecifierDependency = require("./HarmonyImportSpecifierDependency");
/** @typedef {import("estree").ExportAllDeclaration} ExportAllDeclaration */
/** @typedef {import("estree").ExportNamedDeclaration} ExportNamedDeclaration */
/** @typedef {import("estree").Identifier} Identifier */
/** @typedef {import("estree").ImportDeclaration} ImportDeclaration */
/** @typedef {import("estree").ImportExpression} ImportExpression */
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
/** @typedef {import("../optimize/InnerGraph").InnerGraph} InnerGraph */
/** @typedef {import("../optimize/InnerGraph").TopLevelSymbol} TopLevelSymbol */
@ -33,32 +29,8 @@ const harmonySpecifierTag = Symbol("harmony import");
* @property {number} sourceOrder
* @property {string} name
* @property {boolean} await
* @property {Record<string, any> | undefined} assertions
*/
/**
* @param {ImportDeclaration | ExportNamedDeclaration | ExportAllDeclaration | ImportExpression} node node with assertions
* @returns {Record<string, any> | undefined} assertions
*/
function getAssertions(node) {
// TODO remove cast when @types/estree has been updated to import assertions
const assertions = /** @type {{ assertions?: ImportAttributeNode[] }} */ (
node
).assertions;
if (assertions === undefined) {
return undefined;
}
const result = {};
for (const assertion of assertions) {
const key =
assertion.key.type === "Identifier"
? assertion.key.name
: assertion.key.value;
result[key] = assertion.value.value;
}
return result;
}
module.exports = class HarmonyImportDependencyParserPlugin {
constructor(options) {
this.strictExportPresence = options.strictExportPresence;
@ -93,11 +65,9 @@ module.exports = class HarmonyImportDependencyParserPlugin {
clearDep.loc = statement.loc;
parser.state.module.addPresentationalDependency(clearDep);
parser.unsetAsiPosition(statement.range[1]);
const assertions = getAssertions(statement);
const sideEffectDep = new HarmonyImportSideEffectDependency(
source,
parser.state.lastHarmonyImportOrder,
assertions
parser.state.lastHarmonyImportOrder
);
sideEffectDep.loc = statement.loc;
parser.state.module.addDependency(sideEffectDep);
@ -112,8 +82,7 @@ module.exports = class HarmonyImportDependencyParserPlugin {
name,
source,
ids,
sourceOrder: parser.state.lastHarmonyImportOrder,
assertions: getAssertions(statement)
sourceOrder: parser.state.lastHarmonyImportOrder
});
return true;
}
@ -128,8 +97,7 @@ module.exports = class HarmonyImportDependencyParserPlugin {
settings.ids,
settings.name,
expr.range,
this.strictExportPresence,
settings.assertions
this.strictExportPresence
);
dep.shorthand = parser.scope.inShorthand;
dep.directImport = true;
@ -150,8 +118,7 @@ module.exports = class HarmonyImportDependencyParserPlugin {
ids,
settings.name,
expr.range,
this.strictExportPresence,
settings.assertions
this.strictExportPresence
);
dep.asiSafe = !parser.isAsiPosition(expr.range[0]);
dep.loc = expr.loc;
@ -171,8 +138,7 @@ module.exports = class HarmonyImportDependencyParserPlugin {
ids,
settings.name,
callee.range,
this.strictExportPresence,
settings.assertions
this.strictExportPresence
);
dep.directImport = members.length === 0;
dep.call = true;
@ -240,4 +206,3 @@ module.exports = class HarmonyImportDependencyParserPlugin {
};
module.exports.harmonySpecifierTag = harmonySpecifierTag;
module.exports.getAssertions = getAssertions;

View File

@ -20,8 +20,8 @@ const HarmonyImportDependency = require("./HarmonyImportDependency");
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
class HarmonyImportSideEffectDependency extends HarmonyImportDependency {
constructor(request, sourceOrder, assertions) {
super(request, sourceOrder, assertions);
constructor(request, sourceOrder) {
super(request, sourceOrder);
}
get type() {

View File

@ -29,16 +29,8 @@ const HarmonyImportDependency = require("./HarmonyImportDependency");
const idsSymbol = Symbol("HarmonyImportSpecifierDependency.ids");
class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
constructor(
request,
sourceOrder,
ids,
name,
range,
strictExportPresence,
assertions
) {
super(request, sourceOrder, assertions);
constructor(request, sourceOrder, ids, name, range, strictExportPresence) {
super(request, sourceOrder);
this.ids = ids;
this.name = name;
this.range = range;

View File

@ -22,20 +22,13 @@ class ModuleDependency extends Dependency {
this.request = request;
this.userRequest = request;
this.range = undefined;
// assertions must be serialized by subclasses that use it
/** @type {Record<string, any> | undefined} */
this.assertions = undefined;
}
/**
* @returns {string | null} an identifier to merge equal requests
*/
getResourceIdentifier() {
let str = `module${this.request}`;
if (this.assertions !== undefined) {
str += JSON.stringify(this.assertions);
}
return str;
return `module${this.request}`;
}
/**

View File

@ -6,7 +6,6 @@
"use strict";
const { Parser: AcornParser } = require("acorn");
const { importAssertions } = require("acorn-import-assertions");
const { SyncBailHook, HookMap } = require("tapable");
const vm = require("vm");
const Parser = require("../Parser");
@ -43,10 +42,6 @@ const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
/** @typedef {import("estree").Node} AnyNode */
/** @typedef {import("estree").Program} ProgramNode */
/** @typedef {import("estree").Statement} StatementNode */
/** @typedef {import("estree").ImportDeclaration} ImportDeclarationNode */
/** @typedef {import("estree").ExportNamedDeclaration} ExportNamedDeclarationNode */
/** @typedef {import("estree").ExportDefaultDeclaration} ExportDefaultDeclarationNode */
/** @typedef {import("estree").ExportAllDeclaration} ExportAllDeclarationNode */
/** @typedef {import("estree").Super} SuperNode */
/** @typedef {import("estree").TaggedTemplateExpression} TaggedTemplateExpressionNode */
/** @typedef {import("estree").TemplateLiteral} TemplateLiteralNode */
@ -66,7 +61,7 @@ const ALLOWED_MEMBER_TYPES_ALL = 0b11;
// Syntax: https://developer.mozilla.org/en/SpiderMonkey/Parser_API
const parser = AcornParser.extend(importAssertions);
const parser = AcornParser;
class VariableInfo {
/**
@ -195,31 +190,31 @@ class JavascriptParser extends Parser {
]),
/** @type {HookMap<SyncBailHook<[LabeledStatementNode], boolean | void>>} */
label: new HookMap(() => new SyncBailHook(["statement"])),
/** @type {SyncBailHook<[ImportDeclarationNode, ImportSource], boolean | void>} */
/** @type {SyncBailHook<[StatementNode, ImportSource], boolean | void>} */
import: new SyncBailHook(["statement", "source"]),
/** @type {SyncBailHook<[ImportDeclarationNode, ImportSource, string, string], boolean | void>} */
/** @type {SyncBailHook<[StatementNode, ImportSource, string, string], boolean | void>} */
importSpecifier: new SyncBailHook([
"statement",
"source",
"exportName",
"identifierName"
]),
/** @type {SyncBailHook<[ExportNamedDeclarationNode | ExportAllDeclarationNode], boolean | void>} */
/** @type {SyncBailHook<[StatementNode], boolean | void>} */
export: new SyncBailHook(["statement"]),
/** @type {SyncBailHook<[ExportNamedDeclarationNode | ExportAllDeclarationNode, ImportSource], boolean | void>} */
/** @type {SyncBailHook<[StatementNode, ImportSource], boolean | void>} */
exportImport: new SyncBailHook(["statement", "source"]),
/** @type {SyncBailHook<[ExportNamedDeclarationNode | ExportAllDeclarationNode, DeclarationNode], boolean | void>} */
/** @type {SyncBailHook<[StatementNode, DeclarationNode], boolean | void>} */
exportDeclaration: new SyncBailHook(["statement", "declaration"]),
/** @type {SyncBailHook<[ExportDefaultDeclarationNode, DeclarationNode], boolean | void>} */
/** @type {SyncBailHook<[StatementNode, DeclarationNode], boolean | void>} */
exportExpression: new SyncBailHook(["statement", "declaration"]),
/** @type {SyncBailHook<[ExportNamedDeclarationNode | ExportAllDeclarationNode, string, string, number | undefined], boolean | void>} */
/** @type {SyncBailHook<[StatementNode, string, string, number | undefined], boolean | void>} */
exportSpecifier: new SyncBailHook([
"statement",
"identifierName",
"exportName",
"index"
]),
/** @type {SyncBailHook<[ExportNamedDeclarationNode | ExportAllDeclarationNode, ImportSource, string, string, number | undefined], boolean | void>} */
/** @type {SyncBailHook<[StatementNode, ImportSource, string, string, number | undefined], boolean | void>} */
exportImportSpecifier: new SyncBailHook([
"statement",
"source",

View File

@ -8,32 +8,28 @@
/** @typedef {import("./RuleSetCompiler")} RuleSetCompiler */
/** @typedef {import("./RuleSetCompiler").RuleCondition} RuleCondition */
class ObjectMatcherRulePlugin {
constructor(ruleProperty, dataProperty) {
this.ruleProperty = ruleProperty;
this.dataProperty = dataProperty || ruleProperty;
}
const RULE_PROPERTY = "descriptionData";
class DescriptionDataMatcherRulePlugin {
/**
* @param {RuleSetCompiler} ruleSetCompiler the rule set compiler
* @returns {void}
*/
apply(ruleSetCompiler) {
const { ruleProperty, dataProperty } = this;
ruleSetCompiler.hooks.rule.tap(
"ObjectMatcherRulePlugin",
"DescriptionDataMatcherRulePlugin",
(path, rule, unhandledProperties, result) => {
if (unhandledProperties.has(ruleProperty)) {
unhandledProperties.delete(ruleProperty);
const value = rule[ruleProperty];
if (unhandledProperties.has(RULE_PROPERTY)) {
unhandledProperties.delete(RULE_PROPERTY);
const value = rule[RULE_PROPERTY];
for (const property of Object.keys(value)) {
const nestedDataProperties = property.split(".");
const dataProperty = property.split(".");
const condition = ruleSetCompiler.compileCondition(
`${path}.${ruleProperty}.${property}`,
`${path}.${RULE_PROPERTY}.${property}`,
value[property]
);
result.conditions.push({
property: [dataProperty, ...nestedDataProperties],
property: ["descriptionData", ...dataProperty],
matchWhenEmpty: condition.matchWhenEmpty,
fn: condition.fn
});
@ -44,4 +40,4 @@ class ObjectMatcherRulePlugin {
}
}
module.exports = ObjectMatcherRulePlugin;
module.exports = DescriptionDataMatcherRulePlugin;

View File

@ -11,7 +11,6 @@
"@webassemblyjs/wasm-edit": "1.11.1",
"@webassemblyjs/wasm-parser": "1.11.1",
"acorn": "^8.4.1",
"acorn-import-assertions": "1.7.1",
"browserslist": "^4.14.5",
"chrome-trace-event": "^1.0.2",
"enhanced-resolve": "^5.8.0",

File diff suppressed because one or more lines are too long

View File

@ -3585,13 +3585,6 @@
"type": "object",
"additionalProperties": false,
"properties": {
"assert": {
"description": "Match on import assertions of the dependency.",
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/RuleSetConditionOrConditions"
}
},
"compiler": {
"description": "Match the child compiler name.",
"oneOf": [

View File

@ -191,12 +191,6 @@ describe("Defaults", () => {
},
],
},
Object {
"assert": Object {
"type": "json",
},
"type": "json",
},
],
"generator": Object {},
"noParse": undefined,
@ -825,6 +819,8 @@ describe("Defaults", () => {
- "syncWebAssembly": false,
+ "syncWebAssembly": true,
@@ ... @@
+ },
+ ],
+ },
+ Object {
+ "rules": Array [
@ -849,9 +845,9 @@ describe("Defaults", () => {
+ },
+ "resolve": Object {
+ "fullySpecified": true,
+ },
@@ ... @@
+ },
+ ],
@@ ... @@
+ "type": "webassembly/sync",
`)
);
@ -895,6 +891,8 @@ describe("Defaults", () => {
- "asyncWebAssembly": false,
+ "asyncWebAssembly": true,
@@ ... @@
+ },
+ ],
+ },
+ Object {
+ "rules": Array [
@ -919,9 +917,9 @@ describe("Defaults", () => {
+ },
+ "resolve": Object {
+ "fullySpecified": true,
+ },
@@ ... @@
+ },
+ ],
@@ ... @@
+ "type": "webassembly/async",
`)
);
@ -940,6 +938,8 @@ describe("Defaults", () => {
- "syncWebAssembly": false,
+ "syncWebAssembly": true,
@@ ... @@
+ },
+ ],
+ },
+ Object {
+ "rules": Array [
@ -954,7 +954,7 @@ describe("Defaults", () => {
+ ],
+ "test": /\\.wasm$/i,
+ "type": "webassembly/async",
+ },
@@ ... @@
+ Object {
+ "mimetype": "application/wasm",
+ "rules": Array [
@ -966,7 +966,7 @@ describe("Defaults", () => {
+ "fullySpecified": true,
+ },
+ },
+ ],
@@ ... @@
+ "type": "webassembly/async",
`)
);

View File

@ -182,7 +182,7 @@ describe("Validation", () => {
expect(msg).toMatchInlineSnapshot(`
"Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
- configuration.module.rules[0].oneOf[0] has an unknown property 'passer'. These properties are valid:
object { assert?, compiler?, dependency?, descriptionData?, enforce?, exclude?, generator?, include?, issuer?, issuerLayer?, layer?, loader?, mimetype?, oneOf?, options?, parser?, realResource?, resolve?, resource?, resourceFragment?, resourceQuery?, rules?, scheme?, sideEffects?, test?, type?, use? }
object { compiler?, dependency?, descriptionData?, enforce?, exclude?, generator?, include?, issuer?, issuerLayer?, layer?, loader?, mimetype?, oneOf?, options?, parser?, realResource?, resolve?, resource?, resourceFragment?, resourceQuery?, rules?, scheme?, sideEffects?, test?, type?, use? }
-> A rule description with conditions and effects for modules."
`)
);

View File

@ -2441,15 +2441,15 @@ LOG from webpack.FileSystemInfo
exports[`StatsTestCases should print correct stats for real-content-hash 1`] = `
"a-normal:
assets by path *.js 3.22 KiB
asset 10bfdcacb3051293cdb8-10bfdc.js 2.7 KiB [emitted] [immutable] [minimized] (name: runtime)
asset dafabd2c0a256cd3ba09-dafabd.js 288 bytes [emitted] [immutable] [minimized] (name: lazy)
asset 58b1760470afdc121e5b-58b176.js 225 bytes [emitted] [immutable] [minimized] (name: index)
asset 92b100c9dd880fb6fedd-92b100.js 2.7 KiB [emitted] [immutable] [minimized] (name: runtime)
asset a639a9edc4557744bf94-a639a9.js 288 bytes [emitted] [immutable] [minimized] (name: lazy)
asset e00b58ce2785691cd374-e00b58.js 225 bytes [emitted] [immutable] [minimized] (name: index)
asset 666f2b8847021ccc7608-666f2b.js 21 bytes [emitted] [immutable] [minimized] (name: a, b)
assets by chunk 20.4 KiB (auxiliary name: lazy)
asset 89a353e9c515885abd8e.png 14.6 KiB [emitted] [immutable] [from: file.png] (auxiliary name: lazy)
asset 7382fad5b015914e0811.jpg?query 5.89 KiB [cached] [immutable] [from: file.jpg?query] (auxiliary name: lazy)
asset 7382fad5b015914e0811.jpg 5.89 KiB [emitted] [immutable] [from: file.jpg] (auxiliary name: index)
Entrypoint index 2.92 KiB (5.89 KiB) = 10bfdcacb3051293cdb8-10bfdc.js 2.7 KiB 58b1760470afdc121e5b-58b176.js 225 bytes 1 auxiliary asset
Entrypoint index 2.92 KiB (5.89 KiB) = 92b100c9dd880fb6fedd-92b100.js 2.7 KiB e00b58ce2785691cd374-e00b58.js 225 bytes 1 auxiliary asset
Entrypoint a 21 bytes = 666f2b8847021ccc7608-666f2b.js
Entrypoint b 21 bytes = 666f2b8847021ccc7608-666f2b.js
runtime modules 7.19 KiB 9 modules
@ -2468,15 +2468,15 @@ exports[`StatsTestCases should print correct stats for real-content-hash 1`] = `
b-normal:
assets by path *.js 3.22 KiB
asset 51a734c984da3108483e-51a734.js 2.7 KiB [emitted] [immutable] [minimized] (name: runtime)
asset dafabd2c0a256cd3ba09-dafabd.js 288 bytes [emitted] [immutable] [minimized] (name: lazy)
asset 58b1760470afdc121e5b-58b176.js 225 bytes [emitted] [immutable] [minimized] (name: index)
asset b02624dcf8d618f12ba1-b02624.js 2.7 KiB [emitted] [immutable] [minimized] (name: runtime)
asset a639a9edc4557744bf94-a639a9.js 288 bytes [emitted] [immutable] [minimized] (name: lazy)
asset e00b58ce2785691cd374-e00b58.js 225 bytes [emitted] [immutable] [minimized] (name: index)
asset 666f2b8847021ccc7608-666f2b.js 21 bytes [emitted] [immutable] [minimized] (name: a, b)
assets by chunk 20.4 KiB (auxiliary name: lazy)
asset 89a353e9c515885abd8e.png 14.6 KiB [emitted] [immutable] [from: file.png] (auxiliary name: lazy)
asset 7382fad5b015914e0811.jpg?query 5.89 KiB [cached] [immutable] [from: file.jpg?query] (auxiliary name: lazy)
asset 7382fad5b015914e0811.jpg 5.89 KiB [emitted] [immutable] [from: file.jpg] (auxiliary name: index)
Entrypoint index 2.92 KiB (5.89 KiB) = 51a734c984da3108483e-51a734.js 2.7 KiB 58b1760470afdc121e5b-58b176.js 225 bytes 1 auxiliary asset
Entrypoint index 2.92 KiB (5.89 KiB) = b02624dcf8d618f12ba1-b02624.js 2.7 KiB e00b58ce2785691cd374-e00b58.js 225 bytes 1 auxiliary asset
Entrypoint a 21 bytes = 666f2b8847021ccc7608-666f2b.js
Entrypoint b 21 bytes = 666f2b8847021ccc7608-666f2b.js
runtime modules 7.19 KiB 9 modules
@ -2495,19 +2495,19 @@ b-normal:
a-source-map:
assets by path *.js 3.44 KiB
asset 53b1502f730643477466-53b150.js 2.76 KiB [emitted] [immutable] [minimized] (name: runtime)
sourceMap 53b1502f730643477466-53b150.js.map 14.2 KiB [emitted] [dev] (auxiliary name: runtime)
asset 6a0b20739c3374bc8404-6a0b20.js 344 bytes [emitted] [immutable] [minimized] (name: lazy)
sourceMap 6a0b20739c3374bc8404-6a0b20.js.map 401 bytes [emitted] [dev] (auxiliary name: lazy)
asset 20918c3d6f37be1833a3-20918c.js 281 bytes [emitted] [immutable] [minimized] (name: index)
sourceMap 20918c3d6f37be1833a3-20918c.js.map 366 bytes [emitted] [dev] (auxiliary name: index)
asset 64f4e187a137fbe6d037-64f4e1.js 2.76 KiB [emitted] [immutable] [minimized] (name: runtime)
sourceMap 64f4e187a137fbe6d037-64f4e1.js.map 14.2 KiB [emitted] [dev] (auxiliary name: runtime)
asset 05c637d15dff2d0dc5fd-05c637.js 344 bytes [emitted] [immutable] [minimized] (name: lazy)
sourceMap 05c637d15dff2d0dc5fd-05c637.js.map 399 bytes [emitted] [dev] (auxiliary name: lazy)
asset c41aff3dd03dbe1d8aa3-c41aff.js 281 bytes [emitted] [immutable] [minimized] (name: index)
sourceMap c41aff3dd03dbe1d8aa3-c41aff.js.map 366 bytes [emitted] [dev] (auxiliary name: index)
asset 222c2acc68675174e6b2-222c2a.js 77 bytes [emitted] [immutable] [minimized] (name: a, b)
sourceMap 222c2acc68675174e6b2-222c2a.js.map 254 bytes [emitted] [dev] (auxiliary name: a, b)
assets by chunk 20.4 KiB (auxiliary name: lazy)
asset 89a353e9c515885abd8e.png 14.6 KiB [emitted] [immutable] [from: file.png] (auxiliary name: lazy)
asset 7382fad5b015914e0811.jpg?query 5.89 KiB [cached] [immutable] [from: file.jpg?query] (auxiliary name: lazy)
asset 7382fad5b015914e0811.jpg 5.89 KiB [emitted] [immutable] [from: file.jpg] (auxiliary name: index)
Entrypoint index 3.03 KiB (20.5 KiB) = 53b1502f730643477466-53b150.js 2.76 KiB 20918c3d6f37be1833a3-20918c.js 281 bytes 3 auxiliary assets
Entrypoint index 3.03 KiB (20.5 KiB) = 64f4e187a137fbe6d037-64f4e1.js 2.76 KiB c41aff3dd03dbe1d8aa3-c41aff.js 281 bytes 3 auxiliary assets
Entrypoint a 77 bytes (254 bytes) = 222c2acc68675174e6b2-222c2a.js 1 auxiliary asset
Entrypoint b 77 bytes (254 bytes) = 222c2acc68675174e6b2-222c2a.js 1 auxiliary asset
runtime modules 7.19 KiB 9 modules
@ -2526,19 +2526,19 @@ a-source-map:
b-source-map:
assets by path *.js 3.44 KiB
asset 4421f63e38fac939b46f-4421f6.js 2.76 KiB [emitted] [immutable] [minimized] (name: runtime)
sourceMap 4421f63e38fac939b46f-4421f6.js.map 14.2 KiB [emitted] [dev] (auxiliary name: runtime)
asset 6a0b20739c3374bc8404-6a0b20.js 344 bytes [emitted] [immutable] [minimized] (name: lazy)
sourceMap 6a0b20739c3374bc8404-6a0b20.js.map 397 bytes [emitted] [dev] (auxiliary name: lazy)
asset 20918c3d6f37be1833a3-20918c.js 281 bytes [emitted] [immutable] [minimized] (name: index)
sourceMap 20918c3d6f37be1833a3-20918c.js.map 323 bytes [emitted] [dev] (auxiliary name: index)
asset 3e79f6f89bbfaf1c154c-3e79f6.js 2.76 KiB [emitted] [immutable] [minimized] (name: runtime)
sourceMap 3e79f6f89bbfaf1c154c-3e79f6.js.map 14.2 KiB [emitted] [dev] (auxiliary name: runtime)
asset 05c637d15dff2d0dc5fd-05c637.js 344 bytes [emitted] [immutable] [minimized] (name: lazy)
sourceMap 05c637d15dff2d0dc5fd-05c637.js.map 395 bytes [emitted] [dev] (auxiliary name: lazy)
asset c41aff3dd03dbe1d8aa3-c41aff.js 281 bytes [emitted] [immutable] [minimized] (name: index)
sourceMap c41aff3dd03dbe1d8aa3-c41aff.js.map 323 bytes [emitted] [dev] (auxiliary name: index)
asset 222c2acc68675174e6b2-222c2a.js 77 bytes [emitted] [immutable] [minimized] (name: a, b)
sourceMap 222c2acc68675174e6b2-222c2a.js.map 254 bytes [emitted] [dev] (auxiliary name: a, b)
assets by chunk 20.4 KiB (auxiliary name: lazy)
asset 89a353e9c515885abd8e.png 14.6 KiB [emitted] [immutable] [from: file.png] (auxiliary name: lazy)
asset 7382fad5b015914e0811.jpg?query 5.89 KiB [cached] [immutable] [from: file.jpg?query] (auxiliary name: lazy)
asset 7382fad5b015914e0811.jpg 5.89 KiB [emitted] [immutable] [from: file.jpg] (auxiliary name: index)
Entrypoint index 3.03 KiB (20.4 KiB) = 4421f63e38fac939b46f-4421f6.js 2.76 KiB 20918c3d6f37be1833a3-20918c.js 281 bytes 3 auxiliary assets
Entrypoint index 3.03 KiB (20.4 KiB) = 3e79f6f89bbfaf1c154c-3e79f6.js 2.76 KiB c41aff3dd03dbe1d8aa3-c41aff.js 281 bytes 3 auxiliary assets
Entrypoint a 77 bytes (254 bytes) = 222c2acc68675174e6b2-222c2a.js 1 auxiliary asset
Entrypoint b 77 bytes (254 bytes) = 222c2acc68675174e6b2-222c2a.js 1 auxiliary asset
runtime modules 7.19 KiB 9 modules
@ -4382,36 +4382,34 @@ webpack x.x.x compiled with 1 warning in X ms"
`;
exports[`StatsTestCases should print correct stats for wasm-explorer-examples-sync 1`] = `
"assets by path *.js 21.7 KiB
asset bundle.js 16.3 KiB [emitted] (name: main)
asset 325.bundle.js 3.81 KiB [emitted]
asset 795.bundle.js 571 bytes [emitted]
"assets by path *.js 21.5 KiB
asset bundle.js 16.1 KiB [emitted] (name: main)
asset 325.bundle.js 3.98 KiB [emitted]
asset 780.bundle.js 571 bytes [emitted]
asset 526.bundle.js 366 bytes [emitted] (id hint: vendors)
asset 189.bundle.js 243 bytes [emitted]
asset 517.bundle.js 243 bytes [emitted]
asset 20.bundle.js 241 bytes [emitted]
asset 230.bundle.js 243 bytes [emitted]
asset 99.bundle.js 241 bytes [emitted]
assets by path *.wasm 1.37 KiB
asset e3f145b183228cc640d7.module.wasm 531 bytes [emitted] [immutable]
asset 82d524821ee70d495948.module.wasm 290 bytes [emitted] [immutable]
asset ea450800640f54975338.module.wasm 156 bytes [emitted] [immutable]
asset ebbf27083d239c1ad5e3.module.wasm 154 bytes [emitted] [immutable]
asset ee97efb6a05a4e504238.module.wasm 154 bytes [emitted] [immutable]
asset 0301cb3f9f4151b567f5.module.wasm 120 bytes [emitted] [immutable]
chunk (runtime: main) 20.bundle.js 50 bytes (javascript) 531 bytes (webassembly) [rendered]
asset 4098dd6bcb43bd54baf6.module.wasm 531 bytes [emitted] [immutable]
asset a0bbe50b118b7ff0648b.module.wasm 290 bytes [emitted] [immutable]
asset 86fec7665231a0198df8.module.wasm 156 bytes [emitted] [immutable]
asset 1da1d844c1509ed4d4c3.module.wasm 154 bytes [emitted] [immutable]
asset 2be4d707a05b1f7313ca.module.wasm 154 bytes [emitted] [immutable]
asset d1fdb94978c775bdc12a.module.wasm 120 bytes [emitted] [immutable]
chunk (runtime: main) 99.bundle.js 50 bytes (javascript) 531 bytes (webassembly) [rendered]
./duff.wasm 50 bytes (javascript) 531 bytes (webassembly) [built] [code generated]
chunk (runtime: main) bundle.js (main) 586 bytes (javascript) 9.18 KiB (runtime) [entry] [rendered]
runtime modules 9.18 KiB 11 modules
./index.js 586 bytes [built] [code generated]
chunk (runtime: main) 189.bundle.js 50 bytes (javascript) 156 bytes (webassembly) [rendered]
chunk (runtime: main) 230.bundle.js 50 bytes (javascript) 156 bytes (webassembly) [rendered]
./Q_rsqrt.wasm 50 bytes (javascript) 156 bytes (webassembly) [built] [code generated]
chunk (runtime: main) 325.bundle.js 1.45 KiB (javascript) 154 bytes (webassembly) [rendered]
chunk (runtime: main) 325.bundle.js 1.5 KiB (javascript) 274 bytes (webassembly) [rendered]
./popcnt.wasm 50 bytes (javascript) 120 bytes (webassembly) [dependent] [built] [code generated]
./testFunction.wasm 50 bytes (javascript) 154 bytes (webassembly) [dependent] [built] [code generated]
./tests.js 1.4 KiB [built] [code generated]
chunk (runtime: main) 517.bundle.js 50 bytes (javascript) 120 bytes (webassembly) [rendered]
./popcnt.wasm 50 bytes (javascript) 120 bytes (webassembly) [built] [code generated]
chunk (runtime: main) 526.bundle.js (id hint: vendors) 34 bytes [rendered] split chunk (cache group: defaultVendors)
./node_modules/env.js 34 bytes [built] [code generated]
chunk (runtime: main) 795.bundle.js 110 bytes (javascript) 444 bytes (webassembly) [rendered]
chunk (runtime: main) 780.bundle.js 110 bytes (javascript) 444 bytes (webassembly) [rendered]
./fact.wasm 50 bytes (javascript) 154 bytes (webassembly) [built] [code generated]
./fast-math.wasm 60 bytes (javascript) 290 bytes (webassembly) [built] [code generated]
runtime modules 9.18 KiB 11 modules

View File

@ -1 +0,0 @@
throw new Error("imported")

View File

@ -1 +0,0 @@
[1, 2, 3, 4]

View File

@ -1,3 +0,0 @@
module.exports = [
[{ moduleName: /data.poison/, message: /Unexpected token .+ in JSON/ }]
];

View File

@ -1,3 +0,0 @@
import poison from "../data/poison" assert { type: "json" };
export default poison;

View File

@ -1,21 +0,0 @@
import c from "../data/c.json" assert { type: "json" };
import unknownJson from "../data/unknown" assert { type: "json" };
import unknownJs from "../data/unknown";
it("should be possible to import json data with import assertion", function () {
expect(c).toEqual([1, 2, 3, 4]);
});
it("should be possible to import json data without extension with import assertion", function () {
expect(unknownJson).toEqual([1, 2, 3, 4]);
});
it("should be possible to import js without extension without import assertion in the same file", function () {
expect(unknownJs).toEqual({});
});
it("should not be possible to import js with import assertion", function () {
expect(() => {
require("./import-poison.js");
}).toThrowError();
});

View File

@ -7,8 +7,8 @@ it("should generate the correct output files", () => {
NORMAL1 && `634.bundle${INDEX}.js`,
NORMAL2 && `882.bundle${INDEX}.js`,
`bundle${INDEX}.js`,
CONTENT2 && "localization-264.js",
"localization-530.js",
"localization-219.js",
CONTENT2 && "localization-551.js",
NORMAL1 && "localization-634.js",
NORMAL2 && "localization-882.js"
].filter(Boolean)

46
types.d.ts vendored
View File

@ -4735,44 +4735,21 @@ declare class JavascriptParser extends Parser {
boolean | void
>;
label: HookMap<SyncBailHook<[LabeledStatement], boolean | void>>;
import: SyncBailHook<[ImportDeclaration, ImportSource], boolean | void>;
import: SyncBailHook<[Statement, ImportSource], boolean | void>;
importSpecifier: SyncBailHook<
[ImportDeclaration, ImportSource, string, string],
boolean | void
>;
export: SyncBailHook<
[ExportNamedDeclaration | ExportAllDeclaration],
boolean | void
>;
exportImport: SyncBailHook<
[ExportNamedDeclaration | ExportAllDeclaration, ImportSource],
boolean | void
>;
exportDeclaration: SyncBailHook<
[ExportNamedDeclaration | ExportAllDeclaration, Declaration],
boolean | void
>;
exportExpression: SyncBailHook<
[ExportDefaultDeclaration, Declaration],
[Statement, ImportSource, string, string],
boolean | void
>;
export: SyncBailHook<[Statement], boolean | void>;
exportImport: SyncBailHook<[Statement, ImportSource], boolean | void>;
exportDeclaration: SyncBailHook<[Statement, Declaration], boolean | void>;
exportExpression: SyncBailHook<[Statement, Declaration], boolean | void>;
exportSpecifier: SyncBailHook<
[
ExportNamedDeclaration | ExportAllDeclaration,
string,
string,
undefined | number
],
[Statement, string, string, undefined | number],
boolean | void
>;
exportImportSpecifier: SyncBailHook<
[
ExportNamedDeclaration | ExportAllDeclaration,
ImportSource,
string,
string,
undefined | number
],
[Statement, ImportSource, string, string, undefined | number],
boolean | void
>;
preDeclarator: SyncBailHook<
@ -6397,7 +6374,6 @@ declare class ModuleDependency extends Dependency {
request: string;
userRequest: string;
range: any;
assertions?: Record<string, any>;
static Template: typeof DependencyTemplate;
static NO_EXPORTS_REFERENCED: string[][];
static EXPORTS_OBJECT_REFERENCED: string[][];
@ -8954,7 +8930,6 @@ declare interface ResolveData {
resolveOptions?: ResolveOptionsWebpackOptions;
context: string;
request: string;
assertions?: Record<string, any>;
dependencies: ModuleDependency[];
createData: Object;
fileDependencies: LazySet<string>;
@ -9366,11 +9341,6 @@ declare interface RuleSetLogicalConditionsAbsolute {
* A rule description with conditions and effects for modules.
*/
declare interface RuleSetRule {
/**
* Match on import assertions of the dependency.
*/
assert?: { [index: string]: RuleSetConditionOrConditions };
/**
* Match the child compiler name.
*/

View File

@ -1225,11 +1225,6 @@ acorn-globals@^6.0.0:
acorn "^7.1.1"
acorn-walk "^7.1.1"
acorn-import-assertions@1.7.1:
version "1.7.1"
resolved "https://registry.yarnpkg.com/acorn-import-assertions/-/acorn-import-assertions-1.7.1.tgz#da2c1fd00dbd7fd8b22c59957cea3e4508e64fa5"
integrity sha512-Wc7PWe2G9s9E3aPaKDvOgV00xn1HIetG3VxPs+Jtr/4nHpdfLZ/0JbEVM83QCUqV4fYilbMb+y5SSXHMzP8AVw==
acorn-jsx@^5.3.1:
version "5.3.1"
resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.1.tgz#fc8661e11b7ac1539c47dbfea2e72b3af34d267b"