Skip to content

Commit

Permalink
fix: resolve failed when package use node as key (#1516)
Browse files Browse the repository at this point in the history
* fix: resolve failed when package use node as key

* test: add testcase
  • Loading branch information
sorrycc authored Aug 21, 2024
1 parent 9a5a92f commit e09880d
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ $ OKAM=/PATH/TO/umijs/marko/packages/bundler-mako/index.js bigfish build
```

Performance analysis with [Xcode instruments](https://help.apple.com/instruments/mac) in umi or bigfish.

```bash
$ XCODE_PROFILE=1 OKAM=/PATH/TO/umijs/marko/packages/bundler-mako/index.js umi build
$ XCODE_PROFILE=1 OKAM=/PATH/TO/umijs/marko/packages/bundler-mako/index.js umi dev
Expand Down
2 changes: 2 additions & 0 deletions crates/mako/src/resolve/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ fn get_resolver(config: &Config, resolver_type: ResolverType) -> Resolver {
"import".to_string(),
"module".to_string(),
"webpack".to_string(),
"node".to_string(),
],
),
main_fields: vec!["module".to_string(), "main".to_string()],
Expand All @@ -374,6 +375,7 @@ fn get_resolver(config: &Config, resolver_type: ResolverType) -> Resolver {
"require".to_string(),
"module".to_string(),
"webpack".to_string(),
"node".to_string(),
],
),
main_fields: vec!["module".to_string(), "main".to_string()],
Expand Down
5 changes: 5 additions & 0 deletions e2e/fixtures/config.platform.node.resolve/expect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const assert = require("assert");
const { parseBuildResult, trim, moduleReg } = require("../../../scripts/test-utils");
const { files } = parseBuildResult(__dirname);

const content = files["index.js"];
3 changes: 3 additions & 0 deletions e2e/fixtures/config.platform.node.resolve/mako.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"platform": "node"
}

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

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

2 changes: 2 additions & 0 deletions e2e/fixtures/config.platform.node.resolve/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
let foo = require('foo');
console.log(foo);

0 comments on commit e09880d

Please sign in to comment.