Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
philipwalton opened this issue Jan 1, 2017 · 2 comments
Open

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

philipwalton opened this issue Jan 1, 2017 · 2 comments

Comments

@philipwalton
Copy link

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)
@philipwalton
Copy link
Author

I should mention that if I rewrite the modules to use CommonJS syntax, both variations work. For example:

In ./a and ./node_modules/a/index.js:

module.exports = {
  foo: 'bar'
};

In ./index:

const a = require('a');

console.log(a);

@cramforce
Copy link
Owner

cramforce commented Jan 1, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants