From 6b0d88754831d63fea899c5bb37fe64ef033add9 Mon Sep 17 00:00:00 2001 From: Jonathan Poelman Date: Thu, 31 Mar 2022 16:09:58 +0200 Subject: [PATCH 1/3] initial version of template with es-module support --- babel.config.json | 3 ++- helpers/mu/index.js | 30 +++++++++++++++--------------- package.json | 1 + 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/babel.config.json b/babel.config.json index b163059..11d44d1 100644 --- a/babel.config.json +++ b/babel.config.json @@ -4,7 +4,8 @@ { "targets": { "node": 14 - } + }, + "modules": false } ], ["@babel/preset-typescript" diff --git a/helpers/mu/index.js b/helpers/mu/index.js index 3f84979..aedf82f 100644 --- a/helpers/mu/index.js +++ b/helpers/mu/index.js @@ -1,6 +1,6 @@ -import { app, errorHandler } from './server'; -import sparql from './sparql'; -import { v1 as uuidV1 } from 'uuid'; +import { app, errorHandler } from "./server.js"; +import sparql from "./sparql.js"; +import { v1 as uuidV1 } from "uuid"; // generates a uuid const uuid = uuidV1; @@ -20,20 +20,20 @@ const mu = { sparqlEscapeDateTime: sparql.sparqlEscapeDateTime, sparqlEscapeBool: sparql.sparqlEscapeBool, uuid, - errorHandler + errorHandler, }; const SPARQL = mu.SPARQL, - query = mu.query, - update = mu.update, - sparqlEscape = mu.sparqlEscape, - sparqlEscapeString = mu.sparqlEscapeString, - sparqlEscapeUri = mu.sparqlEscapeUri, - sparqlEscapeInt = mu.sparqlEscapeInt, - sparqlEscapeFloat = mu.sparqlEscapeFloat, - sparqlEscapeDate = mu.sparqlEscapeDate, - sparqlEscapeDateTime = mu.sparqlEscapeDateTime, - sparqlEscapeBool = mu.sparqlEscapeBool; + query = mu.query, + update = mu.update, + sparqlEscape = mu.sparqlEscape, + sparqlEscapeString = mu.sparqlEscapeString, + sparqlEscapeUri = mu.sparqlEscapeUri, + sparqlEscapeInt = mu.sparqlEscapeInt, + sparqlEscapeFloat = mu.sparqlEscapeFloat, + sparqlEscapeDate = mu.sparqlEscapeDate, + sparqlEscapeDateTime = mu.sparqlEscapeDateTime, + sparqlEscapeBool = mu.sparqlEscapeBool; export { app, @@ -50,7 +50,7 @@ export { sparqlEscapeDateTime, sparqlEscapeBool, uuid, - errorHandler + errorHandler, }; export default mu; diff --git a/package.json b/package.json index 25fc50b..29931c3 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "mu-javascript-template", "version": "1.5.0-beta.4", "description": "Template for mu services written in JavaScript", + "type": "module", "repository": { "type": "git", "url": "git+https://github.com/mu-semtech/mu-javascript-template.git" From 0b5c687b489965e0d44c555e82b9919caf39adf2 Mon Sep 17 00:00:00 2001 From: Jonathan Poelman Date: Thu, 31 Mar 2022 16:19:44 +0200 Subject: [PATCH 2/3] replace commonJS by ES2020 --- tsconfig-base.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsconfig-base.json b/tsconfig-base.json index deda59a..5b2db41 100644 --- a/tsconfig-base.json +++ b/tsconfig-base.json @@ -4,7 +4,7 @@ "compilerOptions": { "lib": ["es2020"], - "module": "commonjs", + "module": "es2020", "target": "es2020", "allowJs": true, "noEmit": true, From c15060f20184bf97d02b4ccdf75b06878b1d0118 Mon Sep 17 00:00:00 2001 From: Jonathan Poelman Date: Thu, 7 Apr 2022 08:54:20 +0200 Subject: [PATCH 3/3] undo formatting by prettier --- helpers/mu/index.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/helpers/mu/index.js b/helpers/mu/index.js index aedf82f..eb041b5 100644 --- a/helpers/mu/index.js +++ b/helpers/mu/index.js @@ -24,16 +24,16 @@ const mu = { }; const SPARQL = mu.SPARQL, - query = mu.query, - update = mu.update, - sparqlEscape = mu.sparqlEscape, - sparqlEscapeString = mu.sparqlEscapeString, - sparqlEscapeUri = mu.sparqlEscapeUri, - sparqlEscapeInt = mu.sparqlEscapeInt, - sparqlEscapeFloat = mu.sparqlEscapeFloat, - sparqlEscapeDate = mu.sparqlEscapeDate, - sparqlEscapeDateTime = mu.sparqlEscapeDateTime, - sparqlEscapeBool = mu.sparqlEscapeBool; + query = mu.query, + update = mu.update, + sparqlEscape = mu.sparqlEscape, + sparqlEscapeString = mu.sparqlEscapeString, + sparqlEscapeUri = mu.sparqlEscapeUri, + sparqlEscapeInt = mu.sparqlEscapeInt, + sparqlEscapeFloat = mu.sparqlEscapeFloat, + sparqlEscapeDate = mu.sparqlEscapeDate, + sparqlEscapeDateTime = mu.sparqlEscapeDateTime, + sparqlEscapeBool = mu.sparqlEscapeBool; export { app, @@ -50,7 +50,7 @@ export { sparqlEscapeDateTime, sparqlEscapeBool, uuid, - errorHandler, + errorHandler }; export default mu;