esm 你退群吧

Created on 16 Jan 2019  ·  2Comments  ·  Source: standard-things/esm

esm 本身出现就是为了 让web 模块化的,
结果 浏览器 esm 运行不了
import lodash from 'lodash '
然后为了解决方案来了 browserify =>webpack , 然后问题又来了
node.js 本身 不支持esm 然后你们这样写 node.js 又得用babel 去打包,编译了..不然就没法运行
然后看了半天人家的打包配置: 把async 语法都编译成 node.js 低版本的东西了...
弄了半天 哇 这折腾

question

Most helpful comment

Hi @spitWind!

The Google translate for your issue is a little rough:

Esm itself appears to make the web modular,
Result browser esm can't run
Import lodash from 'lodash '
Then came the solution for the browserify =>webpack , then the problem came again
Node.js itself does not support esm and then you write node.js and then use babel to package and compile.. otherwise it will not run.
Then I saw the package configuration for a long time: Compile the async syntax into a low version of node.js...
Got it for a long time, wow, this toss

I think what you're getting at is how to bundle code for the browser. You can use the browser or module field in your package.json to specify the ESM entry point _(whichever your bundler of choice supports)_. For example, if you're using esm in an _index.js_ to bridge the ESM entry point in _main.js_ your module field would be "module":"./main.js".

You can use the Browserify plugin esmify to add support for resolving the "module" field.

thank you
Both the browser and node.js are not compatible with esm mode.
i think i use cjs mode would be better

All 2 comments

Hi @spitWind!

The Google translate for your issue is a little rough:

Esm itself appears to make the web modular,
Result browser esm can't run
Import lodash from 'lodash '
Then came the solution for the browserify =>webpack , then the problem came again
Node.js itself does not support esm and then you write node.js and then use babel to package and compile.. otherwise it will not run.
Then I saw the package configuration for a long time: Compile the async syntax into a low version of node.js...
Got it for a long time, wow, this toss

I think what you're getting at is how to bundle code for the browser. You can use the browser or module field in your package.json to specify the ESM entry point _(whichever your bundler of choice supports)_. For example, if you're using esm in an _index.js_ to bridge the ESM entry point in _main.js_ your module field would be "module":"./main.js".

You can use the Browserify plugin esmify to add support for resolving the "module" field.

Hi @spitWind!

The Google translate for your issue is a little rough:

Esm itself appears to make the web modular,
Result browser esm can't run
Import lodash from 'lodash '
Then came the solution for the browserify =>webpack , then the problem came again
Node.js itself does not support esm and then you write node.js and then use babel to package and compile.. otherwise it will not run.
Then I saw the package configuration for a long time: Compile the async syntax into a low version of node.js...
Got it for a long time, wow, this toss

I think what you're getting at is how to bundle code for the browser. You can use the browser or module field in your package.json to specify the ESM entry point _(whichever your bundler of choice supports)_. For example, if you're using esm in an _index.js_ to bridge the ESM entry point in _main.js_ your module field would be "module":"./main.js".

You can use the Browserify plugin esmify to add support for resolving the "module" field.

thank you
Both the browser and node.js are not compatible with esm mode.
i think i use cjs mode would be better

Was this page helpful?
0 / 5 - 0 ratings