Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ Before we started using OpenCollective, donations were made anonymously. Now tha

<p>(In chronological order)</p>

- [@google](https://github.com/google) for [Google Web Toolkit (GWT)](http://www.gwtproject.org/), which aims to compile Java to JavaScript. It features a similar [Code Splitting](http://www.gwtproject.org/doc/latest/DevGuideCodeSplitting.html) as webpack.
- [@google](https://github.com/google) for [Google Web Toolkit (GWT)](http://www.gwtproject.org/), which aims to compile Java to JavaScript. It features a similar [Code Splitting](http://www.gwtproject.org/doc/latest/DevGuideCodeSplitting.html) to webpack.
Copy link
Member

Choose a reason for hiding this comment

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

Avoid this change, not related to fix

- [@medikoo](https://github.com/medikoo) for [modules-webmake](https://github.com/medikoo/modules-webmake), which is a similar project. webpack was born because of the desire for code splitting for modules such as Webmake. Interestingly, the [Code Splitting issue is still open](https://github.com/medikoo/modules-webmake/issues/7) (thanks also to @Phoscur for the discussion).
- [@substack](https://github.com/substack) for [browserify](https://browserify.org/), which is a similar project and source for many ideas.
- [@jrburke](https://github.com/jrburke) for [require.js](https://requirejs.org/), which is a similar project and source for many ideas.
Expand Down
17 changes: 16 additions & 1 deletion lib/dependencies/CommonJsExportRequireDependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,22 @@ CommonJsExportRequireDependency.Template = class CommonJsExportRequireDependency
);
return;
case "Object.defineProperty":
throw new Error("TODO");
if (!used) {
source.replace(
dep.range[0],
dep.range[1] - 1,
`/* unused reexport */ ${requireExpr}`
);
return;
}
source.replace(
dep.range[0],
dep.range[1] - 1,
`Object.defineProperty(${base}${propertyAccess(
used.slice(0, -1)
)}, ${JSON.stringify(used[used.length - 1])}, { value: ${requireExpr} })`
);
return;
default:
throw new Error("Unexpected type");
}
Expand Down
26 changes: 25 additions & 1 deletion lib/util/compileBooleanMatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,32 @@ const itemsToRegexp = (itemsArr) => {
}
}
// special case for only single char items
// optimize by using character ranges: e.g., [1-4a] instead of [1234a]
if (countOfSingleCharItems === itemsArr.length) {
return `[${quoteMeta(itemsArr.sort().join(""))}]`;
const sorted = itemsArr.sort();
const ranges = [];
let start = sorted[0];
let prev = sorted[0];
for (let i = 1; i < sorted.length; i++) {
const current = sorted[i];
if (current.charCodeAt(0) === prev.charCodeAt(0) + 1) {
prev = current;
} else {
if (start === prev) {
ranges.push(quoteMeta(start));
} else {
ranges.push(`${quoteMeta(start)}-${quoteMeta(prev)}`);
}
start = current;
prev = current;
}
}
if (start === prev) {
ranges.push(quoteMeta(start));
} else {
ranges.push(`${quoteMeta(start)}-${quoteMeta(prev)}`);
}
return `[${ranges.join("")}]`;
Copy link
Member

Choose a reason for hiding this comment

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

Avoid this change, not related to fix

}
/** @type {Set<string>} */
const items = new Set(itemsArr.sort());
Expand Down