". js" extension loses relative path in Requirejs modules

Asked

Viewed 17 times

1

I’m using Bable or Typescript to transpose my ES6 modules to AMD. The problem is that if the file has extension Requirejs cannot locate the files, it looks at the root of the project instead of relative to the file.


Thus does not work in ES6 module:

src/index.js

import { counter } from './conter.js';

dist/index.js

define(["./counter.js"], function (_counter) {});

How it works in AMD module:

src/index.js

import { counter } from './conter';

dist/index.js

define(["./counter"], function (_counter) {});

I’m in need of a solution that works on both.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.