This question has already been asked
https://mail.mozilla.org/pipermail/es-discuss/2015-February/041430.html
I prefer to follow the following rules:
File structure
```
root/
foo/
index.js
```
Export module
```js
export default foo class () {}
```
Import module
In Node.js you can either mention the file extension .js or omit it when you
require a module. Which one is preferred for ES6 ModuleSpecifiers?
Thanks!
Axel
--
Dr. Axel Rauschmayer
a...@rauschma.de
rauschma.de
___
es-discuss mailing list
Some food for thought from a non-standard use-case.
In GPSEE, we can require(module) - but we support both modules written in
JavaScript, and modules written in C (technically, any compiled binary with
the correct C API), or both. We dlload(module.so) (if present), then
interpret module.js (if
.
From: John Barton johnjbar...@google.com
To: Glen Huang curvedm...@gmail.com
Cc: monolithed monolit...@gmail.com, es-discuss
es-discuss@mozilla.org
Date: Thu, 5 Feb 2015 07:53:47 -0800
Subject: Re: include 'foo/index.js' or include 'foo'?
The following solution has worked very well for us
.
From: John Barton johnjbar...@google.com
To: Glen Huang curvedm...@gmail.com
Cc: monolithed monolit...@gmail.com, es-discuss
es-discuss@mozilla.org
Date: Thu, 5 Feb 2015 07:53:47 -0800
Subject: Re: include 'foo/index.js' or include 'foo'?
The following solution has worked very
I could not find an answer in the specification regarding the following
cases:
import './foo/index.js'
import 'foo/index.js'
import 'foo/index'
import 'foo'
import 'foo/'
Is there a difference?
Node.js lets create an 'index.js' file, which indicates the main include
file for a directory.
So
```js
import './foo/index.js';
import 'foo/index.js';
import 'foo/index';
import 'foo';
import 'foo/‘;
```
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
lets create an 'index.js' file, which indicates the main include file
for a directory.
So if you call require('./foo'), both a 'foo.js' file as well as an
'foo/index.js' file will be considered, this goes for non-relative includes
as well
the following
cases:
import './foo/index.js'
import 'foo/index.js'
import 'foo/index'
import 'foo'
import 'foo/'
Is there a difference?
Node.js lets create an 'index.js' file, which indicates the main include
file for a directory.
So if you call require('./foo'), both a 'foo.js' file as well
bad sure, but sometimes
you have to play cards you are dealt. We still depend upon foo.js, bad or
not bad.
In the current module system we have to abandon ship. In our importer we
need to:
// WARNING pre-load foo.js somehow!
Now imagine if we could issue
include 'foo';
and the Loader computes
to play cards you are dealt. We still depend upon foo.js, bad or
not bad.
In the current module system we have to abandon ship. In our importer we
need to:
// WARNING pre-load foo.js somehow!
Now imagine if we could issue
include 'foo';
and the Loader computes an address, say foo.js,fetches
importer we
need to:
// WARNING pre-load foo.js somehow!
Now imagine if we could issue
include 'foo';
and the Loader computes an address, say foo.js,fetches the resource and
compiles it. Since the content has no dependencies, it is evaluated, then
the importer is evaluated. Yay
Sorry, I was imagining a specific scenario without giving the specifics:
include 'foo'; // foo is conventional JS, not a module
I have written on global in a module, it works ok, but the goal was
specifically to mutate global with code written in a module.
Here I have given code, designed
the specifics:
include 'foo'; // foo is conventional JS, not a module
I have written on global in a module, it works ok, but the goal was
specifically to mutate global with code written in a module.
Here I have given code, designed to be loaded with a script tag or
included with require() in node
14 matches
Mail list logo