-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to compress the packaged files? #390
Comments
remove |
{17-12-23 19:21}Leung:~/workspace/parcel lynnleung% node -v
v8.9.1
{17-12-23 19:23}Leung:~/workspace/parcel lynnleung% cat package.json | grep parcel
"name": "parcel-demo",
"description": "A demo of parcel-bundle",
"parcel-bundler": "^1.3.0",
"parcel-plugin-url-loader": "^1.0.3", |
@albinotonnina {17-12-23 19:49}Leung:~/workspace/parcel lynnleung% npm run build
> parcel-demo@1.0.0 build /Users/lynnleung/workspace/parcel
> NODE_ENV=production && parcel build index.js
🚨 /Users/lynnleung/workspace/parcel/index.js: Couldn't find preset "env" relative to directory "/Users at /Users/lynnleung/.config/yarn/global/node_modules/babel-core/lib/transformation/file/options/option-manager.js:293:19
at Array.map (<anonymous>)
at OptionManager.resolvePresets (/Users/lynnleung/.config/yarn/global/node_modules/babel-core/lib/transformation/file/options/option-manager.js:275:20)
at OptionManager.mergePresets (/Users/lynnleung/.config/yarn/global/node_modules/babel-core/lib/transformation/file/options/option-manager.js:264:10)
at OptionManager.mergeOptions (/Users/lynnleung/.config/yarn/global/node_modules/babel-core/lib/transformation/file/options/option-manager.js:249:14)
at OptionManager.init (/Users/lynnleung/.config/yarn/global/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12)
at File.initOptions (/Users/lynnleung/.config/yarn/global/node_modules/babel-core/lib/transformation/file/index.js:212:65)
at new File (/Users/lynnleung/.config/yarn/global/node_modules/babel-core/lib/transformation/file/index.js:135:24)
at JSAsset.parse (/Users/lynnleung/.config/yarn/global/node_modules/parcel-bundler/src/assets/JSAsset.js:52:20)
at <anonymous> the .babelrc: {
"presets": ["env"],
"env": {
"production": {
"presets": ["es2015"]
}
}
} |
ok, i built another demo: {
"name": "parcel-demo",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "NODE_ENV=production && parcel build index.html",
"dev": "parcel index.html"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"autoprefixer": "^7.2.3",
"babel-preset-env": "^1.6.1",
"parcel-bundler": "^1.3.0",
"postcss-modules": "^1.1.0"
}
} without any configures. // modules are defined as an array
// [ module function, map of requires ]
//
// map of requires is short require name -> numeric require
//
// anything defined in a previous bundle is accessed via the
// orig method which is the require for previous bundles
require = (function (modules, cache, entry) {
// Save the require from previous bundle to this closure if any
var previousRequire = typeof require === "function" && require;
function newRequire(name, jumped) {
if (!cache[name]) {
if (!modules[name]) {
// if we cannot find the module within our internal map or
// cache jump to the current global require ie. the last bundle
// that was added to the page.
var currentRequire = typeof require === "function" && require;
if (!jumped && currentRequire) {
return currentRequire(name, true);
}
// If there are other bundles on this page the require from the
// previous one is saved to 'previousRequire'. Repeat this as
// many times as there are bundles until the module is found or
// we exhaust the require chain.
if (previousRequire) {
return previousRequire(name, true);
}
var err = new Error('Cannot find module \'' + name + '\'');
err.code = 'MODULE_NOT_FOUND';
throw err;
}
localRequire.resolve = resolve;
var module = cache[name] = new newRequire.Module;
modules[name][0].call(module.exports, localRequire, module, module.exports);
}
return cache[name].exports;
function localRequire(x){
return newRequire(localRequire.resolve(x));
}
function resolve(x){
return modules[name][1][x] || x;
}
}
function Module() {
this.bundle = newRequire;
this.exports = {};
}
newRequire.Module = Module;
newRequire.modules = modules;
newRequire.cache = cache;
newRequire.parent = previousRequire;
for (var i = 0; i < entry.length; i++) {
newRequire(entry[i]);
}
// Override the current require with this new one
return newRequire;
})({4:[function(require,module,exports) {
console.log('hello, parcel.')
},{}]},{},[4]) |
Yes, I have the same problem. The creators of parcel would be better to create a starter with minimal settings. Where you could see how to set everything up correctly. |
@orzechowskid console.log('hello, parcel.')
[1,2,3,4,5].map(value => {
console.log(value)
})
(() => {
const root = document.getElementById('root')
let newLine = document.createElement('p')
newLine.innerText = 'This text is from js.'
root.appendChild(newLine)
})() and this is the packaged code: ...
// ↓ It seems to be wrong here.
console.log('hello, parcel.')[(1, 2, 3, 4, 5)].map(function (value) {
console.log(value);
})(function () {
var root = document.getElementById('root');
var newLine = document.createElement('p');
newLine.innerText = 'This text is from js.';
root.appendChild(newLine);
})();
... and my browser throw an error (look at the pic):
|
console.log('hello, parcel.')[(1, 2, 3, 4, 5)].map(function (value) {
console.log(value);
} This code will work if you add a semicolon after edit: You also need to add a semicolon after your map function for this to work properly. I think the rule is to never start a line with |
Closing, looks like you figured out the problem. We'll handle minifying the prelude in #334. |
@jorgegonzalez |
after running the script :
parcel build index.html --no-minify
the packaged files are not compressed.
how to compress them ?
The text was updated successfully, but these errors were encountered: