@ms-cloudpack/esm-stub-utilities
Advanced tools
Comparing version 0.3.3 to 0.3.4
@@ -5,6 +5,36 @@ { | ||
{ | ||
"date": "Tue, 18 Oct 2022 08:15:52 GMT", | ||
"date": "Wed, 02 Nov 2022 08:10:59 GMT", | ||
"tag": "@ms-cloudpack/esm-stub-utilities_v0.3.4", | ||
"version": "0.3.4", | ||
"comments": { | ||
"patch": [ | ||
{ | ||
"author": "dzearing@microsoft.com", | ||
"package": "@ms-cloudpack/esm-stub-utilities", | ||
"commit": "3439c51ff4eb7cb624cf84fb2881a781eabca83f", | ||
"comment": "README updates." | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"date": "Tue, 01 Nov 2022 08:11:03 GMT", | ||
"tag": "@ms-cloudpack/esm-stub-utilities_v0.3.3", | ||
"version": "0.3.3", | ||
"comments": { | ||
"none": [ | ||
{ | ||
"author": "dzearing@microsoft.com", | ||
"package": "@ms-cloudpack/esm-stub-utilities", | ||
"commit": "264fdebf12d3c964f2520feef232af76425cdc4c", | ||
"comment": "Updating readme notes." | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"date": "Tue, 18 Oct 2022 08:16:24 GMT", | ||
"tag": "@ms-cloudpack/esm-stub-utilities_v0.3.3", | ||
"version": "0.3.3", | ||
"comments": { | ||
"patch": [ | ||
@@ -11,0 +41,0 @@ { |
# Change Log - @ms-cloudpack/esm-stub-utilities | ||
This log was last generated on Tue, 18 Oct 2022 08:15:52 GMT and should not be manually modified. | ||
This log was last generated on Wed, 02 Nov 2022 08:10:59 GMT and should not be manually modified. | ||
<!-- Start content --> | ||
## 0.3.4 | ||
Wed, 02 Nov 2022 08:10:59 GMT | ||
### Patches | ||
- README updates. (dzearing@microsoft.com) | ||
## 0.3.3 | ||
Tue, 18 Oct 2022 08:15:52 GMT | ||
Tue, 18 Oct 2022 08:16:24 GMT | ||
@@ -11,0 +19,0 @@ ### Patches |
@@ -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.33.1" | ||
"packageVersion": "7.33.5" | ||
} | ||
] | ||
} |
{ | ||
"name": "@ms-cloudpack/esm-stub-utilities", | ||
"version": "0.3.3", | ||
"version": "0.3.4", | ||
"description": "Generates ESM stubs for CommonJS entry files.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -7,3 +7,3 @@ # @ms-cloudpack/esm-stub-utilities | ||
Generate a stub given a JavaScript entry path: | ||
Call `createESMStub` to generate a stub for the cjs entry: | ||
@@ -13,10 +13,21 @@ ```js | ||
const esmStub = await createESMStub('/path/to/entry.js', '/path/to/stub.js'); | ||
const esmStub = await createESMStub('/path/to/cjs/entry.js', '/path/to/esm/stub.js'); | ||
``` | ||
This return an esm stub string, based on loading the package in node and parsing exported keys. Example output: | ||
This call returns an esm stub string, but does not write the file. The path in the second argument is needed to derive import paths. | ||
Example cjs file `entry.js`: | ||
```js | ||
import content from '/path/to/entry.js'; | ||
module.exports = { | ||
named1: 'named1', | ||
named2: 'named2', | ||
}; | ||
``` | ||
Example output (`stub.js`): | ||
```js | ||
import content from '../cjs/entry.js'; | ||
export { | ||
@@ -29,3 +40,4 @@ default: content, | ||
Writes the path to the stub to a file: | ||
To write the file in the same call, the `writeESMStub` helper does this (which writes the stub to the node_modules/.cache folder in | ||
the package): | ||
@@ -35,3 +47,3 @@ ```js | ||
await writeESMStub('./path/to/entry.js', './path/to/stub.js'); | ||
const stubPath = await writeESMStub('./path/to/entry.js'); | ||
``` | ||
@@ -38,0 +50,0 @@ |
42846
793
58