Skip to content

import umd module is undefined except file in node_modules #2586

@yangblink

Description

@yangblink

Version

3.0.1

Reproduction link

https://github.com/yangblink/vue-cli-umd-test

Node and OS info

Node v9.3.0 / npm 6.0.1/ macOS 10.13.1

Steps to reproduce

use vue-cli create a default project, and import a simple umd module umd.js,

umd.js

/* eslint-disable */
(function webpackUniversalModuleDefinition(root, factory) {
  if(typeof exports === 'object' && typeof module === 'object')
    module.exports = factory();
  else if(typeof define === 'function' && define.amd)
    define("bxs", [], factory);
  else if(typeof exports === 'object')
    exports["bxs"] = factory();
  else
    root["bxs"] = factory();
})(window, function() {
  return 'umd';
});

when the file in /node_modules it's work fine,
copy it to other folder except /node_modules, it's undefined

import localumd from './umd.js'
import moduleumd from '../node_modules/umd.copy.js'
console.log(localumd);  // undefined
console.log(moduleumd); // umd

What is expected?

umd module can be recognize in any floder

What is actually happening?

umd module can be recognize only in path /node_modules

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions