Skip to content
This repository has been archived by the owner on Jan 18, 2022. It is now read-only.

Cannot import Vue SFC from current working directory #418

Open
adamchipperfield opened this issue Dec 6, 2020 · 2 comments
Open

Cannot import Vue SFC from current working directory #418

adamchipperfield opened this issue Dec 6, 2020 · 2 comments

Comments

@adamchipperfield
Copy link

adamchipperfield commented Dec 6, 2020

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
Copy link
Author

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
Copy link
Author

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

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

1 participant