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

All esm modules #386

Merged
merged 10 commits into from
Sep 28, 2024
Merged
  •  
  •  
  •  
3 changes: 1 addition & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"access": "public"
},
"license": "MIT",
"main": "dist/index.js",
"module": "dist/index.mjs",
"main": "dist/index.mjs",
"types": "dist/index.d.ts",
"type": "module",
"repository": {
Expand Down
27 changes: 7 additions & 20 deletions packages/core/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import terser from '@rollup/plugin-terser';
import typescript from '@rollup/plugin-typescript';
import pkg from './package.json' with { type: 'json'};
Expand All @@ -15,28 +13,17 @@ const config = [
sourcemap: true,
format: 'es',
name: pkg.name,
file: pkg.module,
},
{
sourcemap: true,
format: 'umd',
name: pkg.name,
file: pkg.main,
}
// Uncomment to generate commonjs, but did not manage to get this working ok
// {
// coiurcemap: true
// file: 'dist/index.cjs',
// format: 'cjs'
//
// }
],
plugins: [
// If you have external dependencies installed from
// npm, you'll most likely need these plugins. In
// some cases you'll need additional configuration -
// consult the documentation for details:
// https://github.com/rollup/plugins/tree/master/packages/commonjs

/* the param to resolve is added because of the note in
https://github.com/rollup/plugins/tree/master/packages/node-resolve/#readme
regarding "Resolving Built-Ins (like fs)"
*/
resolve({ preferBuiltins: false }),
commonjs(),
typescript(),

// If we're building for production (npm run build
Expand Down
10 changes: 5 additions & 5 deletions packages/core/src/__tests__/changes/Change.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { UndoModel } from "./change-model/UndoModel";
import { UndoUnit } from "./change-model/UndoUnit";
import { UndoPart } from "./change-model/UndoPart";
import { FreDelta, FreTransactionDelta, FreUndoManager } from "../../change-manager";
import { FreModelUnit } from "../../ast";
import { UndoModel } from "./change-model/UndoModel.js";
import { UndoUnit } from "./change-model/UndoUnit.js";
import { UndoPart } from "./change-model/UndoPart.js";
import { FreDelta, FreTransactionDelta, FreUndoManager } from "../../change-manager/index.js";
import { FreModelUnit } from "../../ast/index.js";
import { describe, it, expect, beforeEach } from "vitest";

// expose the private parts of the undo manager for testing purposes only
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/__tests__/changes/change-model/UndoModel.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { observablepart, FreNodeBaseImpl, FreModel } from "../../../ast";
import { FreUtils } from "../../../util";
import { FreLanguage } from "../../../language";
import { UndoUnit } from "./UndoUnit";
import { observablepart, FreNodeBaseImpl, FreModel } from "../../../ast/index.js";
import { FreUtils } from "../../../util/index.js";
import { FreLanguage } from "../../../language/index.js";
import { UndoUnit } from "./UndoUnit.js";

/**
* Class UndoModel is the implementation of the model with the same name in the language definition file.
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/__tests__/changes/change-model/UndoPart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* It uses mobx decorators to enable parts of the language environment, e.g. the editor, to react
* to the changes in the state of its properties.
*/
import { observableprim, FreNodeBaseImpl, FreNamedNode } from "../../../ast";
import { FreUtils } from "../../../util";
import { observableprim, FreNodeBaseImpl, FreNamedNode } from "../../../ast/index.js";
import { FreUtils } from "../../../util/index.js";

export class UndoPart extends FreNodeBaseImpl implements FreNamedNode {
/**
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/__tests__/changes/change-model/UndoUnit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import {
observableprimlist,
FreNodeBaseImpl,
FreModelUnit,
} from "../../../ast";
} from "../../../ast/index.js";
import { UndoPart } from "./UndoPart";
import { FreUtils } from "../../../util";
import { FreUtils } from "../../../util/index.js";
import { FreLogger } from "../../../logging";

const LOGGER = new FreLogger("UndoUnit");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { FreNamedNode } from "../../ast";
import { FreNamedNode } from "../../ast/index.js";
import { computed, observable, makeObservable } from "mobx";
import { TestScoper } from "./TestScoper";
import { FreLogger } from "../../logging";
import { MobxModelElementImpl } from "../../ast";
import { TestScoper } from "./TestScoper.js";
import { FreLogger } from "../../logging/index.js";
import { MobxModelElementImpl } from "../../ast/index.js";

const LOGGER = new FreLogger("FreNodeReference").mute();
/**
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/__tests__/mobx/MobxModel.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import "reflect-metadata";
import { FreNodeBaseImpl, observablepartlist, observablepart, observableprimlist, observableprim } from "../../ast";
import { FreNodeBaseImpl, observablepartlist, observablepart, observableprimlist, observableprim } from "../../ast/index.js";
import { makeObservable, observable } from "mobx";
import { FreNodeReferenceTestScoper } from "./FreNodeReferenceTestScoper";
import { FreNodeReferenceTestScoper } from "./FreNodeReferenceTestScoper.js";

/**
* These classes are used only to test the mobx decorators. They extend FreNodeBaseImpl directly.
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/__tests__/mobx/MobxTest.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FreNodeReferenceTestScoper } from "./FreNodeReferenceTestScoper";
import { TestScoper } from "./TestScoper";
import { MobxTestElement, ModelContext, MobxTestRoot, MobxTestParts } from "./MobxModel";
import { FreNodeReferenceTestScoper } from "./FreNodeReferenceTestScoper.js";
import { TestScoper } from "./TestScoper.js";
import { MobxTestElement, ModelContext, MobxTestRoot, MobxTestParts } from "./MobxModel.js";
import { observe, reaction } from "mobx";
import { describe, it, expect, beforeEach } from "vitest";

Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/__tests__/mobx/TestScoper.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MobxTestRoot } from "./MobxModel";
import { FreNamedNode } from "../../ast";
import { MobxTestRoot } from "./MobxModel.js";
import { FreNamedNode } from "../../ast/index.js";

export class TestScoper {
private static instance: TestScoper = new TestScoper();
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/ast-utils/AstUtil.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FreLanguage } from "../language";
import { FreLanguage } from "../language/index.js";
import {
FreBinaryExpression,
FreNode,
Expand All @@ -7,7 +7,7 @@ import {
FreModelUnit,
FreNamedNode,
FreNodeReference,
} from "../ast";
} from "../ast/index.js";

export function isFreModel(node: FreNode): node is FreModel {
return !!node && node.freIsModel && node.freIsModel();
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/ast-utils/AstWalker.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { FreLanguage, FreLanguageProperty } from "../language";
import { FreLogger } from "../logging";
import { AstWorker } from "./AstWorker";
import { FreNode } from "../ast";
import { FreLanguage, FreLanguageProperty } from "../language/index.js";
import { FreLogger } from "../logging/index.js";
import { AstWorker } from "./AstWorker.js";
import { FreNode } from "../ast/index.js";

const LOGGER = new FreLogger("AstWalker");

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/ast-utils/AstWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Interface AstWorker defines the extended visitor pattern of instances of languages.
* Every node is visited twice, once before the visit of its children, and once after this visit.
*/
import { FreNode } from "../ast";
import { FreNode } from "../ast/index.js";

export interface AstWorker {
/**
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/ast-utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from "./AstWorker";
export * from "./AstWalker";
export * from "./AstUtil";
export * from "./AstWorker.js";
export * from "./AstWalker.js";
export * from "./AstUtil.js";
2 changes: 1 addition & 1 deletion packages/core/src/ast/FreBinaryExpression.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FreExpressionNode } from "./FreExpressionNode";
import { FreExpressionNode } from "./FreExpressionNode.js";

export interface FreBinaryExpression extends FreExpressionNode {
freLeft(): FreExpressionNode;
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/ast/FreExpressionNode.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { FreNode } from "./FreNode";
import { FreNode } from "./FreNode.js";

export interface FreExpressionNode extends FreNode {}
4 changes: 2 additions & 2 deletions packages/core/src/ast/FreModel.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FreNamedNode } from "./FreNamedNode";
import { FreModelUnit } from "./FreModelUnit";
import { FreNamedNode } from "./FreNamedNode.js";
import { FreModelUnit } from "./FreModelUnit.js";

// TODO rethink inheritance from FreNamedElement: no match method needed here
export interface FreModel extends FreNamedNode {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/ast/FreModelUnit.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FreNamedNode } from "./FreNamedNode";
import { FreNamedNode } from "./FreNamedNode.js";

export interface FreModelUnit extends FreNamedNode {
fileExtension: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/ast/FreNamedNode.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FreNode } from "./FreNode";
import { FreNode } from "./FreNode.js";

export interface FreNamedNode extends FreNode {
name: string;
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/ast/FreNode.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FreOwnerDescriptor } from "./FreOwnerDescriptor";
import { FreParseLocation } from "../reader";
import { FreOwnerDescriptor } from "./FreOwnerDescriptor.js";
import { FreParseLocation } from "../reader/index.js";

/**
* You can either directly implement these interfaces, or use `Module Augmentation`,
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/ast/FreNodeBaseImpl.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FreNode } from "..";
import { FreParseLocation } from "../reader";
import { MobxModelElementImpl } from "./decorators";
import { FreNode } from "./index.js";
import { FreParseLocation } from "../reader/index.js";
import { MobxModelElementImpl } from "./decorators/index.js";

/**
* An abstract implementation of a decorated FreNode.
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/ast/FreNodeReference.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { FreNamedNode } from ".";
import { FreNamedNode } from "./FreNamedNode.js";
import { computed, observable, makeObservable } from "mobx";
import { FreLanguageEnvironment } from "../environment";
import { FreLogger } from "../logging";
import { MobxModelElementImpl } from "./decorators";
import { FreLanguageEnvironment } from "../environment/index.js";
import { FreLogger } from "../logging/index.js";
import { MobxModelElementImpl } from "./decorators/index.js";

const LOGGER = new FreLogger("FreElementReference").mute();
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/ast/FreOwnerDescriptor.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FreNode } from "./FreNode";
import { FreNode } from "./FreNode.js";

/**
* This object describes for each FreNode what its `owner` object is (if any),
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/ast/decorators/DecoratedModelElement.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { makeObservable, observable } from "mobx";
import { FreOwnerDescriptor, FreNode } from "..";
import { FreOwnerDescriptor, FreNode } from "../index.js";

/**
* An element using the decorators should implement this interface.
Expand Down
10 changes: 5 additions & 5 deletions packages/core/src/ast/decorators/MobxModelDecorators.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { IObservableValue, IArrayWillChange, IArrayWillSplice, observable, intercept, runInAction } from "mobx";
import "reflect-metadata";
import { FreNode } from "../FreNode";
import { FreNode } from "../FreNode.js";

import { allOwners, DecoratedModelElement } from "./DecoratedModelElement";
import { FreChangeManager } from "../../change-manager";
import { PrimType } from "../../language";
import { FreLogger } from "../../logging";
import { allOwners, DecoratedModelElement } from "./DecoratedModelElement.js";
import { FreChangeManager } from "../../change-manager/index.js";
import { PrimType } from "../../language/index.js";
import { FreLogger } from "../../logging/index.js";

const LOGGER: FreLogger = new FreLogger("MobxDecorators").mute();

Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/ast/decorators/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from "./MobxModelDecorators";
export * from "./DecoratedModelElement";
export * from "./MobxModelDecorators.js";
export * from "./DecoratedModelElement.js";
2 changes: 1 addition & 1 deletion packages/core/src/ast/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "./internal";
export * from "./internal.js";
22 changes: 11 additions & 11 deletions packages/core/src/ast/internal.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
export * from "./FreNode";
export * from "./FreNamedNode";
export * from "./FreExpressionNode";
export * from "./FreBinaryExpression";
export * from "./FreOwnerDescriptor";
export * from "./FreExpressionNode";
export * from "./FreModel";
export * from "./FreModelUnit";
export * from "./decorators";
export * from "./FreNodeBaseImpl";
export * from "./FreNodeReference";
export * from "./FreNode.js";
export * from "./FreNamedNode.js";
export * from "./FreExpressionNode.js";
export * from "./FreBinaryExpression.js";
export * from "./FreOwnerDescriptor.js";
export * from "./FreExpressionNode.js";
export * from "./FreModel.js";
export * from "./FreModelUnit.js";
export * from "./decorators/index.js";
export * from "./FreNodeBaseImpl.js";
export * from "./FreNodeReference.js";
10 changes: 5 additions & 5 deletions packages/core/src/change-manager/FreChangeManager.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { DecoratedModelElement, FreNode } from "../ast";
import { FreDelta, FrePartListDelta, FrePartDelta, FrePrimDelta, FrePrimListDelta } from "./FreDelta";
import { FreLogger } from "../logging";
import { PrimType } from "../language";
import { modelUnit } from "../ast-utils";
import { DecoratedModelElement, FreNode } from "../ast/index.js";
import { FreDelta, FrePartListDelta, FrePartDelta, FrePrimDelta, FrePrimListDelta } from "./FreDelta.js";
import { FreLogger } from "../logging/index.js";
import { PrimType } from "../language/index.js";
import { modelUnit } from "../ast-utils/index.js";

export type callback = (delta: FreDelta) => void;

Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/change-manager/FreDelta.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DecoratedModelElement, MobxModelElementImpl, FreNode, FreNodeBaseImpl, FreModelUnit } from "../ast";
import { PrimType } from "../language";
import { DecoratedModelElement, MobxModelElementImpl, FreNode, FreNodeBaseImpl, FreModelUnit } from "../ast/index.js";
import { PrimType } from "../language/index.js";

export abstract class FreDelta {
unit: FreModelUnit;
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/change-manager/FreUndoManager.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { FreChangeManager } from "./FreChangeManager";
import { FreModelUnit } from "../ast";
import { FreDelta } from "./FreDelta";
import { FreUndoStackManager } from "./FreUndoStackManager";
import { FreChangeManager } from "./FreChangeManager.js";
import { FreModelUnit } from "../ast/index.js";
import { FreDelta } from "./FreDelta.js";
import { FreUndoStackManager } from "./FreUndoStackManager.js";

/**
* Class FreUndoManager holds the change information on the model.
Expand Down
10 changes: 5 additions & 5 deletions packages/core/src/change-manager/FreUndoStackManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import {
FrePrimDelta,
FrePrimListDelta,
FreTransactionDelta,
} from "./FreDelta";
import { FreModelUnit } from "../ast";
import { modelUnit } from "../ast-utils";
import { FreLogger } from "../logging";
import { FreUndoManager } from "./FreUndoManager";
} from "./FreDelta.js";
import { FreModelUnit } from "../ast/index.js";
import { modelUnit } from "../ast-utils/index.js";
import { FreLogger } from "../logging/index.js";
import { FreUndoManager } from "./FreUndoManager.js";

const LOGGER: FreLogger = new FreLogger("FreUndoStackManager");

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/change-manager/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "./internal";
export * from "./internal.js";
6 changes: 3 additions & 3 deletions packages/core/src/change-manager/internal.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from "./FreChangeManager";
export * from "./FreUndoManager";
export * from "./FreDelta";
export * from "./FreChangeManager.js";
export * from "./FreUndoManager.js";
export * from "./FreDelta.js";
2 changes: 1 addition & 1 deletion packages/core/src/editor/FreCombinedActions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FreCreateBinaryExpressionAction, FreCustomAction } from "./actions";
import { FreCreateBinaryExpressionAction, FreCustomAction } from "./actions/index.js";

export interface FreCombinedActions {
binaryExpressionActions: FreCreateBinaryExpressionAction[];
Expand Down
Loading