Module not found but still works
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 30/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- javascript
- Lĩnh vực
- build-system, tooling
Hướng nghiên cứu
Bắt đầu bằng việc tái tạo các bundle đã tạo bằng script biên dịch gulp được đăng, Browserify, factor-bundle và hai entry của trang. Kiểm tra ánh xạ module được tạo xung quanh jquery require và so sánh các bundle của homepage và product; hoàn tất có nghĩa là homepage không còn báo thiếu module và cả hai trang vẫn tiếp tục hoạt động.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Hi,
I've got a strange behavior with my scripts.
I have 2 JS files : home.js and product.js for the concerned page.
Both require the common.js file, it works fine on the product page but on the homepage I have this error :
"Uncaught Error: Cannot find module '51'"
More about this error :
var _jquery = require('jquery');
var _jquery2 = _interopRequireDefault(_jquery);
var _common = require('../common/common.js');
var _common2 = _interopRequireDefault(_common);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : {'default':obj}; }
(0, _jquery2['default'])(function () {
_common2['default'].init();
});
},{"../common/common.js":88,"jquery":51}]},{},[89]);
But, the JS still works. When I look further on the console, it's apparently the first module I have imported in the home.js script (jquery).
Here is my compilation script:
'use strict';
const __DEV__ = process.argv.indexOf('--dev') > -1;
const fs = require('fs');
const path = require('path');
const gulp = require('gulp');
const notify = require('gulp-notify');
const plumber = require('gulp-plumber');
const browserify = require('browserify');
const babelify = require('babelify');
const watchify = require('watchify');
const replace = require('gulp-replace');
const gutil = require('gulp-util');
module.exports = function(config, prefix) {
return function() {
const folders = fs.readdirSync('./src/pages');
const files = folders.reduce((acc, folder) => {
if (folder != 'common') {
acc.entries.push(path.join(__dirname, `../src/pages/${folder}/${folder}.js`));
acc.outputs.push(path.join(__dirname, `../dist/assets/scripts/${folder}.bundle.js`));
}
return acc;
}, { entries: [], outputs: [] });
const stream = browserify({
entries: files.entries,
cache: {},
packageCache: {},
})
.transform('babelify', { presets: ['es2015'] })
.plugin(watchify)
.plugin('factor-bundle', {
outputs: files.outputs,
})
stream.on('update', bundle);
return bundle();
function bundle() {
return stream
.bundle()
.on('error', e => {
gutil.log(gutil.colors.red('Bundle error:', e.message));
})
.pipe(fs.createWriteStream(`${config.distOutputPath}/common.bundle.js`))
.on('finish', () => {
return gulp.src(config.distPath)
.pipe(replace(/var-/g, prefix + '-'))
.pipe(replace(/\.default(?=\.|\;|\)|\,|\(|\s)/g,"['default']"))
.pipe(replace(/\{ default: obj }/g,"{'default':obj}"))
.pipe(gulp.dest(config.distOutputPath))
.pipe(notify('Scripts task end'));
});
}
};
}
I work on Windows 7 with Node.js v4.2.
- Ngôn ngữ chính
- JavaScript
- Star
- 397
- Fork
- 24
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của browserify/factor-bundle
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 32/100
browserify/factor-bundle#95 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 30/100
browserify/factor-bundle#94 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
browserify/factor-bundle#92 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
browserify/factor-bundle#83 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
browserify/factor-bundle#82 · 3 reaction ·
Tất cả issue của browserify/factor-bundle
Issue tương tự
-
Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Automattic/safe-publish#594 ·
-
内部文件键(绝对路径的 base64)泄漏到界面标签 Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
dream-num/dsh-univer-office#104 ·
-
comp/dashboard invalid P3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
NousResearch/hermes-agent#121143 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
avniproject/avni-webapp#1811 ·
-
area/auroraboot area/webui bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100