Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

Using modulesOnly: true triggers unresolved dependency even when target defines module entry #200

Closed
natevw opened this issue Mar 26, 2019 · 4 comments

Comments

@natevw
Copy link

natevw commented Mar 26, 2019

I am compiling code like this:

import { render } from 'preact';   // @10.0.0-alpha.2

Using this via --config rollup.config.mjs:

import resolve from 'rollup-plugin-node-resolve';

export default {
  plugins: [ resolve({
    browser: true,
    modulesOnly: true
  }) ]
}

Preact's package.json includes:

  "module": "dist/preact.mjs",

But I still get an error:

(!) Unresolved dependencies
https://rollupjs.org/guide/en#warning-treating-module-as-external-dependency
preact (imported by myfile.mjs)

@natevw
Copy link
Author

natevw commented Mar 26, 2019

UPDATE: this doesn't work — see later comment.


Turns out this is due to #144 (comment). If I add the .mjs extension to my config, the error goes away:

import resolve from 'rollup-plugin-node-resolve';

export default {
  plugins: [ resolve({
    browser: true,
    modulesOnly: true,
    extensions: [ '.mjs', '.js']
  }) ]
}

(A preact workaround for this sort of behavior would also avoid this gotcha: preactjs/preact#1425)

@natevw natevw closed this as completed Mar 26, 2019
@natevw natevw reopened this Mar 26, 2019
@natevw
Copy link
Author

natevw commented Mar 26, 2019

I spoke to soon. Not sure what I was testing, but adding .mjs as a supported extension does not fix this after all 🙁

@natevw
Copy link
Author

natevw commented Mar 26, 2019

Looks like preact is exporting multiple items, which is probably breaking isModule: component/is-module#3

@dima-takoy-zz
Copy link

I tried to reproduce it with the latest versions. All works perfectly! Repro here: https://github.com/mecurc/200-rollup-issue

Used versions:

"preact": "10.0.0-beta.1",
"rollup": "^1.11.3",
"rollup-plugin-node-resolve": "^4.2.3"

Console output:

$ rollup -c

src/index.js → dist/bundle.js...
created dist/bundle.js in 278ms
Done in 0.71s

Can be closed now.

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

No branches or pull requests

3 participants