Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix node imports #17

Merged
merged 13 commits into from
Oct 1, 2021
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.github
e2e
jest.config.js
jest.e2e.config.js
Expand Down
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,7 @@ module.exports = {
},
},
},
parserOptions: {
project: "./**/tsconfig*.json",
},
};
9,257 changes: 0 additions & 9,257 deletions .github/workflows/cd-packaging-tests/bundler-parcel/package-lock.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"name": "cd-packaging-test-parcel",
"private": true
"private": true,
"dependencies": {
"@inrupt/solid-client-authn-browser": "^1.11.2"
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
{
"name": "cd-packaging-test-webpack",
"private": true
"private": true,
"dependencies": {
"@inrupt/solid-client-authn-browser": "^1.11.2",
"@inrupt/solid-client-consent": "file:../../../..",
"assert": "^2.0.0",
"browserify-zlib": "^0.2.0",
"buffer": "^6.0.3",
"crypto-browserify": "^3.12.0",
"os-browserify": "^0.3.0",
"stream-browserify": "^3.0.0",
"webpack": "^5.31.0",
"webpack-cli": "^4.6.0"
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Verify that imports from the main export work:
import { requestAccess as mainModuleFn } from "@inrupt/solid-client-consent";
// Verify that submodule imports work:
import { requestAccess } from "@inrupt/solid-client-consent/consent";
import { requestAccess } from "@inrupt/solid-client-consent/request";

console.log(typeof mainModuleFn);
console.log(typeof requestAccess);
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// It should be possible to delete this file once solid-client-authn-browser has switched to jose@3:
module.exports = {
resolve: {
fallback: {
crypto: require.resolve("crypto-browserify"),
stream: require.resolve("stream-browserify"),
util: require.resolve("util/"),
buffer: require.resolve("buffer/"),
os: require.resolve("os-browserify/browser"),
assert: require.resolve("assert/"),
zlib: require.resolve("browserify-zlib"),
},
},
};
2 changes: 1 addition & 1 deletion .github/workflows/cd-packaging-tests/node/esmodule.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Verify that imports from the main export work:
import { requestAccess as mainModuleFn } from "@inrupt/solid-client-consent";
// Verify that submodule imports work:
import { requestAccess } from "@inrupt/solid-client-consent/consent";
import { requestAccess } from "@inrupt/solid-client-consent/request";

console.log(typeof mainModuleFn);
console.log(typeof requestAccess);
12 changes: 0 additions & 12 deletions .github/workflows/cd-packaging-tests/node/package-lock.json

This file was deleted.

3 changes: 2 additions & 1 deletion .github/workflows/cd-packaging-tests/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "cd-packaging-test-node",
"private": true,
"dependencies": {
"@inrupt/solid-client-consent": "*"
"@inrupt/solid-client-consent": "*",
"@inrupt/solid-client": "^1.13.0"
}
}
6 changes: 3 additions & 3 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ jobs:
node-version: ${{ matrix.node-version }}
registry-url: 'https://registry.npmjs.org'
- name: Install the preview release of solid-client-consent in the packaging test project
if: github.actor != 'dependabot[bot]' && false
if: github.actor != 'dependabot[bot]'
run: |
cd .github/workflows/cd-packaging-tests/node
npm install @inrupt/solid-client @inrupt/solid-client-consent@$VERSION_NR
Expand All @@ -173,7 +173,7 @@ jobs:
node-version: '14.x'
registry-url: 'https://registry.npmjs.org'
- name: Verify that the package can be imported in a Parcel project
if: github.actor != 'dependabot[bot]' && false
if: github.actor != 'dependabot[bot]'
run: |
cd .github/workflows/cd-packaging-tests/bundler-parcel
npm install
Expand All @@ -200,7 +200,7 @@ jobs:
node-version: '14.x'
registry-url: 'https://registry.npmjs.org'
- name: Verify that the package can be imported in a Webpack project
if: github.actor != 'dependabot[bot]' && false
if: github.actor != 'dependabot[bot]'
run: |
cd .github/workflows/cd-packaging-tests/bundler-webpack
npm install @inrupt/solid-client @inrupt/solid-client-consent@$VERSION_NR
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ docs/dist/
docs/.DS_Store
.env*.local
.cache
.github/**/package-lock.json
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@
"./request": "./dist/request/index.mjs",
"./verify": "./dist/verify/index.mjs"
},
"typesVersions": {
"*": {
"discover": ["dist/discover/index.d.ts"],
"manage": ["dist/manage/index.d.ts"],
"request": ["dist/request/index.d.ts"],
"verify": ["dist/verify/index.d.ts"]
}
},
"files": [
"dist",
"src",
Expand Down
99 changes: 69 additions & 30 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,40 +22,79 @@
import pkg from "./package.json";
import typescript from "rollup-plugin-typescript2";

export default {
input: "./src/index.ts",
output: [
{
file: pkg.main,
format: "cjs",
},
{
file: pkg.module,
entryFileNames: "[name].es.js",
format: "esm",
const external = [
...Object.keys(pkg.dependencies || {}),
"@inrupt/solid-client-authn-browser",
];

const plugins = [
typescript({
// Use our own version of TypeScript, rather than the one bundled with the plugin:
typescript: require("typescript"),
tsconfigOverride: {
compilerOptions: {
module: "esnext",
},
},
{
}),
];

const rollupDefaultConfig = { external, plugins };

export default [
{
input: "./src/index.ts",
output: [
{
file: pkg.main,
format: "cjs",
},
{
file: pkg.module,
entryFileNames: "[name].es.js",
format: "esm",
},
{
dir: "umd",
format: "umd",
name: "SolidConsent",
},
],
...rollupDefaultConfig,
},
{
input: [
"./src/index.ts",
"./src/discover/index.ts",
"./src/manage/index.ts",
"./src/request/index.ts",
"./src/verify/index.ts",
],
output: {
dir: "dist",
entryFileNames: "[name].mjs",
format: "esm",
preserveModules: true,
},
{
dir: "umd",
format: "umd",
name: "SolidConsent",
...rollupDefaultConfig,
},
{
input: [
"./src/type/AccessVerifiableCredential.ts",
"./src/type/ConsentApiBaseOptions.ts",
"./src/type/ConsentContext.ts",
"./src/type/ConsentStatus.ts",
"./src/type/Parameter.ts",
"./src/type/RequestAccessParameters.ts",
"./src/type/RequestAccessWithConsentParameters.ts",
"./src/type/ResourceAccessMode.ts",
],
output: {
dir: "dist",
entryFileNames: "[name].d.ts",
format: "esm",
preserveModules: true,
},
],
plugins: [
typescript({
// Use our own version of TypeScript, rather than the one bundled with the plugin:
typescript: require("typescript"),
tsconfigOverride: {
compilerOptions: {
module: "esnext",
},
},
}),
],
external: [],
};
...rollupDefaultConfig,
},
];
12 changes: 6 additions & 6 deletions src/type/AccessVerifiableCredential.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
import type { UrlString } from "@inrupt/solid-client";
import type {
CONSENT_CONTEXT,
CONSENT_STATUS_DENIED,
CONSENT_STATUS_EXPLICITLY_GIVEN,
CONSENT_STATUS_REQUESTED,
GC_CONSENT_STATUS_DENIED,
GC_CONSENT_STATUS_EXPLICITLY_GIVEN,
GC_CONSENT_STATUS_REQUESTED,
CREDENTIAL_TYPE,
} from "../constants";
import type { ResourceAccessMode } from "./ResourceAccessMode";
Expand Down Expand Up @@ -57,7 +57,7 @@ export type BaseConsentBody = BaseAccessBody & {
export type AccessRequestBody = BaseAccessBody & {
credentialSubject: {
hasConsent: {
hasStatus: typeof CONSENT_STATUS_REQUESTED;
hasStatus: typeof GC_CONSENT_STATUS_REQUESTED;
};
};
};
Expand All @@ -67,7 +67,7 @@ export type ConsentRequestBody = AccessRequestBody & BaseConsentBody;
export type AccessDeniedBody = BaseAccessBody & {
credentialSubject: {
hasConsent: {
hasStatus: typeof CONSENT_STATUS_DENIED;
hasStatus: typeof GC_CONSENT_STATUS_DENIED;
};
};
};
Expand All @@ -77,7 +77,7 @@ export type ConsentDeniedBody = AccessRequestBody & BaseConsentBody;
export type AccessGrantBody = BaseAccessBody & {
credentialSubject: {
hasConsent: {
hasStatus: typeof CONSENT_STATUS_EXPLICITLY_GIVEN;
hasStatus: typeof GC_CONSENT_STATUS_EXPLICITLY_GIVEN;
isProvidedTo: UrlString;
};
};
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": ".", /* Redirect output structure to the directory. */
"outDir": "dist", /* Redirect output structure to the directory. */
"rootDir": "src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "removeComments": true, /* Do not emit comments to output. */
Expand Down Expand Up @@ -104,7 +104,7 @@
"readme": "none",
"entryDocument": "index.md",
},
"include": ["src/**/*.ts", ".eslintrc.js"],
"include": [ "src/index.ts", ".eslintrc.js" ],
"exclude": [
"**/node_modules",
// These end-to-end tests reference code in `.codesandbox`,
Expand Down
6 changes: 6 additions & 0 deletions tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "./tsconfig.json",
"include": [
"src/**/*.test.ts"
]
}