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

Question: Any advice on how to get this working with rollup-plugin-skypack? #39

Open
tropicalraisel opened this issue Sep 2, 2021 · 1 comment

Comments

@tropicalraisel
Copy link

tropicalraisel commented Sep 2, 2021

I'm trying to use this alongside rollup-plugin-skypin, and have my snowpack config set up like so:

snowpack.config.mjs

// Snowpack Configuration File
// See all supported options: https://www.snowpack.dev/reference/configuration
import { skypin } from 'rollup-plugin-skypin';

/** @type {import("snowpack").SnowpackUserConfig } */
export default {
  mount: {
    src: '/src/'
  },
  plugins: [
    [
      "snowpack-plugin-rollup-bundle",
      {
        extendConfig: (config) => {
          config.inputOptions.plugins.push(skypin())
          config.inputOptions.input = 'index.js'
          config.outputOptions.file = 'dist/index.js'
          config.outputOptions.format = 'esm'
          return config
        }
      }
    ]
  ],
  packageOptions: {
    /* rollup: {
      options: {
        input: 'src/index.js',
        output: {
          file: 'dist/index.js',
          format: 'esm'
        }
      }
    } */
  },
  devOptions: {
    /* ... */
  },
  buildOptions: {
    clean: true
  },
};

And keep getting this error:

[17:48:10] [snowpack] ! optimizing build...
Error fetching module from skypack. Returning empty strings
ReferenceError: fetch is not defined
    at fetchSkypack (file:///C:/test/node_modules/skypin/dist/browser.mjs:52:22)
    at lookup (file:///C:/test/node_modules/skypin/dist/browser.mjs:47:61)
    at skypin (file:///C:/test/node_modules/skypin/dist/browser.mjs:40:18)
    at Object.resolveId (file:///C:/test/node_modules/rollup-plugin-skypin/dist/index.mjs:27:31)
    at C:\test\node_modules\rollup\dist\shared\rollup.js:20218:25
[17:48:10] [snowpack-plugin-rollup-bundle] Error: Entry module cannot be external (index.js).
error Command failed with exit code 1.

Using Yarn 1.
Is there a way to get this working?

@tropicalraisel
Copy link
Author

I'm now getting a successful build with this config file:

// Snowpack Configuration File
// See all supported options: https://www.snowpack.dev/reference/configuration
import { skypin } from 'rollup-plugin-skypin';
import resolve from 'rollup-plugin-node-resolve';

/** @type {import("snowpack").SnowpackUserConfig } */
export default {
  mount: {
    src: { url: '/', resolve: false }
  },
  plugins: [
    /* ... */
    [
      "snowpack-plugin-rollup-bundle",
      {
        extendConfig: (config) => {
          config.inputOptions.plugins.push(skypin())
          config.inputOptions.input = 'src/index.js'
          config.outputOptions.format = 'esm'
          return config
        }
      }
    ]
  ],
  packageOptions: {
    NODE_ENV: true,
    rollup: {
      plugins: [
        resolve()
      ]
    },
  },
  devOptions: {
    out: "build/snowpacker",
    open: "none",
    bundle: true,
    baseUrl: "/snowpacker",
  },
  buildOptions: {
    clean: true
  },
};

However the ReferenceError section still occurs, and no urls are being added to the file. Anyone have any ideas?

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