Esm: SyntaxError: Missing export in [email protected]

Created on 22 May 2018  路  11Comments  路  Source: standard-things/esm

Error:

SyntaxError: Missing export 'createTest2' in ES module: node_modules/test/build.js
at Object. (xxx.js:1)

Reproducable structure:

  1. esm
require = require('esm')(module)
requireModule('./xxx')
  1. xxx.js import node_modules/test
import { createTest2 } from 'test' 
  1. node_modules/test/index.js
module.exports = require('./build')
  1. node_modules/test/build.js
exports.createTest1 = function () {};
exports.createTest2 = function () {};

Example:
https://github.com/vuejs/vue/blob/dev/packages/vue-server-renderer/index.js#L16
https://github.com/vuejs/vue/blob/dev/packages/vue-server-renderer/build.js#L8641-L8642

bug

Most helpful comment

@StreetStrider it's likely totally my bad _(esm loader regression)_ and not something you've done. I should have a release out today that hopefully resolves the issue.

Update:

v3.0.37 is released :tada:

All 11 comments

Hi @clarkdo could you create a simple repro repo.

@jdalton https://github.com/clarkdo/esm-issue-report

I found the error only occurred when import same file but different exported things multiple times.

First import: https://github.com/clarkdo/esm-issue-report/blob/master/core/index.js#L1
Second: https://github.com/clarkdo/esm-issue-report/blob/master/core/renderer.js#L1

Thanks @clarkdo!

This appears to be fixed in our master branch :tada:

@jdalton Thank you so much for the fast fix 馃樃

@jdalton looks like I've faced that or similar issue on 3.0.36 with package randomstring.
SyntaxError: Missing export 'generate' in ES module: file:///.../node_modules/randomstring/lib/randomstring.js.
When I do import { generate as random } from 'randomstring'. (possible caused by this re-export)

I can believe that this may be an improper use of import by mine, but this works previously on major esm@3 til recent time.

@StreetStrider it's likely totally my bad _(esm loader regression)_ and not something you've done. I should have a release out today that hopefully resolves the issue.

Update:

v3.0.37 is released :tada:

Sorry, I've tried 3.0.37 when its out, havent any time to post this. Now esm nagging on export { default } from './Outcome' with Missing export 'default' in ES module: file:///.../src/Outcome/index.js where static typing doesn't find any problem one step earlier. I use this when I want re-export Smth/Smth.js as Smth/index.js.

Hard fixed with "esm": "3.0.34", for now.

Hi @StreetStrider!

Could you create a repro repo for me to check out and file a new issue.

~@jdalton, will do.~ Already fixed.

Confirm that fixed in #422 :+1:

Was this page helpful?
0 / 5 - 0 ratings