You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@annotator.apache.org by ra...@apache.org on 2020/08/05 05:23:33 UTC

[incubator-annotator] branch master updated (21cb6da -> a2806d4)

This is an automated email from the ASF dual-hosted git repository.

randall pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-annotator.git.


    from 21cb6da  Remove superfluous .js extension support in nyc
     new 710e235  Add type qualifier to type-only imports
     new acf90a5  Add extensions to import and require statements in build
     new bca65b9  Export all types from @annotator/selector
     new a2806d4  Use a unified output directory with .js or .mjs extensions

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .eslintignore                              |  1 -
 .gitignore                                 |  1 -
 babel.config.js                            | 28 ++++++++++++++++++++++++----
 package.json                               |  9 +++++----
 packages/dom/package.json                  |  5 ++---
 packages/dom/src/range/match.ts            |  2 +-
 packages/dom/src/scope.ts                  |  2 +-
 packages/dom/src/text-quote/describe.ts    |  2 +-
 packages/dom/src/text-quote/match.ts       |  2 +-
 packages/dom/test/text-quote/match.test.ts |  2 +-
 packages/selector/package.json             |  5 ++---
 packages/selector/src/index.ts             |  5 +++--
 yarn.lock                                  | 12 ++++++++++++
 13 files changed, 53 insertions(+), 23 deletions(-)


[incubator-annotator] 04/04: Use a unified output directory with .js or .mjs extensions

Posted by ra...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

randall pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-annotator.git

commit a2806d438d7c79d615badec1b531e896768adb65
Author: Randall Leeds <ra...@apache.org>
AuthorDate: Tue Aug 4 22:22:03 2020 -0700

    Use a unified output directory with .js or .mjs extensions
---
 .eslintignore                  | 1 -
 .gitignore                     | 1 -
 babel.config.js                | 2 +-
 package.json                   | 8 ++++----
 packages/dom/package.json      | 5 ++---
 packages/selector/package.json | 5 ++---
 6 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/.eslintignore b/.eslintignore
index 61cf845..ba489a4 100644
--- a/.eslintignore
+++ b/.eslintignore
@@ -3,6 +3,5 @@
 !/packages/*/src/types
 **/*.d.ts
 /coverage
-/packages/*/esm
 /packages/*/lib
 /web/dist
diff --git a/.gitignore b/.gitignore
index 856c6a8..807d102 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,6 +6,5 @@ node_modules
 tsconfig.tsbuildinfo
 /packages/*/LICENSE
 /packages/*/NOTICE
-/packages/*/esm
 /packages/*/lib
 /web/dist
diff --git a/babel.config.js b/babel.config.js
index 265fdcc..1dddf6a 100644
--- a/babel.config.js
+++ b/babel.config.js
@@ -44,7 +44,7 @@ module.exports = (api) => {
   };
 
   const addImportExtensionOptions = {
-    extension: DEV || TEST ? 'ts' : 'js',
+    extension: DEV || TEST ? 'ts' : CJS ? 'js' : 'mjs',
   };
 
   // Options for the module-resolver plugin.
diff --git a/package.json b/package.json
index 913aa56..d97f19c 100644
--- a/package.json
+++ b/package.json
@@ -16,12 +16,12 @@
   },
   "scripts": {
     "build": "yarn run build:cjs && yarn run build:esm && yarn run build:misc && yarn run build:types",
-    "build:babel": "lerna exec --parallel -- babel --extensions '.js,.ts' --root-mode upward",
-    "build:cjs": "cross-env BABEL_ENV=cjs yarn build:babel -d lib src",
-    "build:esm": "cross-env BABEL_ENV=esm yarn build:babel -d esm src",
+    "build:babel": "lerna exec --parallel -- babel -d lib -s inline -x .ts --root-mode upward src",
+    "build:cjs": "cross-env BABEL_ENV=cjs yarn build:babel",
+    "build:esm": "cross-env BABEL_ENV=esm yarn build:babel --out-file-extension .mjs",
     "build:misc": "lerna exec -- cp ../../LICENSE ../../NOTICE .",
     "build:types": "tsc --build",
-    "clean": "tsc --build --clean && lerna exec -- rimraf LICENSE NOTICE esm lib",
+    "clean": "tsc --build --clean && lerna exec -- rimraf LICENSE NOTICE lib",
     "lint": "tsc --build && eslint .",
     "prepare": "yarn run build:types && lerna run prepare",
     "prepublishOnly": "yarn run build",
diff --git a/packages/dom/package.json b/packages/dom/package.json
index 498460a..6181f69 100644
--- a/packages/dom/package.json
+++ b/packages/dom/package.json
@@ -9,13 +9,12 @@
   },
   "license": "Apache-2.0",
   "author": "Apache Software Foundation",
