Skip to content

Commit

Permalink
feat: expose fast-element as a module package to NodeJS (#5601)
Browse files Browse the repository at this point in the history
* add lint rule to enforce file extensions in imports

* declare fast-element as a ESModule package

* convert eslintrc to a commonjs module

* adding file extensions to import paths

* fixing accidently modified string

* fixing build processes

* revert change

* Change files

Co-authored-by: nicholasrice <[email protected]>
  • Loading branch information
nicholasrice and nicholasrice committed May 9, 2022
1 parent ecdf1c0 commit 0b53c4d
Show file tree
Hide file tree
Showing 26 changed files with 136 additions and 140 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "enumerate fast-element package as a ES module package",
"packageName": "@microsoft/fast-element",
"email": "[email protected]",
"dependentChangeType": "patch"
}
19 changes: 19 additions & 0 deletions packages/web-components/fast-element/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
extends: ["@microsoft/eslint-config-fast-dna", "prettier"],
rules: {
"import/extensions": ["error", "always"],
"max-classes-per-file": "off",
"no-case-declarations": "off",
"@typescript-eslint/ban-types": [
"error",
{
types: {
"{}": false,
Function: false,
Object: false,
},
extendDefaults: true,
},
],
},
};
30 changes: 0 additions & 30 deletions packages/web-components/fast-element/.eslintrc.json

This file was deleted.

4 changes: 2 additions & 2 deletions packages/web-components/fast-element/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ src/

# config files
.eslintignore
.eslintrc.js
.eslintrc.cjs
.mocharc.json
.prettierignore
api-extractor.json
Expand All @@ -19,4 +19,4 @@ tsconfig.json

# cache
.rollupcache
temp
temp
1 change: 1 addition & 0 deletions packages/web-components/fast-element/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"url": "https://github.com/Microsoft/fast/issues/new/choose"
},
"main": "dist/esm/index.js",
"type": "module",
"types": "dist/fast-element.d.ts",
"type": "module",
"unpkg": "dist/fast-element.min.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/web-components/fast-element/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import typescript from "rollup-plugin-typescript2";
import {
transformCSSFragment,
transformHTMLFragment,
} from "../../../build/transform-fragments";
} from "../../../build/transform-fragments.js";

const parserOptions = {
sourceType: "module",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Accessor, Observable } from "../observation/observable";
import { DOM } from "../dom";
import type { Notifier } from "../observation/notifier";
import { isString } from "../interfaces";
import { Accessor, Observable } from "../observation/observable.js";
import { DOM } from "../dom.js";
import type { Notifier } from "../observation/notifier.js";
import { isString } from "../interfaces.js";

/**
* Represents objects that can convert values to and from
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { DOM } from "../dom.js";
import type { Mutable } from "../interfaces.js";
import type { Behavior } from "../observation/behavior.js";
import { PropertyChangeNotifier } from "../observation/notifier.js";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { isString, Mutable } from "../interfaces";
import { Observable } from "../observation/observable";
import { ComposableStyles, ElementStyles } from "../styles/element-styles";
import type { ElementViewTemplate } from "../templating/template";
import { AttributeConfiguration, AttributeDefinition } from "./attributes";
import { isString, Mutable } from "../interfaces.js";
import { Observable } from "../observation/observable.js";
import { ComposableStyles, ElementStyles } from "../styles/element-styles.js";
import type { ElementViewTemplate } from "../templating/template.js";
import { AttributeConfiguration, AttributeDefinition } from "./attributes.js";

const defaultShadowOptions: ShadowRootInit = { mode: "open" };
const defaultElementOptions: ElementDefinitionOptions = {};
Expand Down
4 changes: 2 additions & 2 deletions packages/web-components/fast-element/src/dom.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Callable } from "./interfaces";
import { $global, TrustedTypesPolicy } from "./platform";
import type { Callable } from "./interfaces.js";
import { $global, TrustedTypesPolicy } from "./platform.js";

/* eslint-disable */
const fastHTMLPolicy: TrustedTypesPolicy = $global.trustedTypes.createPolicy(
Expand Down
52 changes: 26 additions & 26 deletions packages/web-components/fast-element/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
export * from "./platform";
export * from "./templating/template";
export * from "./components/fast-element";
export * from "./platform.js";
export * from "./templating/template.js";
export * from "./components/fast-element.js";
export {
FASTElementDefinition,
PartialFASTElementDefinition,
} from "./components/fast-definitions";
export * from "./components/attributes";
export * from "./components/controller";
export type { Callable, Constructable, Mutable } from "./interfaces";
export * from "./templating/compiler";
} from "./components/fast-definitions.js";
export * from "./components/attributes.js";
export * from "./components/controller.js";
export type { Callable, Constructable, Mutable } from "./interfaces.js";
export * from "./templating/compiler.js";
export {
ElementStyles,
ElementStyleFactory,
ComposableStyles,
StyleTarget,
} from "./styles/element-styles";
export { css, cssPartial } from "./styles/css";
export { CSSDirective } from "./styles/css-directive";
export * from "./templating/view";
export * from "./observation/observable";
export * from "./observation/notifier";
export { Splice } from "./observation/array-change-records";
export { enableArrayObservation } from "./observation/array-observer";
export { DOM } from "./dom";
export type { Behavior } from "./observation/behavior";
} from "./styles/element-styles.js";
export { css, cssPartial } from "./styles/css.js";
export { CSSDirective } from "./styles/css-directive.js";
export * from "./observation/observable.js";
export * from "./observation/notifier.js";
export { Splice } from "./observation/array-change-records.js";
export { enableArrayObservation } from "./observation/array-observer.js";
export { DOM } from "./dom.js";
export type { Behavior } from "./observation/behavior.js";
export {
bind,
oneTime,
Expand All @@ -33,22 +32,23 @@ export {
BindingType,
BindingBehaviorFactory,
DefaultBindingOptions,
} from "./templating/binding";
} from "./templating/binding.js";
export {
ViewBehaviorTargets,
ViewBehavior,
ViewBehaviorFactory,
HTMLDirective,
AspectedHTMLDirective,
InlinableHTMLDirective,
} from "./templating/html-directive";
export * from "./templating/ref";
export * from "./templating/when";
export * from "./templating/repeat";
export * from "./templating/slotted";
export * from "./templating/children";
} from "./templating/html-directive.js";
export * from "./templating/ref.js";
export * from "./templating/when.js";
export * from "./templating/repeat.js";
export * from "./templating/slotted.js";
export * from "./templating/children.js";
export * from "./templating/view.js";
export {
elements,
ElementsFilter,
NodeBehaviorOptions,
} from "./templating/node-observation";
} from "./templating/node-observation.js";
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { DOM } from "../dom";
import { Splice } from "./array-change-records";
import { SubscriberSet } from "./notifier";
import type { Notifier } from "./notifier";
import { Observable } from "./observable";
import { DOM } from "../dom.js";
import { Splice } from "./array-change-records.js";
import { SubscriberSet } from "./notifier.js";
import type { Notifier } from "./notifier.js";
import { Observable } from "./observable.js";

function adjustIndex(changeRecord: Splice, array: any[]): Splice {
let index = changeRecord.index;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DOM } from "../dom";
import { PropertyChangeNotifier, SubscriberSet } from "./notifier";
import type { Notifier, Subscriber } from "./notifier";
import { isFunction, isString } from "../interfaces";
import { DOM } from "../dom.js";
import { isFunction, isString } from "../interfaces.js";
import { PropertyChangeNotifier, SubscriberSet } from "./notifier.js";
import type { Notifier, Subscriber } from "./notifier.js";

const volatileRegex = /(:|&&|\|\||if)/;
const notifierLookup = new WeakMap<any, Notifier>();
Expand Down
10 changes: 5 additions & 5 deletions packages/web-components/fast-element/src/styles/css.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { FASTElement } from "../components/fast-element";
import { isString } from "../interfaces";
import type { Behavior } from "../observation/behavior";
import { CSSDirective } from "./css-directive";
import { ComposableStyles, ElementStyles } from "./element-styles";
import type { FASTElement } from "../components/fast-element.js";
import { isString } from "../interfaces.js";
import type { Behavior } from "../observation/behavior.js";
import { CSSDirective } from "./css-directive.js";
import { ComposableStyles, ElementStyles } from "./element-styles.js";

function collectStyles(
strings: TemplateStringsArray,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Behavior } from "../observation/behavior";
import { DOM, nextId } from "../dom";
import type { Behavior } from "../observation/behavior.js";
import { DOM, nextId } from "../dom.js";

