Skip to content

Commit

Permalink
chore: rename harmony
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiahan committed Oct 18, 2024
1 parent 27f197c commit 09fc1ed
Show file tree
Hide file tree
Showing 36 changed files with 84 additions and 84 deletions.
2 changes: 1 addition & 1 deletion crates/rspack_core/src/concatenated_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@ impl Module for ConcatenatedModule {
let mut result = ConcatSource::default();
let mut should_add_harmony_flag = false;

// Add harmony compatibility flag (must be first because of possible circular dependencies)
// Add ESM compatibility flag (must be first because of possible circular dependencies)
if compilation
.get_module_graph()
.get_exports_info(&self.id())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -858,9 +858,9 @@ impl HarmonyExportImportedSpecifierDependency {
) -> Option<Vec<Diagnostic>> {
let create_error = |message: String| {
let (severity, title) = if should_error {
(Severity::Error, "HarmonyLinkingError")
(Severity::Error, "ESModulesLinkingError")
} else {
(Severity::Warning, "HarmonyLinkingWarning")
(Severity::Warning, "ESModulesLinkingWarning")
};
let parent_module_identifier = module_graph
.get_parent_module(&self.id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,9 @@ pub fn harmony_import_dependency_get_linking_error<T: ModuleDependency>(
);
let create_error = |message: String| {
let (severity, title) = if should_error {
(Severity::Error, "HarmonyLinkingError")
(Severity::Error, "ESModulesLinkingError")
} else {
(Severity::Warning, "HarmonyLinkingWarning")
(Severity::Warning, "ESModulesLinkingWarning")
};
let mut diagnostic = if let Some(span) = module_dependency.range()
&& let Some(source) = parent_module.original_source().map(|s| s.source())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ impl ParserAndGenerator for JavaScriptParserAndGenerator {
_mg: &ModuleGraph,
_cg: &ChunkGraph,
) -> Option<Cow<'static, str>> {
// Only harmony modules are valid for optimization
// Only ES modules are valid for optimization
if module.build_meta().is_none()
|| module
.build_meta()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ __webpack_require__.hmd = function (module) {
Object.defineProperty(module, 'exports', {
enumerable: true,
set: function () {
throw new Error('ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: ' + module.id);
throw new Error('ES modules may not assign module.exports or exports.*, Use ESM export syntax, instead: ' + module.id);
}
});
return module;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ const value = foo + (bar_default())
export { value };
`;
exports[`config config/library/modern-module-force-concaten step should pass: harmony export should concat 1`] = `
exports[`config config/library/modern-module-force-concaten step should pass: ESM export should concat 1`] = `
;// CONCATENATED MODULE: ./a.js
const a = 'a'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ module.exports = {
*/
const handler = compilation => {
compilation.hooks.afterProcessAssets.tap("testcase", assets => {
expect(assets['a.js']._value).toMatchSnapshot("harmony export should concat");
expect(assets['a.js']._value).toMatchSnapshot("ESM export should concat");
expect(assets['b.js']._value).toMatchSnapshot(".cjs should bail out");
expect(assets['c.js']._value).toMatchSnapshot("unambiguous should bail out");
expect(assets['d.js']._value).toMatchSnapshot(".mjs should concat");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
it("should throw if harmony export default from is used", () => {
it("should throw if ESM export default from is used", () => {
expect(() => require("./foo")).toThrowError(/Module parse failed/);
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "./bbb";

it("should decorate esm and commonjs mix with harmony module decorator when assign to module.exports", function () {
it("should decorate esm and commonjs mix with ES modules decorator when assign to module.exports", function () {
expect(function () {
module.exports = 1;
}).toThrowError();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import "./bbb";

module = 1;

it("should decorate esm and commonjs mix with harmony module decorator when assign to module", function () {
it("should decorate esm and commonjs mix with ES modules decorator when assign to module", function () {
expect(function () {
__webpack_module__.exports = 1;
}).toThrowError();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import "./bbb";

module.__esModule = 1;

it("should decorate esm and commonjs mix with harmony module decorator when assign to module._esModule", function () {
it("should decorate esm and commonjs mix with ES modules decorator when assign to module._esModule", function () {
expect(function () {
__webpack_module__.exports = 1;
}).toThrowError();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import "./bbb";

Object.keys(module);

it("should decorate esm and commonjs mix with harmony module decorator when access module", function () {
it("should decorate esm and commonjs mix with ES modules decorator when access module", function () {
expect(function () {
__webpack_module__.exports = 1;
}).toThrowError();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "./bbb";

it("should decorate esm and commonjs mix with harmony module decorator when Object.defineProperty(module, 'exports', xxx);", function () {
it("should decorate esm and commonjs mix with ES modules decorator when Object.defineProperty(module, 'exports', xxx);", function () {
expect(function () {
Object.defineProperty(module, "exports", 1);
}).toThrowError();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import "./bbb";

module.xxx = 1;

it("should decorate esm and commonjs mix with harmony module decorator when assign to module.xxx", function () {
it("should decorate esm and commonjs mix with ES modules decorator when assign to module.xxx", function () {
expect(function () {
__webpack_module__.exports = 1;
}).toThrowError();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "./bbb";

it("should decorate esm and commonjs mix with harmony module decorator when assign to module.exports", function () {
it("should decorate esm and commonjs mix with ES modules decorator when assign to module.exports", function () {
expect(function () {
module.exports = 1;
}).toThrowError();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import "./bbb";

module = 1;

it("should decorate esm and commonjs mix with harmony module decorator when assign to module", function () {
it("should decorate esm and commonjs mix with ES modules decorator when assign to module", function () {
expect(function () {
__webpack_module__.exports = 1;
}).toThrowError();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import "./bbb";

module.__esModule = 1;

it("should decorate esm and commonjs mix with harmony module decorator when assign to module._esModule", function () {
it("should decorate esm and commonjs mix with ES modules decorator when assign to module._esModule", function () {
expect(function () {
__webpack_module__.exports = 1;
}).toThrowError();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "./bbb";

it("should decorate esm and commonjs mix with harmony module decorator when access module", function () {
it("should decorate esm and commonjs mix with ES modules decorator when access module", function () {
expect(function () {
__webpack_module__.exports = 1;
}).toThrowError();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "./bbb";

it("should decorate esm and commonjs mix with harmony module decorator when Object.defineProperty(module, 'exports', xxx);", function () {
it("should decorate esm and commonjs mix with ES modules decorator when Object.defineProperty(module, 'exports', xxx);", function () {
expect(function () {
Object.defineProperty(module, "exports", 1);
}).toThrowError();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import "./bbb";

module.xxx = 1;

it("should decorate esm and commonjs mix with harmony module decorator when assign to module.xxx", function () {
it("should decorate esm and commonjs mix with ES modules decorator when assign to module.xxx", function () {
expect(function () {
__webpack_module__.exports = 1;
}).toThrowError();
Expand Down
2 changes: 1 addition & 1 deletion packages/rspack/src/RuntimeGlobals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export const RuntimeGlobals = {
compatGetDefaultExport: "__webpack_require__.n",

/**
* harmony module decorator
* ES modules decorator
*/
harmonyModuleDecorator: "__webpack_require__.hmd",

Expand Down
2 changes: 1 addition & 1 deletion tests/webpack-examples/build-http/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ modules by path https:// 30 KiB
https://unpkg.com/p-map-series?module 263 bytes [built] [code generated]
[exports: default]
[used exports unknown]
harmony side effect evaluation https://unpkg.com/p-map-series?module ./example.js 4:0-58
ESM side effect evaluation https://unpkg.com/p-map-series?module ./example.js 4:0-58
ESM import specifier https://unpkg.com/p-map-series?module ./example.js 8:12-17
./example.js 314 bytes [built] [code generated]
[no exports]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -589,21 +589,21 @@ chunk (runtime: runtime) react-vendors.js (react-vendors) 87 bytes ={runtime}= >
./node_modules/prop-types.js 31 bytes [built] [code generated]
[used exports unknown]
from origin ./lazy.js
harmony side effect evaluation prop-types ./lazy.js 2:0-35
ESM side effect evaluation prop-types ./lazy.js 2:0-35
ESM import specifier prop-types ./lazy.js 4:20-29
cjs self exports reference ./node_modules/prop-types.js 1:0-14
entry prop-types react-vendors
./node_modules/react-dom.js 30 bytes [built] [code generated]
[used exports unknown]
from origin ./page1.js
harmony side effect evaluation react-dom ./page1.js 3:0-33
ESM side effect evaluation react-dom ./page1.js 3:0-33
ESM import specifier react-dom ./page1.js 5:36-44
cjs self exports reference ./node_modules/react-dom.js 1:0-14
entry react-dom react-vendors
./node_modules/react.js 26 bytes [built] [code generated]
[used exports unknown]
from origin ./page1.js
harmony side effect evaluation react ./page1.js 2:0-26
ESM side effect evaluation react ./page1.js 2:0-26
ESM import specifier react ./page1.js 5:29-34
cjs self exports reference ./node_modules/react.js 1:0-14
entry react react-vendors
Expand Down Expand Up @@ -660,21 +660,21 @@ chunk (runtime: runtime) react-vendors.js (react-vendors) 87 bytes ={runtime}= >
./node_modules/prop-types.js 31 bytes [built] [code generated]
[used exports unknown]
from origin ./lazy.js
harmony side effect evaluation prop-types ./lazy.js 2:0-35
ESM side effect evaluation prop-types ./lazy.js 2:0-35
ESM import specifier prop-types ./lazy.js 4:20-29
cjs self exports reference ./node_modules/prop-types.js 1:0-14
entry prop-types react-vendors
./node_modules/react-dom.js 30 bytes [built] [code generated]
[used exports unknown]
from origin ./page1.js
harmony side effect evaluation react-dom ./page1.js 3:0-33
ESM side effect evaluation react-dom ./page1.js 3:0-33
ESM import specifier react-dom ./page1.js 5:36-44
cjs self exports reference ./node_modules/react-dom.js 1:0-14
entry react-dom react-vendors
./node_modules/react.js 26 bytes [built] [code generated]
[used exports unknown]
from origin ./page1.js
harmony side effect evaluation react ./page1.js 2:0-26
ESM side effect evaluation react ./page1.js 2:0-26
ESM import specifier react ./page1.js 5:29-34
cjs self exports reference ./node_modules/react.js 1:0-14
entry react react-vendors
Expand Down
12 changes: 6 additions & 6 deletions tests/webpack-examples/code-splitting-depend-on-simple/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,21 +312,21 @@ chunk (runtime: react-vendors) react-vendors.js (react-vendors) 87 bytes (javasc
./node_modules/prop-types.js 31 bytes [built] [code generated]
[used exports unknown]
from origin ./app.js
harmony side effect evaluation prop-types ./app.js 3:0-35
ESM side effect evaluation prop-types ./app.js 3:0-35
ESM import specifier prop-types ./app.js 5:29-38
cjs self exports reference ./node_modules/prop-types.js 1:0-14
entry prop-types react-vendors
./node_modules/react-dom.js 30 bytes [built] [code generated]
[used exports unknown]
from origin ./app.js
harmony side effect evaluation react-dom ./app.js 2:0-33
ESM side effect evaluation react-dom ./app.js 2:0-33
ESM import specifier react-dom ./app.js 5:19-27
cjs self exports reference ./node_modules/react-dom.js 1:0-14
entry react-dom react-vendors
./node_modules/react.js 26 bytes [built] [code generated]
[used exports unknown]
from origin ./app.js
harmony side effect evaluation react ./app.js 1:0-26
ESM side effect evaluation react ./app.js 1:0-26
ESM import specifier react ./app.js 5:12-17
cjs self exports reference ./node_modules/react.js 1:0-14
entry react react-vendors
Expand All @@ -353,21 +353,21 @@ chunk (runtime: react-vendors) react-vendors.js (react-vendors) 87 bytes (javasc
./node_modules/prop-types.js 31 bytes [built] [code generated]
[used exports unknown]
from origin ./app.js
harmony side effect evaluation prop-types ./app.js 3:0-35
ESM side effect evaluation prop-types ./app.js 3:0-35
ESM import specifier prop-types ./app.js 5:29-38
cjs self exports reference ./node_modules/prop-types.js 1:0-14
entry prop-types react-vendors
./node_modules/react-dom.js 30 bytes [built] [code generated]
[used exports unknown]
from origin ./app.js
harmony side effect evaluation react-dom ./app.js 2:0-33
ESM side effect evaluation react-dom ./app.js 2:0-33
ESM import specifier react-dom ./app.js 5:19-27
cjs self exports reference ./node_modules/react-dom.js 1:0-14
entry react-dom react-vendors
./node_modules/react.js 26 bytes [built] [code generated]
[used exports unknown]
from origin ./app.js
harmony side effect evaluation react ./app.js 1:0-26
ESM side effect evaluation react ./app.js 1:0-26
ESM import specifier react ./app.js 5:12-17
cjs self exports reference ./node_modules/react.js 1:0-14
entry react react-vendors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ it("should load a module from dll", function() {
expect(require("dll/index")).toEqual(nsObj({ bar: "bar", default: 42 }));
});

it("should load an harmony module from dll (default export)", function() {
it("should load an ES module from dll (default export)", function() {
expect(Answer).toBe(42);
});

it("should load an harmony module from dll (star export)", function() {
it("should load an ES module from dll (star export)", function() {
expect(bar).toBe("bar");
});

Expand Down
4 changes: 2 additions & 2 deletions tests/webpack-test/configCases/dll-plugin/1-use-dll/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ it("should load an async module from dll", function(done) {
.catch(done);
});

it("should load an harmony module from dll (default export)", function() {
it("should load an ES module from dll (default export)", function() {
expect(d).toBe("d");
});

it("should load an harmony module from dll (star export)", function() {
it("should load an ES module from dll (star export)", function() {
expect(x1).toBe(123);
expect(x2).toBe(123);
expect(y1).toBe(456);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ it("should load an async module from dll", function (done) {
.catch(done);
});

it("should load an harmony module from dll (default export)", function () {
it("should load an ES module from dll (default export)", function () {
expect(d).toBe("d");
});

it("should load an harmony module from dll (star export)", function () {
it("should load an ES module from dll (star export)", function () {
expect(x1).toBe(123);
expect(x2).toBe(123);
expect(y1).toBe(456);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ it("should load an async module from dll", function(done) {
}).catch(done);
});

it("should load an harmony module from dll (default export)", function() {
it("should load an ES module from dll (default export)", function() {
expect(d).toBe("d");
});

it("should load an harmony module from dll (star export)", function() {
it("should load an ES module from dll (star export)", function() {
expect(x1).toBe(123);
expect(x2).toBe(123);
expect(y1).toBe(456);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {bindThis, callThis, applyThis} from "./issue-7213";

import * as abc from "./abc";

it("should have this = undefined on harmony modules", () => {
it("should have this = undefined on ES modules", () => {
expect((typeof that)).toBe("undefined");
expect((typeof abc.that)).toBe("undefined");
expect((typeof returnThisArrow())).toBe("undefined");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {bindThis, callThis, applyThis} from "./issue-7213";

import * as abc from "./abc";

it("should have this = undefined on harmony modules", () => {
it("should have this = undefined on ES modules", () => {
expect((typeof that)).toBe("undefined");
expect((typeof abc.that)).toBe("undefined");
expect((typeof returnThisArrow())).toBe("undefined");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ it("should throw exception when module.exports is assigned in es module", functi
expect(function() {
require("./esm-import-cjs-export");
}).toThrowError(
'ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: ./esm-import-cjs-export.js'
'ES modules may not assign module.exports or exports.*, Use ESM export syntax, instead: ./esm-import-cjs-export.js'
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ module.exports = {
- ./module-a.js XX bytes [built] [code generated]
- import() ./module-a ./eXX.js
- import() ./module-a ./module-c.js
+ harmony side effect evaluation ./module-x ./eXX.js XX:XX-XX
+ harmony side effect evaluation ./module-x ./eXX.js XX:XX-XX
+ ESM side effect evaluation ./module-x ./eXX.js XX:XX-XX
+ ESM side effect evaluation ./module-x ./eXX.js XX:XX-XX
+ import() ./module-x ./module-b.js XX:XX-XX
@@ -14,5 +12,1 @@
- import() ./module-b ./module-a.js
Expand All @@ -41,8 +41,8 @@ module.exports = {
- esm import ./module-x ./eXX.js
- esm import ./module-x ./eXX.js
- import() ./module-x ./module-b.js
+ harmony side effect evaluation ./module-x ./eXX.js XX:XX-XX
+ harmony side effect evaluation ./module-x ./eXX.js XX:XX-XX
+ ESM side effect evaluation ./module-x ./eXX.js XX:XX-XX
+ ESM side effect evaluation ./module-x ./eXX.js XX:XX-XX
+ import() ./module-x ./module-b.js XX:XX-XX
+ chunk (runtime: eXX, eXX) c.js (c) XX bytes <{XX}> <{XX}> >{XX}< [rendered]
+ ./module-c.js XX bytes [built] [code generated]
Expand Down
Loading

0 comments on commit 09fc1ed

Please sign in to comment.