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

External global dependency not resolving #22

Closed
jd-carroll opened this issue Jan 19, 2015 · 1 comment
Closed

External global dependency not resolving #22

jd-carroll opened this issue Jan 19, 2015 · 1 comment

Comments

@jd-carroll
Copy link
Contributor

Not sure that this fixed the issue... (In reference to #15)

I am trying to create a bundle that has an external dependency of famous/famous. But I cannot seem to figure out how to list that as a dependency.

Famous does not list a main in their package.json, so I tried modifying it to:

  "main": "src/"

Then I ran:

$ pure-cjs -i ./src/my-main.js -s '{"famous": {"global": "famous", "amd": "famous/src"}}'

Error: Cannot find module 'famous' from 'c:\dev\famous-components\focus-scroll-view'
    at Function.module.exports [as sync] (c:\Users\Joseph Carroll\AppData\Roaming\npm\node_modules\pure-cjs\node_modules\resolve\lib\sync.js:35:11)
    at Object.exports.getNodePath (c:\Users\Joseph Carroll\AppData\Roaming\npm\node_modules\pure-cjs\lib\pathUtils.js:27:36)
    at ReplacerMap.<anonymous> (c:\Users\Joseph Carroll\AppData\Roaming\npm\node_modules\pure-cjs\lib\replacerMap.js:13:17)
    at Array.reduce (native)
    at new ReplacerMap (c:\Users\Joseph Carroll\AppData\Roaming\npm\node_modules\pure-cjs\lib\replacerMap.js:12:30)
    at Object.exports.transformAST (c:\Users\Joseph Carroll\AppData\Roaming\npm\node_modules\pure-cjs\lib\index.js:13:9)
    at Object.exports.transform (c:\Users\Joseph Carroll\AppData\Roaming\npm\node_modules\pure-cjs\lib\index.js:36:17)
    at Object.<anonymous> (c:\Users\Joseph Carroll\AppData\Roaming\npm\node_modules\pure-cjs\bin\pure-cjs.js:33:5)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)

Even though famous is installed and available under node_modules, it will fail because the resolver.sync will recusively iterate through the folders until it finds a package.json with a file or index.js.

So I created an index.js under src/ and require()'d all of the famous files. However, this still failed with:

$ pure-cjs -i ./src/my-main.js -s '{"famous": {"global": "famous", "amd": "famous/src"}}'

Error: Cannot find module 'famous/core/OptionsManager' from 'c:\dev\famous-components\focus-scroll-view\src'
    at Function.module.exports [as sync] (c:\Users\Joseph Carroll\AppData\Roaming\npm\node_modules\pure-cjs\node_modules\resolve\lib\sync.js:35:11)
    at Object.exports.getNodePath (c:\Users\Joseph Carroll\AppData\Roaming\npm\node_modules\pure-cjs\lib\pathUtils.js:27:36)
    at Replacer.getDependency (c:\Users\Joseph Carroll\AppData\Roaming\npm\node_modules\pure-cjs\lib\replacer.js:34:32)
    at Context.astTypes.visit.visitCallExpression (c:\Users\Joseph Carroll\AppData\Roaming\npm\node_modules\pure-cjs\lib\replacer.js:63:14)
    at Context.invokeVisitorMethod (c:\Users\Joseph Carroll\AppData\Roaming\npm\node_modules\pure-cjs\node_modules\ast-types\lib\path-visitor.js:259:43)
    at Visitor.PVp.visitWithoutReset (c:\Users\Joseph Carroll\AppData\Roaming\npm\node_modules\pure-cjs\node_modules\ast-types\lib\path-visitor.js:143:28)
    at visitChildren (c:\Users\Joseph Carroll\AppData\Roaming\npm\node_modules\pure-cjs\node_modules\ast-types\lib\path-visitor.js:179:21)
    at Visitor.PVp.visitWithoutReset (c:\Users\Joseph Carroll\AppData\Roaming\npm\node_modules\pure-cjs\node_modules\ast-types\lib\path-visitor.js:151:16)
    at NodePath.each (c:\Users\Joseph Carroll\AppData\Roaming\npm\node_modules\pure-cjs\node_modules\ast-types\lib\path.js:96:22)
    at visitChildren (c:\Users\Joseph Carroll\AppData\Roaming\npm\node_modules\pure-cjs\node_modules\ast-types\lib\path-visitor.js:162:14)

So instead of pointing directly to the source, I pointed the main to the UMD dist file:

  "main": "dist/famous-global.js"

This again failed with the same exception above. I'm not sure what I am doing wrong and I am a little lost at this point.

The project I am trying to build is here: jd-carroll/focus-scroll-view
If you clone the repository locally and run npm install you can follow the steps I've outlined above to reproduce the issue. Since the repository uses bower to manage the famous dependency, you will have to run the following modified script:

$ pure-cjs -i ./index.js -s '{"famous": {"global": "famous", "amd": "famous/src"}}' -d ./bower_components

Any assistance/guidance would be greatly appreciated.

Edit:
Note issue #23

@jd-carroll
Copy link
Contributor Author

So its looking like if you include a UMD external, it is assumed that it only contains a single file. Instead the resolver should inspect the file and load all sub-modules into the map.

@jd-carroll jd-carroll closed this as not planned Won't fix, can't repro, duplicate, stale Oct 7, 2022
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

1 participant