-
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement new transform-runtime protocol for runtime package name (#160)
* Implement new transform-runtime protocol for runtime package name * Better error mesage
- Loading branch information
1 parent
8c6d4d7
commit 185c51f
Showing
7 changed files
with
101 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
packages/babel-helper-define-polyfill-provider/test/misc.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import * as babel from "@babel/core"; | ||
import definePolyfillProvider from "../lib"; | ||
|
||
function transform(code, objs) { | ||
return babel.transformSync(code, { | ||
configFile: false, | ||
plugins: objs.map(obj => [ | ||
definePolyfillProvider(() => ({ usagePure() {}, ...obj })), | ||
{ method: "usage-pure" }, | ||
]), | ||
}); | ||
} | ||
|
||
describe("misc", () => { | ||
it("warns if two different providers provide a @babel/runtime alternative", () => { | ||
const warn = jest.spyOn(console, "warn").mockImplementation(() => {}); | ||
try { | ||
transform("code", [ | ||
{ name: "provider-1", runtimeName: "@provider-1/babel-runtime" }, | ||
{ name: "provider-2", runtimeName: "@provider-2/babel-runtime" }, | ||
]); | ||
|
||
expect(warn).toHaveBeenCalledTimes(1); | ||
expect(warn.mock.lastCall[0]).toMatchInlineSnapshot( | ||
`"Two different polyfill providers (provider-1 and provider-2) are trying to define two conflicting @babel/runtime alternatives: @provider-1/babel-runtime and @provider-2/babel-runtime. The second one will be ignored."`, | ||
); | ||
} finally { | ||
warn.mockRestore(); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters