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

[ecmascript] (#311) Fix for Unknown error on VROES.import from a missing/invalid module path #345

Merged
merged 18 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
892ddf9
style: [Issue 311] Validations in ecmascript/Module import - module t…
bcpmihail Jul 17, 2024
2063322
feat: [Issue 311] Validations in ecmascript/Module import, load
bcpmihail Jul 17, 2024
677e45d
docs: [Issue 311] Validations in ecmascript/Module - comments
bcpmihail Jul 17, 2024
778920d
test: [Issue 311] Validations in ecmascript/Module - unit tests
bcpmihail Jul 17, 2024
06e5447
docs: [Issue 311] Validations in ecmascript/Module - README
bcpmihail Jul 18, 2024
efd6150
docs: [Issue 311] Validations in ecmascript/Module - release note
bcpmihail Jul 18, 2024
9299814
docs: [Issue 311] Validations in ecmascript/Module - fixed linter iss…
bcpmihail Jul 18, 2024
275e79c
fix: [Issue 311] Validations in ecmascript/Module - error handling wi…
bcpmihail Jul 18, 2024
037f452
refactor: [Issue 311] Validations in ecmascript/Module - error handli…
bcpmihail Aug 1, 2024
7a3d436
fix: [Issue 311] Validations in ecmascript/Module - removed export
bcpmihail Aug 1, 2024
680b867
Merge remote-tracking branch 'origin' into bugfix/issue-311-vroes-imp…
bcpmihail Aug 1, 2024
46a1048
docs: [Issue 311] Validations in ecmascript/Module - updated README
bcpmihail Aug 1, 2024
d8a48bc
Merge branch 'main' into bugfix/issue-311-vroes-import-unknown-error
bcpmihail Aug 1, 2024
74cad6b
chore: Merge latest changes from the main branch (v.2.41.0) into bugf…
bcpmihail Aug 5, 2024
def318b
fix: [Issue 311] Validations in ecmascript/Module - kept a single def…
bcpmihail Aug 19, 2024
5687f7c
docs: [Issue 311] Validations in ecmascript/Module - regex example, r…
bcpmihail Aug 19, 2024
67ededb
test: [Issue 311] Validations in ecmascript/Module - unit tests for M…
bcpmihail Aug 19, 2024
513d8c1
test: [Issue 311] Validations in ecmascript/Module - unit tests for M…
bcpmihail Aug 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions docs/versions/latest/Release.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,38 @@ The following classes were added to `o11n-plugin-aria`:

<https://github.com/vmware/build-tools-for-vmware-aria/issues/347>

### Change default return Object of `Array.from()` Method to be empty array

#### Previous Behavior

In case the object type of the array-like Object does not match any of the expected types (e.g. is a Number) the default case of `Array.from()` returns a clone of the object. This does not match the desired behaviour according to the official documentation.

```js
Array.from(10) // Output: 10
```

#### Current Behavior
In case the object type of the array-like Object does not match any of the expected types (e.g. is a Number) the default case of `Array.from()` returns an empty array.

```js
Array.from(10) // Output: []
```

### *VROES.import from invalid package throws Unknown error*

Fixed an issue with VROES.import() in ecmascript Module.

#### Previous Behavior

VROES import from an invalid module path resulted in Unknown error.
The Unknown error could not be caught in a try/catch block and was not shown in the logs.

#### New Behavior

VROES import from a missing/invalid module path, or import of non-existing elements of a valid module,
result in more detailed errors in the logs. No exceptions are thrown by default (as per the existing behaviour)
but there is an option to alter the error handling behaviour via an optional parameter in import.from().

## Upgrade procedure

[//]: # (Explain in details if something needs to be done)
51 changes: 42 additions & 9 deletions packages/ecmascript/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ECMAScript library
The purpose of the library is to provide runtime support for Typescript based projects by handling the export/import features of ECMA script as well as providing implementations for Set, Map and sum of the Array functions.

# Usage
## Usage
This library is not to be used directly.

## Export
Expand All @@ -13,28 +13,28 @@ export function myFunction() {}
export var myVar = 5;

ESModule.export()
.named("MyClass", MyClass)
.named("myFunction", myFunction)
.named("myVar", myVar)
.build();
.named("MyClass", MyClass)
.named("myFunction", myFunction)
.named("myVar", myVar)
.build();
```

Default exports (function)
```js
export default function myFunction() {}

ESModule.export()
.default(myFunction)
.build();
.default(myFunction)
.build();
```

Default exports (class)
```js
export default class MyClass {}

ESModule.export()
.default(MyClass)
.build();
.default(MyClass)
.build();
```

## Import
Expand Down Expand Up @@ -62,3 +62,36 @@ Mixed imports
import defaultExport, { MyClass, myFunction as myFunc } from "module-name";
var { defaultExport, MyClass, myFunc} = ESModule.import("default", "MyClass", "myFunction").from("module-name");
```

Import with relative and base path
```js
import defaultExport, { MyClass, myFunction as myFunc } from "module-name";
// Note: ./ and ../ are supported only at the start of the relative path. Relative paths without base path will result in error
var { myFunc} = ESModule.import("myFunction").from("../../relative/path", "module-name");
var { MyClass} = ESModule.import("MyClass").from("./relative/path", "module-name");
```

Change error handling behavior on module import/load:
```js
import defaultExport, { MyClass, myFunction as myFunc } from "module-name";
// With predefined error handling options:

// [0] DefaultModuleErrorHandlers.SYS_ERROR - Creates a System ERROR level log entry for the error. Default.
ESModule.setModuleErrorHandler(DefaultModuleErrorHandlers.SYS_ERROR);
// [1] DefaultModuleErrorHandlers.SYS_WARN - Creates a System ERROR level log entry for the error.
ESModule.setModuleErrorHandler(DefaultModuleErrorHandlers.SYS_WARN);
// [2] DefaultModuleErrorHandlers.SYS_INFO - Creates a System INFO level log entry for the error
ESModule.setModuleErrorHandler(DefaultModuleErrorHandlers.SYS_INFO);
// [3] DefaultModuleErrorHandlers.SYS_DEBUG - Creates a System DEBUG level log entry for the error
ESModule.setModuleErrorHandler(DefaultModuleErrorHandlers.SYS_DEBUG);
// [4] DefaultModuleErrorHandlers.SILENT - Ignores the error
ESModule.setModuleErrorHandler(DefaultModuleErrorHandlers.SILENT);
// [5]DefaultModuleErrorHandlers.THROW_ERROR - Rethtows the error without handling it
ESModule.setModuleErrorHandler(DefaultModuleErrorHandlers.THROW_ERROR);


// With custom error handling:
ESModule.setModuleErrorHandler(function(error) {
// custom error treatment - formatting, reporting, etc.
});
```
Loading
Loading