mirror of
https://github.com/swc-project/swc.git
synced 2024-12-22 21:21:31 +03:00
65d376a91b
swc: - Allow parsing input as a `Program`. (Closes #2541)
17 lines
488 B
JavaScript
17 lines
488 B
JavaScript
const swc = require("../../");
|
|
|
|
it("should detect script", () => {
|
|
const script = swc.parseSync(`const fs = require('fs');`, { isModule: "unknown" });
|
|
expect(script.type).toBe("Script");
|
|
});
|
|
|
|
it("should default to isModule: true", () => {
|
|
const script = swc.parseSync(`foo;`, {});
|
|
expect(script.type).toBe("Module");
|
|
});
|
|
|
|
it("should detect module", () => {
|
|
const script = swc.parseSync(`import fs from "fs";`, { isModule: "unknown" });
|
|
expect(script.type).toBe("Module");
|
|
});
|