@ms-cloudpack/esm-stub-utilities
Advanced tools
Comparing version 0.2.4 to 0.3.0
@@ -5,3 +5,24 @@ { | ||
{ | ||
"date": "Tue, 06 Sep 2022 08:17:22 GMT", | ||
"date": "Wed, 21 Sep 2022 08:14:52 GMT", | ||
"tag": "@ms-cloudpack/esm-stub-utilities_v0.3.0", | ||
"version": "0.3.0", | ||
"comments": { | ||
"minor": [ | ||
{ | ||
"author": "dzearing@microsoft.com", | ||
"package": "@ms-cloudpack/esm-stub-utilities", | ||
"commit": "f67f57c632b247d0375d54d2c839447dc5c34156", | ||
"comment": "Updating string and boolean exports to emit properly." | ||
}, | ||
{ | ||
"author": "beachball", | ||
"package": "@ms-cloudpack/esm-stub-utilities", | ||
"comment": "Bump @ms-cloudpack/path-utilities to v0.5.0", | ||
"commit": "edaf39b3a641d469b5238c446b23e25399714ebd" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"date": "Tue, 06 Sep 2022 08:17:50 GMT", | ||
"tag": "@ms-cloudpack/esm-stub-utilities_v0.2.4", | ||
@@ -8,0 +29,0 @@ "version": "0.2.4", |
# Change Log - @ms-cloudpack/esm-stub-utilities | ||
This log was last generated on Tue, 06 Sep 2022 08:17:22 GMT and should not be manually modified. | ||
This log was last generated on Wed, 21 Sep 2022 08:14:52 GMT and should not be manually modified. | ||
<!-- Start content --> | ||
## 0.3.0 | ||
Wed, 21 Sep 2022 08:14:52 GMT | ||
### Minor changes | ||
- Updating string and boolean exports to emit properly. (dzearing@microsoft.com) | ||
- Bump @ms-cloudpack/path-utilities to v0.5.0 | ||
## 0.2.4 | ||
Tue, 06 Sep 2022 08:17:22 GMT | ||
Tue, 06 Sep 2022 08:17:50 GMT | ||
@@ -11,0 +20,0 @@ ### Patches |
@@ -19,3 +19,3 @@ import { slash } from '@ms-cloudpack/path-utilities'; | ||
const packageExport = tryRequire(entryPath); | ||
if (packageExport) { | ||
if (packageExport !== undefined) { | ||
let isDefaultExported = false; | ||
@@ -59,2 +59,10 @@ const isExportObject = typeof packageExport === 'object'; | ||
} | ||
else if (typeof packageExport === 'boolean' || typeof packageExport === 'number') { | ||
// Export as default. | ||
result.push(`export default ${packageExport};`); | ||
} | ||
else if (typeof packageExport === 'string') { | ||
// Export a constant. | ||
result.push(`export default ${JSON.stringify(packageExport)};`); | ||
} | ||
else { | ||
@@ -61,0 +69,0 @@ // not an object or function |
@@ -56,3 +56,3 @@ import { describe, it, expect } from '@jest/globals'; | ||
it('should create an ESM stub for CommonJS string export', async () => { | ||
expect(await createESMStub(path.join(testScenariosPath, 'string-export.cjs'), stubPath)).toMatchInlineSnapshot(`"export default packageExport;"`); | ||
expect(await createESMStub(path.join(testScenariosPath, 'string-export.cjs'), stubPath)).toMatchInlineSnapshot(`"export default "I am a string with \\"double quotes\\" and 'single quotes'";"`); | ||
}); | ||
@@ -212,3 +212,6 @@ // it("should throw when the code can't be parsed", async () => { | ||
}); | ||
it('can generate a stub from something that returns a boolean', async () => { | ||
expect(await createESMStub(path.join(testScenariosPath, 'boolean-return.cjs'), stubPath)).toMatchInlineSnapshot(`"export default true;"`); | ||
}); | ||
}); | ||
//# sourceMappingURL=createESMStub.test.js.map |
@@ -8,5 +8,5 @@ // This file is read by tools that parse documentation comments conforming to the TSDoc standard. | ||
"packageName": "@microsoft/api-extractor", | ||
"packageVersion": "7.30.0" | ||
"packageVersion": "7.31.1" | ||
} | ||
] | ||
} |
{ | ||
"name": "@ms-cloudpack/esm-stub-utilities", | ||
"version": "0.2.4", | ||
"version": "0.3.0", | ||
"description": "Generates ESM stubs for CommonJS entry files.", | ||
@@ -16,3 +16,3 @@ "license": "MIT", | ||
"dependencies": { | ||
"@ms-cloudpack/path-utilities": "^0.4.0", | ||
"@ms-cloudpack/path-utilities": "^0.5.0", | ||
"atob": "^2.1.2", | ||
@@ -19,0 +19,0 @@ "btoa": "^1.2.1", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
38966
701
+ Added@ms-cloudpack/path-utilities@0.5.0(transitive)
- Removed@ms-cloudpack/path-utilities@0.4.0(transitive)