-  "type": "module",
   "exports": {
-    "import": "./esm/index.js",
+    "import": "./lib/index.mjs",
     "require": "./lib/index.js"
   },
   "main": "./lib/index.js",
-  "module": "./esm/index.js",
+  "module": "./lib/index.mjs",
   "types": "./src/types.d.ts",
   "dependencies": {
     "@babel/runtime-corejs3": "^7.8.7",
diff --git a/packages/selector/package.json b/packages/selector/package.json
index 80902cd..809d949 100644
--- a/packages/selector/package.json
+++ b/packages/selector/package.json
@@ -9,13 +9,12 @@
   },
   "license": "Apache-2.0",
   "author": "Apache Software Foundation",
-  "type": "module",
   "exports": {
-    "import": "./esm/index.js",
+    "import": "./lib/index.mjs",
     "require": "./lib/index.js"
   },
   "main": "./lib/index.js",
-  "module": "./esm/index.js",
+  "module": "./lib/index.mjs",
   "types": "./src/index.d.ts",
   "dependencies": {
     "@babel/runtime-corejs3": "^7.8.7",


[incubator-annotator] 01/04: Add type qualifier to type-only imports

Posted by ra...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

randall pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-annotator.git

commit 710e23540f73f1d2e83664ad1a78772a6b62c082
Author: Randall Leeds <ra...@apache.org>
AuthorDate: Tue Aug 4 22:07:36 2020 -0700

    Add type qualifier to type-only imports
---
 packages/dom/src/range/match.ts            | 2 +-
 packages/dom/src/scope.ts                  | 2 +-
 packages/dom/src/text-quote/describe.ts    | 2 +-
 packages/dom/src/text-quote/match.ts       | 2 +-
 packages/dom/test/text-quote/match.test.ts | 2 +-
 packages/selector/src/index.ts             | 4 ++--
 6 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/packages/dom/src/range/match.ts b/packages/dom/src/range/match.ts
index cf6d92a..df87db7 100644
--- a/packages/dom/src/range/match.ts
+++ b/packages/dom/src/range/match.ts
@@ -21,7 +21,7 @@
 import type { RangeSelector, Selector } from '@annotator/selector';
 
 import { ownerDocument } from '../scope';
-import { DomMatcher, DomScope } from '../types';
+import type { DomMatcher, DomScope } from '../types';
 
 import { product } from './cartesian';
 
diff --git a/packages/dom/src/scope.ts b/packages/dom/src/scope.ts
index 816bb03..e107212 100644
--- a/packages/dom/src/scope.ts
+++ b/packages/dom/src/scope.ts
@@ -18,7 +18,7 @@
  * under the License.
  */
 
-import { DomScope } from './types';
+import type { DomScope } from './types';
 
 export function ownerDocument(scope: DomScope): Document {
   const node = isRange(scope) ? scope.commonAncestorContainer : scope;
diff --git a/packages/dom/src/text-quote/describe.ts b/packages/dom/src/text-quote/describe.ts
index 9e690f9..b048914 100644
--- a/packages/dom/src/text-quote/describe.ts
+++ b/packages/dom/src/text-quote/describe.ts
@@ -21,7 +21,7 @@
 import seek from 'dom-seek';
 import type { TextQuoteSelector } from '@annotator/selector';
 
-import { DomScope } from '../types';
+import type { DomScope } from '../types';
 import { ownerDocument, rangeFromScope } from '../scope';
 
 export async function describeTextQuote(
diff --git a/packages/dom/src/text-quote/match.ts b/packages/dom/src/text-quote/match.ts
index e1035b9..a78d057 100644
--- a/packages/dom/src/text-quote/match.ts
+++ b/packages/dom/src/text-quote/match.ts
@@ -21,7 +21,7 @@
 import type { TextQuoteSelector } from '@annotator/selector';
 import seek from 'dom-seek';
 
-import { DomScope, DomMatcher } from '../types';
+import type { DomScope, DomMatcher } from '../types';
 import { ownerDocument, rangeFromScope } from '../scope';
 
 export function createTextQuoteSelectorMatcher(
diff --git a/packages/dom/test/text-quote/match.test.ts b/packages/dom/test/text-quote/match.test.ts
index f892132..78b1239 100644
--- a/packages/dom/test/text-quote/match.test.ts
+++ b/packages/dom/test/text-quote/match.test.ts
@@ -22,7 +22,7 @@ import { assert } from 'chai';
 import type { TextQuoteSelector } from '@annotator/selector';
 
 import { createTextQuoteSelectorMatcher } from '../../src/text-quote/match';
-import { DomScope } from '../../src/types';
+import type { DomScope } from '../../src/types';
 import { evaluateXPath, RangeInfo } from '../utils';
 
 import { testCases } from './match-cases';
diff --git a/packages/selector/src/index.ts b/packages/selector/src/index.ts
index b0bf9af..35d004e 100644
--- a/packages/selector/src/index.ts
+++ b/packages/selector/src/index.ts
@@ -18,9 +18,9 @@
  * under the License.
  */
 
-import { Selector, Matcher } from './types';
+import type { Selector, Matcher } from './types';
 
-export * from './types';
+export type { Selector, Matcher };
 
 export function makeRefinable<
   // Any subtype of Selector can be made refinable; but note we limit the value


[incubator-annotator] 02/04: Add extensions to import and require statements in build

Posted by ra...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

randall pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-annotator.git

commit acf90a5a77977128367e3330261b6129642b1e83
Author: Randall Leeds <ra...@apache.org>
AuthorDate: Tue Aug 4 22:09:43 2020 -0700

    Add extensions to import and require statements in build
---
 babel.config.js | 28 ++++++++++++++++++++++++----
 package.json    |  1 +
 yarn.lock       | 12 ++++++++++++
 3 files changed, 37 insertions(+), 4 deletions(-)

diff --git a/babel.config.js b/babel.config.js
index 44324e7..265fdcc 100644
--- a/babel.config.js
+++ b/babel.config.js
@@ -43,11 +43,29 @@ module.exports = (api) => {
     onlyRemoveTypeImports: true,
   };
 
+  const addImportExtensionOptions = {
+    extension: DEV || TEST ? 'ts' : 'js',
+  };
+
   // Options for the module-resolver plugin.
   // Used for resolving source files during development.
-  let resolverOptions = {
+  const resolverOptions = {
     alias: {
-      '^@annotator/(.+)$': '@annotator/\\1/src/index.ts',
+      ...(DEV || TEST
+        ? {
+            '^@annotator/(.+)$': '@annotator/\\1/src/index.ts',
+          }
+        : null),
+      // TODO: Remove after babel/babel#8462 ships.
+      '^@babel/runtime-corejs3/core-js/(.+)$':
+        '@babel/runtime-corejs3/core-js/\\1.js',
+      '^@babel/runtime-corejs3/core-js-stable/(.+)$':
+        '@babel/runtime-corejs3/core-js-stable/\\1.js',
+      '^@babel/runtime-corejs3/helpers/(.+)$':
+        '@babel/runtime-corejs3/helpers/\\1.js',
+      '^@babel/runtime-corejs3/regenerator$':
+        '@babel/runtime-corejs3/regenerator/index.js',
+      extensions: ['.js', '.ts'],
     },
   };
 
@@ -56,14 +74,16 @@ module.exports = (api) => {
     // Use corejs version 3.
     corejs: { version: 3 },
     // Use helpers formatted for the target environment.
-    useESModules: !CJS && !TEST,
+    // TODO: Re-enable after babel/babel#8462 ships.
+    // useESModules: !CJS && !TEST,
   };
 
   return {
     plugins: [
       ['@babel/transform-runtime', runtimeOptions],
       ...(TEST ? ['istanbul'] : []),
-      ...(DEV ? [['module-resolver', resolverOptions]] : []),
+      ['add-import-extension', addImportExtensionOptions],
+      ['module-resolver', resolverOptions],
       'preserve-comment-header',
     ],
     presets: [
diff --git a/package.json b/package.json
index c5fb3e2..913aa56 100644
--- a/package.json
+++ b/package.json
@@ -46,6 +46,7 @@
     "@typescript-eslint/parser": "^3.7.0",
     "ajv": "^6.11.0",
     "babel-loader": "^8.0.5",
+    "babel-plugin-add-import-extension": "^1.4.1",
     "babel-plugin-istanbul": "^6.0.0",
     "babel-plugin-module-resolver": "^4.0.0",
     "babel-plugin-preserve-comment-header": "^1.0.1",
diff --git a/yarn.lock b/yarn.lock
index 07bcebc..259c26b 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -192,6 +192,11 @@
   resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.10.1.tgz#ec5a5cf0eec925b66c60580328b122c01230a127"
   integrity sha512-fvoGeXt0bJc7VMWZGCAEBEMo/HAjW2mP8apF5eXK0wSqwLAVHAISCWRoLMBMUs2kqeaG77jltVqu4Hn8Egl3nA==
 
+"@babel/helper-plugin-utils@^7.10.4":
+  version "7.10.4"
+  resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.10.4.tgz#2f75a831269d4f677de49986dff59927533cf375"
+  integrity sha512-O4KCvQA6lLiMU9l2eawBPMf1xPP8xPfB3iEQw150hOVTqj/rfXz0ThTb4HEzqQfs2Bmo5Ay8BzxfzVtBrr9dVg==
+
 "@babel/helper-regex@^7.10.1":
   version "7.10.1"
   resolved "https://registry.yarnpkg.com/@babel/helper-regex/-/helper-regex-7.10.1.tgz#021cf1a7ba99822f993222a001cc3fec83255b96"
@@ -2424,6 +2429,13 @@ babel-loader@^8.0.5:
     mkdirp "^0.5.1"
     pify "^4.0.1"
 
+babel-plugin-add-import-extension@^1.4.1:
+  version "1.4.1"
+  resolved "https://registry.yarnpkg.com/babel-plugin-add-import-extension/-/babel-plugin-add-import-extension-1.4.1.tgz#d31b919ecbbd052aa3df210eca0b9f0153df770b"
+  integrity sha512-owxjRte+y2QB0YPCv3hWFNLF3Y1S7eEEZCCGo48TzRPM6zEzYsvxtOyx1h95Ghw1gEcl1UnOFIs5CY3Kd4OLYg==
+  dependencies:
+    "@babel/helper-plugin-utils" "^7.10.4"
+
 babel-plugin-dynamic-import-node@^2.3.3:
   version "2.3.3"
   resolved "https://registry.yarnpkg.com/babel-plugin-dynamic-import-node/-/babel-plugin-dynamic-import-node-2.3.3.tgz#84fda19c976ec5c6defef57f9427b3def66e17a3"


[incubator-annotator] 03/04: Export all types from @annotator/selector

Posted by ra...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

randall pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-annotator.git

commit bca65b945b747d190c173b26e1de1efa81e831a9
Author: Randall Leeds <ra...@apache.org>
AuthorDate: Tue Aug 4 22:12:09 2020 -0700

    Export all types from @annotator/selector
---
 packages/selector/src/index.ts | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/packages/selector/src/index.ts b/packages/selector/src/index.ts
index 35d004e..c66bd94 100644
--- a/packages/selector/src/index.ts
+++ b/packages/selector/src/index.ts
@@ -18,9 +18,10 @@
  * under the License.
  */
 
-import type { Selector, Matcher } from './types';
+import type { Matcher, Selector } from './types';
 
-export type { Selector, Matcher };
+export type { Matcher, Selector } from './types';
+export type { CssSelector, RangeSelector, TextQuoteSelector } from './types';
 
 export function makeRefinable<
   // Any subtype of Selector can be made refinable; but note we limit the value