Skip to content

Commit d874a75

Browse files
authored
Set type: "module" for esm/ and test/ in all packages & update to mocha@9 (#567)
* feat: Add an esm/package.json to all with { "type": "module" } While the top-level package.json files include a "type": "commonjs" specification, the esm/ directories can (and ought) to either have their contents use the .mjs extension, or include their own package.json file with the correct "type". This adds the package.json while keeping the extensions as .js, as this is significantly easier for the TypeScript interop; proper .mjs support is currently an unresolved issue: microsoft/TypeScript#18442 * refactor: Use .js extension for all ES imports While extensionless imports are supported by TypeScript as well as the esm package, the extensions are required by Node.js when resolving imports. TypeScript's tsc is also completely fine with using .js extensions when referring to .ts files. * test(fluent-dom): Move elem() from index.js to util.js * test: Update to mocha@9, now using Node.js native import * chore: Patch ESLint configs to allow linting to succeed The consideration of test/ files as ES modules requires a few of them to use import.meta, which isn't supported by the default parser of eslint@6. So this is a minimal patch to get linting to continue working until ESLint itself is updated.
1 parent b741759 commit d874a75

File tree

80 files changed

+285
-226
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+285
-226
lines changed

common.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ TYPEDOC_CMD = $(TYPEDOC) src/index.?s \
3131

3232
MOCHA_CMD =@$(NYC) --reporter=text --reporter=html $(MOCHA) \
3333
--recursive --ui tdd \
34-
--require esm \
3534
$(MOCHA_EXTRA_ARGS) \
3635
test/**/*_test.js \
3736
$(NULL)

eslint_test.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"parser": "babel-eslint",
23
"parserOptions": {
34
"ecmaVersion": 9,
45
"sourceType": "module",

fluent-bundle/makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ compile: esm/.compiled
1313

1414
esm/.compiled: $(SOURCES)
1515
@$(TSC)
16+
@echo '{ "type": "module" }' > esm/package.json
1617
@touch $@
1718
@echo -e " $(OK) esm/ compiled"
1819

fluent-bundle/test/arguments_test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import assert from 'assert';
44
import ftl from "@fluent/dedent";
55

6-
import {FluentBundle} from '../esm/bundle';
7-
import {FluentResource} from '../esm/resource';
8-
import {FluentType, FluentNumber, FluentDateTime} from '../esm/types';
6+
import {FluentBundle} from '../esm/bundle.js';
7+
import {FluentResource} from '../esm/resource.js';
8+
import {FluentType, FluentNumber, FluentDateTime} from '../esm/types.js';
99

1010
suite('Variables', function() {
1111
let bundle, errs;

fluent-bundle/test/attributes_test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import assert from 'assert';
44
import ftl from "@fluent/dedent";
55

6-
import {FluentBundle} from '../esm/bundle';
7-
import {FluentResource} from '../esm/resource';
6+
import {FluentBundle} from '../esm/bundle.js';
7+
import {FluentResource} from '../esm/resource.js';
88

99
suite('Attributes', function() {
1010
let bundle, args, errs;

fluent-bundle/test/bomb_test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import assert from 'assert';
44
import ftl from "@fluent/dedent";
55

6-
import {FluentBundle} from '../esm/bundle';
7-
import {FluentResource} from '../esm/resource';
6+
import {FluentBundle} from '../esm/bundle.js';
7+
import {FluentResource} from '../esm/resource.js';
88

99
suite('Reference bombs', function() {
1010
let bundle, args, errs;

fluent-bundle/test/constructor_test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import assert from 'assert';
44
import sinon from 'sinon';
55
import ftl from "@fluent/dedent";
66

7-
import {FluentBundle} from '../esm/bundle';
8-
import {FluentResource} from '../esm/resource';
7+
import {FluentBundle} from '../esm/bundle.js';
8+
import {FluentResource} from '../esm/resource.js';
99

1010
suite('FluentBundle constructor', function() {
1111
setup(function() {

fluent-bundle/test/context_test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import assert from 'assert';
44
import ftl from "@fluent/dedent";
55

6-
import {FluentBundle} from '../esm/bundle';
7-
import {FluentResource} from '../esm/resource';
6+
import {FluentBundle} from '../esm/bundle.js';
7+
import {FluentResource} from '../esm/resource.js';
88

99
suite('Bundle', function() {
1010
let bundle;

fluent-bundle/test/errors_test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import assert from "assert";
44
import ftl from "@fluent/dedent";
55

6-
import {FluentBundle} from "../esm/bundle";
7-
import {FluentResource} from '../esm/resource';
6+
import {FluentBundle} from "../esm/bundle.js";
7+
import {FluentResource} from '../esm/resource.js';
88

99
suite("Errors", function() {
1010
let bundle;

fluent-bundle/test/functions_builtin_test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import assert from 'assert';
44
import ftl from "@fluent/dedent";
55

6-
import {FluentBundle} from '../esm/bundle';
7-
import {FluentResource} from '../esm/resource';
8-
import {FluentNumber, FluentDateTime} from '../esm/types';
6+
import {FluentBundle} from '../esm/bundle.js';
7+
import {FluentResource} from '../esm/resource.js';
8+
import {FluentNumber, FluentDateTime} from '../esm/types.js';
99

1010
suite('Built-in functions', function() {
1111
let bundle, errors, msg;

0 commit comments

Comments
 (0)