-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from commercelayer/move-to-esm
Move to Pure ESM. It still bundle to `cjs` and `esm`.
- Loading branch information
Showing
29 changed files
with
587 additions
and
1,331 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const { core } = require('@commercelayer/js-auth') | ||
|
||
async function run() { | ||
const auth = await core.authentication('client_credentials', { | ||
clientId: 'BISG8bb3GWpC8_D7Nt1SuWWdieS5bJq831A50LgB_Ig', | ||
slug: 'demo-store', | ||
scope: 'market:11279' | ||
}) | ||
|
||
console.log(auth) | ||
} | ||
|
||
run() |
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,12 @@ | ||
{ | ||
"private": true, | ||
"name": "cjs", | ||
"type": "commonjs", | ||
"main": "index.js", | ||
"scripts": { | ||
"start": "node index.js" | ||
}, | ||
"dependencies": { | ||
"@commercelayer/js-auth": "workspace:^5.0.0" | ||
} | ||
} |
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,16 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head></head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="importmap"> | ||
{ | ||
"imports": { | ||
"@commercelayer/js-auth": "./node_modules/@commercelayer/js-auth/dist/index.js" | ||
} | ||
} | ||
</script> | ||
<script type="module" src="./index.js"></script> | ||
Open the developer console with <code>Cmd + Option + J</code> (on a Mac) or <code>Ctrl + Shift + J</code> (on Windows) and check the log. You may need to refresh the page. | ||
</body> | ||
</html> |
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,13 @@ | ||
import { core } from '@commercelayer/js-auth' | ||
|
||
async function run() { | ||
const auth = await core.authentication('client_credentials', { | ||
clientId: 'BISG8bb3GWpC8_D7Nt1SuWWdieS5bJq831A50LgB_Ig', | ||
slug: 'demo-store', | ||
scope: 'market:11279' | ||
}) | ||
|
||
console.log(auth) | ||
} | ||
|
||
run() |
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,13 @@ | ||
{ | ||
"private": true, | ||
"name": "esm", | ||
"type": "module", | ||
"main": "index.js", | ||
"scripts": { | ||
"start": "node index.js", | ||
"serve": "npx serve" | ||
}, | ||
"dependencies": { | ||
"@commercelayer/js-auth": "workspace:^5.0.0" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** @type {import('eslint').Linter.Config} */ | ||
module.exports = { | ||
extends: ['@commercelayer/eslint-config-ts'], | ||
parserOptions: { | ||
project: 'tsconfig.json', | ||
tsconfigRootDir: __dirname, | ||
sourceType: 'module' | ||
} | ||
} |
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 |
---|---|---|
|
@@ -9,13 +9,16 @@ | |
"name": "Alessandro Casazza", | ||
"email": "[email protected]" | ||
}, | ||
"main": "lib/cjs/index.js", | ||
"module": "lib/esm/index.js", | ||
"types": "lib/esm/index.d.ts", | ||
"type": "module", | ||
"exports": { | ||
".": { | ||
"import": "./dist/index.js", | ||
"require": "./dist/index.cjs" | ||
} | ||
}, | ||
"main": "./dist/index.js", | ||
"files": [ | ||
"lib", | ||
"package.json", | ||
"README.md" | ||
"dist" | ||
], | ||
"keywords": [ | ||
"jamstack", | ||
|
@@ -32,32 +35,18 @@ | |
"lint": "eslint src --ext .ts,.tsx", | ||
"lint:fix": "eslint src --ext .ts,.tsx --fix", | ||
"test": "pnpm run lint && vitest run --silent", | ||
"coverage": "vitest run --coverage", | ||
"test:e2e": "NODE_ENV=test playwright test", | ||
"test:e2e:coverage": "nyc pnpm test:e2e && pnpm coverage:report", | ||
"coverage:report": "nyc report --reporter=html", | ||
"build": "tsc -b tsconfig.prod.json tsconfig.prod.esm.json --verbose && pnpm postbuild", | ||
"build:dev": "tsc -b tsconfig.prod.json tsconfig.prod.esm.json --verbose && tsc-alias -p tsconfig.prod.json && tsc-alias -p tsconfig.prod.esm.json", | ||
"postbuild": "tsc-alias -p tsconfig.prod.json && tsc-alias -p tsconfig.prod.esm.json && minimize-js lib -w -s" | ||
"build": "tsup" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"license": "MIT", | ||
"dependencies": { | ||
"tslib": "^2.6.2" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^20.11.16", | ||
"@vitejs/plugin-react": "^4.2.1", | ||
"@vitest/coverage-c8": "^0.33.0", | ||
"jsdom": "^24.0.0", | ||
"minimize-js": "^1.4.0", | ||
"tsc-alias": "^1.8.8", | ||
"typescript": "^5.3.3", | ||
"vite": "^5.1.0", | ||
"vite-tsconfig-paths": "^4.3.1", | ||
"vitest": "^1.2.2" | ||
"@types/node": "^20.11.27", | ||
"tsup": "^8.0.2", | ||
"typescript": "^5.4.2", | ||
"vite-tsconfig-paths": "^4.3.2", | ||
"vitest": "^1.3.1" | ||
}, | ||
"engines": { | ||
"node": ">=18.0.0" | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,8 @@ | ||
export { core } from './core' | ||
export { provisioning } from './provisioning' | ||
export { core } from './core.js' | ||
export { provisioning } from './provisioning.js' | ||
|
||
export type * from './types/index.js' | ||
export type * from './types/authorizationCode.js' | ||
export type * from './types/clientCredentials.js' | ||
export type * from './types/password.js' | ||
export type * from './types/refreshToken.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
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
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
Oops, something went wrong.