/**
* A node that can be targeted by styles.
Expand Down
12 changes: 6 additions & 6 deletions packages/web-components/fast-element/src/templating/binding.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { DOM } from "../dom";
import { isString, Mutable } from "../interfaces";
import { DOM } from "../dom.js";
import { isString, Mutable } from "../interfaces.js";
import {
Binding,
BindingObserver,
ExecutionContext,
Observable,
setCurrentEvent,
} from "../observation/observable";
} from "../observation/observable.js";
import {
InlinableHTMLDirective,
ViewBehavior,
ViewBehaviorTargets,
} from "./html-directive";
import type { CaptureType } from "./template";
import type { SyntheticView } from "./view";
} from "./html-directive.js";
import type { CaptureType } from "./template.js";
import type { SyntheticView } from "./view.js";

export type BindingBehaviorFactory = {
createBehavior(targets: ViewBehaviorTargets): ViewBehavior;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { isString } from "../interfaces";
import { NodeObservationDirective, NodeBehaviorOptions } from "./node-observation";
import type { CaptureType } from "./template";
import { isString } from "../interfaces.js";
import { NodeBehaviorOptions, NodeObservationDirective } from "./node-observation.js";
import type { CaptureType } from "./template.js";

/**
* The options used to configure child list observation.
Expand Down
10 changes: 5 additions & 5 deletions packages/web-components/fast-element/src/templating/compiler.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { _interpolationEnd, _interpolationStart, DOM } from "../dom.js";
import { isString } from "../interfaces.js";
import type { ExecutionContext } from "../observation/observable.js";
import { bind, oneTime } from "./binding.js";
import type {
AspectedHTMLDirective,
HTMLDirective,
InlinableHTMLDirective,
ViewBehaviorFactory,
ViewBehaviorTargets,
} from "./html-directive";
import { _interpolationEnd, _interpolationStart, DOM } from "../dom";
import type { ExecutionContext } from "../observation/observable";
import { bind, oneTime } from "./binding";
import { isString } from "../interfaces";
} from "./html-directive.js";

const targetIdFrom = (parentId: string, nodeIndex: number) => `${parentId}.${nodeIndex}`;
const descriptorCache: PropertyDescriptorMap = {};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DOM, nextId } from "../dom";
import type { Behavior } from "../observation/behavior";
import type { Binding, ExecutionContext } from "../observation/observable";
import { DOM, nextId } from "../dom.js";
import type { Behavior } from "../observation/behavior.js";
import type { Binding, ExecutionContext } from "../observation/observable.js";

/**
* The target nodes available to a behavior.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { ExecutionContext } from "../observation/observable";
import { emptyArray } from "../platform";
import type { ExecutionContext } from "../observation/observable.js";
import { emptyArray } from "../platform.js";
import {
StatelessAttachedAttributeDirective,
ViewBehaviorTargets,
} from "./html-directive";
} from "./html-directive.js";

/**
* Options for configuring node observation behavior.
Expand Down
6 changes: 3 additions & 3 deletions packages/web-components/fast-element/src/templating/ref.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { CaptureType } from "./template";
import type { ExecutionContext } from "../observation/observable.js";
import {
StatelessAttachedAttributeDirective,
ViewBehaviorTargets,
} from "./html-directive";
import type { ExecutionContext } from "../observation/observable";
} from "./html-directive.js";
import type { CaptureType } from "./template.js";

/**
* The runtime behavior for template references.
Expand Down
22 changes: 11 additions & 11 deletions packages/web-components/fast-element/src/templating/repeat.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { DOM } from "../dom";
import { DOM } from "../dom.js";
import { isFunction } from "../interfaces.js";
import type { Splice } from "../observation/array-change-records.js";
import { enableArrayObservation } from "../observation/array-observer.js";
import type { Behavior } from "../observation/behavior.js";
import type { Notifier, Subscriber } from "../observation/notifier.js";
import {
Binding,
BindingObserver,
ExecutionContext,
Observable,
} from "../observation/observable";
import type { Notifier, Subscriber } from "../observation/notifier";
import { enableArrayObservation } from "../observation/array-observer";
import type { Splice } from "../observation/array-change-records";
import type { Behavior } from "../observation/behavior";
import { emptyArray } from "../platform";
import { ViewBehaviorTargets, HTMLDirective } from "./html-directive";
import { HTMLView, SyntheticView } from "./view";
import type { CaptureType, SyntheticViewTemplate } from "./template";
import { isFunction } from "../interfaces";
} from "../observation/observable.js";
import { emptyArray } from "../platform.js";
import { HTMLDirective, ViewBehaviorTargets } from "./html-directive.js";
import type { CaptureType, SyntheticViewTemplate } from "./template.js";
import { HTMLView, SyntheticView } from "./view.js";

/**
* Options for configuring repeat behavior.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { isString } from "../interfaces";
import { NodeObservationDirective, NodeBehaviorOptions } from "./node-observation";
import type { CaptureType } from "./template";
import { isString } from "../interfaces.js";
import { NodeBehaviorOptions, NodeObservationDirective } from "./node-observation.js";
import type { CaptureType } from "./template.js";

/**
* The options used to configure slotted node observation.
Expand Down
Loading

0 comments on commit 0b53c4d

Please sign in to comment.