How to use Traceur with a nested directory structure?

I want to use ES6 for my next project, and I use Traceur as a transpiler for this purpose. I started working as described in Getting Started . However, I would like to compile all my source files into one mini file so that they describe it on the Compiling Offline page . But I can not get it to work with several source files organized in a nested directory structure.

Here is an example project to explain the problem. It has index.html in the root folder and two .js files in src.

<project-root>
/index.html
/src/one.js
/src/two.js

index.html

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <script src="traceur.js" type="text/javascript"></script>
  <script src="bootstrap.js" type="text/javascript"></script>
  <script type="module" src="src/two.js"></script>
  <script type="module">
    import Two from 'src/two.js';
    let t = new Two();
    console.log(t);
  </script>
  <title>Title</title>
</head>
<body>

</body>
</html>

SIC / one.js

export default class One {

  constructor() {
    console.log("One constructor");
  }

}

SIC / two.js

import One from 'src/one.js';

export default class Two extends One {
  constructor () {
    console.log("Two constructor");
    super();
  }
}

As I said, if I open index.html in a browser, it will work correctly by printing an instance of Two for the console.

,

PS D:\code\flattraceur> traceur.cmd src/two.js --out out\two.js
[Error: Error: ENOENT: no such file or directory, open 'D:\code\flattraceur\out\src\one.js'
Specified as src/one.js.
Imported by ../src/two.js.
Normalizes to src/one.js
locate resolved against base 'D:/code/flattraceur/out/'
]

, src/two.js traceur src/one.js . traceur, . --dir, .

PS D:\code\flattraceur> traceur.cmd --dir src out

  Error: At least one input file is needed

?

+4

Source: https://habr.com/ru/post/1620005/


All Articles