seia-soto / snowpack-plugin-import-map

A snowpack plugin that maps your imports to Skypack or other sources.
https://zhoukekestar.github.io/notes/2020/06/08/micro-frontends.html
MIT License
39 stars 3 forks source link

error: loaded in both `scripts` and `plugins` #2

Closed Paosder closed 4 years ago

Paosder commented 4 years ago

I added this plugin with same manner of Readme, but error occurs.

[snowpack-plugin-import-map]: loaded in both scripts and plugins. Please choose one (preferably plugins).

Here's my snowpack.config.js-

module.exports = {
  extends: '@snowpack/app-scripts-react',
  plugins: [
    ['snowpack-plugin-import-map', {
      react: 'https://cdn.pika.dev/react@^16.13.1',
      'react-dom': 'https://cdn.pika.dev/react-dom@^16.13.1',
    }],
  ],
  scripts: {
    'build:js,jsx,ts,tsx': 'snowpack-plugin-import-map',
  },
  devOptions: {
    port: 8040,
    open: 'none',
  },
  buildOptions: {
    clean: true,
    sourceMaps: true,
  },
  mount: {
    src: '/assets',
    public: '/',
  },
};

It seems it loads twice so I removed in plugins key, then another error occurs. Might be snowpack issue?

[snowpack-plugin-import-map] "load" method found but "resolve()" config missing.

zhoukekestar commented 4 years ago

Can you add some log in this file: https://github.com/zhoukekestar/snowpack-plugin-import-map/blob/master/babel-plugin.js, and checkout what's going on ? I have no idea on this issue... OR maybe just mismatch the wrong snowpack version?

Paosder commented 4 years ago

@zhoukekestar Okay, I found it crashes with latest snowpack(^2.10) because of some changes in plugin system. I resolved this issue via modifying some code of index.js. If you don't mind, I will make PR to address this issue. However, resolving this issue brings some changes in configuration, therefore previous developers must modify their config. I will write more details in PR.

zhoukekestar commented 4 years ago

Thanks for your PR~ By the way, I'm try using jspm.dev to be my esm loader.

Paosder commented 4 years ago

Cool! Oh, we need to modify readme so that other people could know its change, then finally publish it to npm.

zhoukekestar commented 4 years ago

Done