Skip to content

Commit

Permalink
fix: node polyfill support timers (#1142)
Browse files Browse the repository at this point in the history
  • Loading branch information
sorrycc authored May 9, 2024
1 parent ef73b66 commit b008ac5
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion crates/mako/src/resolve/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ fn do_resolve(
}
_ => {
eprintln!(
"failed to resolve {} from {} with oxc-resolver err: {:?}",
"failed to resolve {} from {} with resolver err: {:?}",
source,
path.to_string_lossy(),
oxc_resolve_err
Expand Down
6 changes: 5 additions & 1 deletion e2e/fixtures/node-polyfill/expect.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ assert.match(
"should have empty module: fs/promise"
);
assert(
content.includes(`var _path = /*#__PURE__*/ _interop_require_default._(__mako_require__("../../../node_modules/.pnpm/node-libs-browser-okam@2.2.4/node_modules/node-libs-browser-okam/polyfill/path.js"));`),
content.includes(`var _path = /*#__PURE__*/ _interop_require_default._(__mako_require__("../../../node_modules/.pnpm/node-libs-browser-okam`),
"should have polyfill module: path"
);
assert(
content.includes(`exports.setTimeout = function() {`),
"should have polyfill module: timers"
);
3 changes: 3 additions & 0 deletions e2e/fixtures/node-polyfill/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ console.log(fs_promise);

import path from "path";
console.log(path);

import { setTimeout } from 'timers';
console.log(setTimeout);
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"get-port": "^7.1.0",
"husky": "^8.0.3",
"less": "^4.2.0",
"node-libs-browser-okam": "2.2.4",
"node-libs-browser-okam": "^2.2.5",
"playwright": "^1.39.0",
"portfinder": "^1.0.32",
"react": "18.2.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/mako/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"yargs-parser": "^21.1.1",
"less": "^4.2.0",
"less-plugin-resolve": "^1.0.2",
"node-libs-browser-okam": "2.2.4",
"node-libs-browser-okam": "^2.2.5",
"react-error-overlay": "6.0.9",
"react-refresh": "^0.14.0",
"workerpool": "^9.1.1"
Expand Down Expand Up @@ -68,4 +68,4 @@
"@umijs/mako-linux-x64-gnu": "0.4.14"
},
"repository": "[email protected]:umijs/mako.git"
}
}
12 changes: 6 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b008ac5

Please sign in to comment.