Skip to content

Doesn't seem to work with import statements in node modules #45

Description

@philipwalton

I've been having problems getting a particular build to work, and I've reduced it down to the fact that I'm including a module from npm that contains an import statement.

Here's my reduced setup:

  • entry: ./index.js
  • local module: ./a.js
  • node module: ./node_modules/a/index.js

In the above setup, the code in both the local module and the node module is identical:

export default {
  foo: 'bar'
};

Splittlable works if my entry file looks like this (referencing the local module):

import a from './a';

console.log(a);

But it doesn't work if my entry file looks like this (referencing the node module):

import a from 'a';

console.log(a);

Here's terminal output:

java -jar /Users/philipwalton/.nvm/versions/node/v6.7.0/lib/node_modules/splittable/third_party/closure-compiler/closure-compiler-1.0-SNAPSHOT.jar --apply_input_source_maps true --compilation_level ADVANCED --create_source_map %outname%.map --externs /Users/philipwalton/.nvm/versions/node/v6.7.0/lib/node_modules/splittable/splittable.extern.js --jscomp_off accessControls --jscomp_off globalThis --jscomp_off misplacedTypeAnnotation --jscomp_off nonStandardJsDocs --jscomp_off suspiciousCode --jscomp_off uselessCode --language_in ES6 --language_out ES5 --module_output_path_prefix out/ --new_type_inf true --parse_inline_source_maps true --process_common_js_modules true --rewrite_polyfills true --source_map_location_mapping splittable-build/transformed/|/ --source_map_location_mapping splittable-build/browser/|/ --source_map_location_mapping |/ --js node_modules/a/package.json --js ../../../.nvm/versions/node/v6.7.0/lib/node_modules/splittable/base.js --js node_modules/a/index.js --js ./splittable-build/transformed/index.js --module index:4 --module_wrapper index:self.global=self;%s
//# sourceMappingURL=%basename%.map
 --js_module_root ./splittable-build/transformed/ --js_module_root ./splittable-build/browser/ --js_module_root ./

WARNING - Failed to load module "a.js"

./splittable-build/transformed/index.js:3:
Originally at:
splittable-build/transformed/index.js:3: ERROR - required "module$a" namespace never provided
import a from 'a';
^

1 error(s), 1 warning(s)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions