[英]Webpack: cannot reach my imported module
The problem: 问题:
My webpack config file: 我的webpack配置文件:
module.exports = {
entry: {
// Entry points for pages:
signup: './signup.js',
activate: './activate.js'
},
output: {
path: __dirname + '/build',
filename: '[name].page.bundle.js',
},
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel',
exclude: /node_modules/,
},
{
test: /\.json$/,
loader: 'json',
},
{
test: /\.vue$/,
loader: 'vue',
}
],
},
vue: {
loaders: {
js: 'babel',
}
},
resolve: {
alias: {vue: 'vue/dist/vue.js'}
},
};
Signup.js: Signup.js:
import Vue from 'vue';
import _ from 'lodash';
import axios from 'axios';
import Signup from './vue-components/page-signup-form.vue';
import UrlFunctions from './js/urlFunctions';
if (typeof UrlFunctions === "undefined") {
console.log("Still not reachable!");
}
Outputs: "Still not reachable" 输出:“仍然无法到达”
excerpt from bundle.js: 摘自bundle.js:
...
var UrlFunctions = exports.UrlFunctions = {
...
In the module file it's correctly exported. 在模块文件中,它已正确导出。
I don't have one clue. 我没有任何线索。
I have created a single file like: 我创建了一个文件,例如:
// sg.js
export var sg = "something";
I tried to import that in my entry file, the signup.js and this also wasn't declared! 我试图将其导入到我的输入文件signup.js中,但也未声明! ...
...
npm-deps: npm-deps:
"devDependencies": {
"babel-core": "^6.20.0",
"babel-loader": "^6.2.9",
"babel-plugin-transform-runtime": "^6.15.0",
"babel-preset-es2015": "^6.18.0",
"babel-runtime": "^6.20.0",
"css-loader": "^0.26.1",
"json-loader": "^0.5.4",
"script-loader": "^0.7.0",
"vue-loader": "^10.0.2",
"vue-template-compiler": "^2.1.6",
"webpack": "^1.14.0"
},
"dependencies": {
"axios": "^0.15.3",
"lodash": "^4.17.2",
"vue": "^2.1.6"
}
It seems that for some reason when exporting a module: 似乎出于某种原因导出模块时:
export myModule; // nOK
export { myModule }; // nOK
export default myModule; // OK!
module.exports = myModule; // OK!
include
the folder for Babel from I am importing the Module from: didn't help. include
Babel的文件夹:没有帮助。 It's welcome if you have any insight on that. 如果您对此有任何见解,欢迎您。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.