This commit makes the `dependencies` param of
`odoo.define` mandatory. It was optional and when
omitted, a regexp read the function to find the
dependencies. We can simplify it now almost all js
modules have been converted to esm.
The transpiler already adds the param for the es
modules except if the module has an alias.
task id: 3271352
closesodoo/odoo#119145
Related: odoo/enterprise#40040
Signed-off-by: Mathieu Duckerts-Antoine <dam@odoo.com>
This commit changes the js transpiler to write sync module.
The goal is to remove all async module and simplify the
module loader in the future.
task id: 3265979
closesodoo/odoo#119186
Signed-off-by: Géry Debongnie <ged@odoo.com>
Before this commit, when filtering tests by odoo module,
tests registered with `QUnit.test` and `QUnit.debug` were
listed, but not `QUnit.only`.
closesodoo/odoo#108591
Signed-off-by: Géry Debongnie <ged@odoo.com>
It made the regex much slower in case of non-match, due to backtracking.
closesodoo/odoo#108046
X-original-commit: 56b1b17d6fdf493368ce219f981f94d9efdc9b7f
Signed-off-by: Simon Genin (ges@odoo) <ges@odoo.com>
After this commit, the transpiler will add the dependencies of a file
to the second argument of the odoo.define(...).
For example:
odoo.define("@test/test", ['@test/dep1', '@test/dep2'], async function (require)
With this change, the code for the module system in the browser will get
directly the dependencies instead of having to stringify the function
defining a module, and grep inside for the "require" words.
closesodoo/odoo#105651
Taskid: 3062390
Related: odoo/enterprise#34895
Signed-off-by: Géry Debongnie <ged@odoo.com>
The purpose of this improvement is to easily identify the module of a
test and to be able to run only the tests of a module.
closesodoo/odoo#105530
Task-id: 3062058
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Previously, when importing both the default export and named imports
with a trailing comma, we would transpile into an object where the first
keys were the named imports, including any trailing comma, and
concatenating with the default import with a leading comma, this means
that the trailing comma would transpile to two successive commas which
is not valid syntax.
This commit fixes that by putting the default import first, and adding
the named imports after, preserving the trailing comma if any, but
precluding the possibility that we get two commas back to back.
closesodoo/odoo#93693
X-original-commit: 798d2f2c6e8a496f4ce0cd3c4f1609693e692254
Signed-off-by: Géry Debongnie <ged@odoo.com>
Signed-off-by: Samuel Degueldre <sad@odoo.com>
Previously, importing the default export on the same line as the named
exports was not supported, this commit adds support for that in order to
allow removing duplicate imports.
before:
import something from "path";
import { A } from "path";
after:
import something, { A } from "path";
Part-of: odoo/odoo#84530
* add configuration for `flake8[flake8-rst-docstring]`
* enable docstring-related checks
* fix invalid docstrings in odoo's core & `base`
* fix a few more bits (mostly missing or incorrect `:param:` info
fields) are out of scope for the lint but my editor catches
closesodoo/odoo#74604
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
After this commit, the js_transpiler will support exported hoisting
function. So it will be possible to define a hoisting function and
exported in an @odoo-module.
Example of exported hoisting function which wasn't supported before
this commit:
```
hoisted();
export function hoisted() {
...
};
```
closesodoo/odoo#80965
X-original-commit: 40ef9f7aeac8048cce8f002c84181abc64bcbe87
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Transpile odoo-modules into async function rather than simple functions.
The aim of this change is to support top-level await.
closesodoo/odoo#74629
Signed-off-by: Simon Genin (ges@odoo) <ges@odoo.com>
The code of the Odoo editor was on another repository
and that created unnecessary overhead. This commit move
the code inside Odoo and slightly change the folder
structure.
Related PR:
saas-14.3: #73345
saas-14.4: #73348closesodoo/odoo#73272
Master: #73272
Signed-off-by: Antoine Guenet <Zinston@users.noreply.github.com>
This commit is to fix two problems when transpiling an @odoo-module file.
1. When a file exports an object with a long name, the regex EXPORT_FROM_RE will cause catastrophic backtracking. The regex will take a long time to resolve.
Example:
```js
export {a, aReallyVeryLongNameElement};
```
2. When a file exports an object without ending the line with ';'. The regex EXPORT_OBJECT_RE will remove spaces and line breaks that follow this kind of export.
Example:
Input:
```js
export {a}
xxx
```
Output:
```js
Object.assign(__export, {a})xxx
```
Output after this commit:
```js
Object.assign(__export, {a})
xxx
```
closesodoo/odoo#68868
Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
In a @odoo-module js file, importing a legacy module that did not have
a name respecting the "addon.name" format was not supported.
This commit will support all keys that do not start with a "." or "@".
This commit will also improve some regexes allowing to extract path.
Legacy module name supported:
import X from "some/path"
import X from "addon.name"
Legacy module name not supported:
(relative path and @module/path are only used to import @odoo-module js
files)
import X from "@some/path"
import X from "./some/path"
import X from "../../some/path"
closesodoo/odoo#68152
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
When you define an @odoo-module with an alias without any space between
the alias and the **/, the alias contains the **/.
The purpose of this commit is to no longer add the **/ to the alias.
Example:
/** @odoo-module alias=web.base**/
Before:
odoo.define(`web.base**/`, function(require) {
After:
odoo.define(`web.base`, function(require) {
closesodoo/odoo#66929
Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
This commit fixes two unrelated small issues in the JS transpiler regexps:
- handle special chars in file url (so, one can now use a "-" in a file url)
- issue with the @odoo-module detection: it required 2 spaces after the @odoo-module word, because of the way the regexp was constructed. It also required spaces at the start of the line. All those have been fixed.
closesodoo/odoo#66255
Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
Because of the way Odoo works at its core, we do not know before hand
which files will be loaded as an asset in the browser, because it
depends on the installed Odoo addons. This is why it is historically
difficult to integrate Odoo with standard JS tooling, and this is why
Odoo needs to use a custom javascript module system.
However, there is a way to use native JS modules (and gain all the
benefits from it: IDE autocompletion, ease of refactoring, intellisense,
...): we can write JS as native JS modules, but convert them at runtime
into Odoo custom modules. This is exactly the strategy applied by this
PR.
This has a lot of benefits, but there is a downside: we can no longer
serve statically JS files in debug=assets. This would be a dealbreaker,
if we did not have sourcemaps (implemented in the next commit).
This commit introduces the python code that will transpile native JS
modules into odoo JS modules.
Task ID: 2414902
PR: 63177
Co-authored-by: Francois (fge) <fge@odoo.com>