rollup-plugin-vue icon indicating copy to clipboard operation
rollup-plugin-vue copied to clipboard

Cannot import Vue SFC from current working directory

Open adamchipperfield opened this issue 4 years ago • 2 comments

Version

5.0.0

Reproduction link

https://codesandbox.io/s/stupefied-shirley-39f24

Steps to reproduce

Build index.js into the dist folder. Run the bundled index.bundle.js file in a node folder with an App.vue file in the root.

What is expected?

To import the App.vue file without error

What is actually happening?

Error is thrown: "SyntaxError: Unexpected token '<'". It specifically points to the "<" in the opening <template> tag. In short, a bundled script I'm running doesn't import from the directory where the script was invoked.


The App.vue is pulling from the CWD which may have an issue, but it still runs through rollup with this plugin. Woth noting this is for a CLI but that shouldn't make a difference.

adamchipperfield avatar Dec 06 '20 14:12 adamchipperfield

Bundled file attached...


Object.defineProperty(exports, '__esModule', { value: true });

function _interopNamespace(e) {
  if (e && e.__esModule) return e;
  var n = Object.create(null);
  if (e) {
    Object.keys(e).forEach(function (k) {
      if (k !== 'default') {
        var d = Object.getOwnPropertyDescriptor(e, k);
        Object.defineProperty(n, k, d.get ? d : {
          enumerable: true,
          get: function () {
            return e[k];
          }
        });
      }
    });
  }
  n['default'] = e;
  return Object.freeze(n);
}

const run = async () => {
  Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(`${process.cwd()}/App.vue`)); })
    .then((response) => {
      console.log(response);
    })
    .catch((error) => {
      console.log(error);
    });
};

exports.run = run;

adamchipperfield avatar Dec 06 '20 14:12 adamchipperfield

Also, when doing the same but from the src directory it works fine... just not from CWD.

adamchipperfield avatar Dec 06 '20 14:12 adamchipperfield