Last active
June 5, 2020 13:49
-
-
Save renoirb/f09dcfc6556894a13383e0551181a21b to your computer and use it in GitHub Desktop.
Attempt at using an ESM/MJS in TypeScript
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
From dd22508d45c9a839d26a090bba05e62abe41e492 Mon Sep 17 00:00:00 2001 | |
From: Renoir Boulanger <contribs@renoirboulanger.com> | |
Date: Thu, 4 Jun 2020 10:25:15 -0400 | |
Subject: [PATCH] Just-a-Demo | |
--- | |
.gitignore | 2 ++ | |
package.json | 39 +++++++++++++++++++++++++++++++++++++++ | |
src/index.ts | 25 +++++++++++++++++++++++++ | |
tsconfig.json | 14 ++++++++++++++ | |
4 files changed, 80 insertions(+) | |
create mode 100644 .gitignore | |
create mode 100644 package.json | |
create mode 100644 src/index.ts | |
create mode 100644 tsconfig.json | |
diff --git a/.gitignore b/.gitignore | |
new file mode 100644 | |
index 0000000..1eae0cf | |
--- /dev/null | |
+++ b/.gitignore | |
@@ -0,0 +1,2 @@ | |
+dist/ | |
+node_modules/ | |
diff --git a/package.json b/package.json | |
new file mode 100644 | |
index 0000000..7f2f085 | |
--- /dev/null | |
+++ b/package.json | |
@@ -0,0 +1,39 @@ | |
+{ | |
+ "name": "monorepos-renoirb-particles--datasource", | |
+ "version": "1.0.0", | |
+ "description": "", | |
+ "keywords": [], | |
+ "license": "MIT", | |
+ "author": "Renoir Boulanger <contribs@renoirboulanger.com> (https://renoirb.com/)", | |
+ "main": "dist/index.js", | |
+ "type": "module", | |
+ "scripts": { | |
+ "build": "tsc --build", | |
+ "test": "", | |
+ "preinstall": "node -e \"if(process.env.npm_execpath.indexOf('npm') === -1) throw new Error('Dependencies must be installed with NPM')\"" | |
+ }, | |
+ "dependencies": { | |
+ "@babel/runtime-corejs3": "^7.8.0", | |
+ "@renoirb/data-source": "^0.2.8", | |
+ "@renoirb/jsonschema-aware-loader": "^0.2.2" | |
+ }, | |
+ "devDependencies": { | |
+ "@babel/core": "^7.10.0", | |
+ "@babel/preset-env": "^7.8.0", | |
+ "@microsoft/node-core-library": "^3.19.0", | |
+ "@renoirb/conventions-use-bili": "^1.0.2", | |
+ "@renoirb/conventions-use-jest": "^1.0.1", | |
+ "@renoirb/conventions-use-prettier": "^1.0.1", | |
+ "@renoirb/conventions-use-typescript-3": "^1.0.2", | |
+ "@renoirb/tools-bundling-helpers": "^1.0.2", | |
+ "@types/node": "^10.17.24", | |
+ "ts-node-dev": "^1.0.0-pre.44", | |
+ "core-js": "^3.6.0", | |
+ "tslib": "^2.0.0", | |
+ "typescript": "^3.9.5", | |
+ "url-template": "^2.0.8" | |
+ }, | |
+ "engines": { | |
+ "node": ">=14" | |
+ } | |
+} | |
diff --git a/src/index.ts b/src/index.ts | |
new file mode 100644 | |
index 0000000..a63234e | |
--- /dev/null | |
+++ b/src/index.ts | |
@@ -0,0 +1,25 @@ | |
+import { DataSource, Endpoint } from '@renoirb/data-source' | |
+ | |
+const originConfig = Object.freeze({ | |
+ hostname: 'secret.corp.example.org', | |
+ port: 8080, | |
+}) | |
+ | |
+const endpointPrivateServicePath = '/backend/UserNamespace/v2/profile' | |
+ | |
+const reInitializeDataSourceFixture = (opts: any) => { | |
+ const origin = new DataSource({ ...opts }) | |
+ const endpoint = new Endpoint('POST', endpointPrivateServicePath, { | |
+ // Make obvious what is the content-type for POST requests | |
+ 'Content-Type': 'application/json', | |
+ }) | |
+ origin.set('detail-user', endpoint) | |
+ | |
+ return origin | |
+} | |
+ | |
+export default (() => { | |
+ console.log('Yo'); | |
+ const f = reInitializeDataSourceFixture(originConfig); | |
+ console.log(f); | |
+})(); | |
diff --git a/tsconfig.json b/tsconfig.json | |
new file mode 100644 | |
index 0000000..b609995 | |
--- /dev/null | |
+++ b/tsconfig.json | |
@@ -0,0 +1,14 @@ | |
+{ | |
+ "extends": "./node_modules/@renoirb/conventions-use-typescript-3/includes/tsconfig.json", | |
+ "compilerOptions": { | |
+ "target": "es2017", | |
+ "module": "esnext", | |
+ "strict": true, | |
+ "esModuleInterop": true, | |
+ "forceConsistentCasingInFileNames": true, | |
+ "outDir": "dist", | |
+ "importHelpers": true, | |
+ "allowSyntheticDefaultImports": true | |
+ }, | |
+ "include": ["src"] | |
+} | |
-- | |
2.24.3 (Apple Git-128) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment