Rollup Babel duplicate definitions in output file












1















I'm trying to use rollup with babel but in output file I got duplicate definitions:



 var Projection =
/*#__PURE__*/
function () {
/**
* @param {Options} options Projection options.
*/
function Projection(options) {
_classCallCheck(this, Projection);

/**
* @private
* @type {string}
*/
this.code_ = options.code;


and



var Projection$1 = function Projection(options) {
/**
* @private
* @type {string}
*/
this.code_ = options.code;

/**
* Units of projected coordinates. When set to `TILE_PIXELS`, a
* `this.extent_` and `this.worldExtent_` must be configured properly for each
* tile.
* @private
* @type {module:ol/proj/Units}
*/
this.units_ = /** @type {module:ol/proj/Units} */ (options.units);


My rollup config



// Rollup configuration for the full build

const path = require('path');
import noderesolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import {uglify} from 'rollup-plugin-uglify';
import sourcemaps from 'rollup-plugin-sourcemaps';
import babel from 'rollup-plugin-babel';
import alias from 'rollup-plugin-alias';
import minify from 'rollup-plugin-babel-minify';

const prod = process.env.BUILD === 'production';
const cesiumSource = 'node_modules/cesium/Source';
//const cesiumSource = 'Source/Cesium';
const olSource = 'ol_build/openlayers/src/ol';

const plugins = [
noderesolve(),
commonjs(),
];

// const uglifyPlugin = uglify({
// compress: {
// sequences: false, // workaround uglify bug with sequences
// drop_console: true
// }
// });

const babelPlugin = babel({
babelrc: false,
presets: [["@babel/preset-env", { modules: false }]],
exclude: ['node_modules/**']
// externalHelpers: true,
// plugins: ["@babel/external-helpers"]
// runtimeHelpers: true,
// plugins: ["@babel/plugin-transform-runtime"]
});

const aliasPlugin = alias({
ol: path.resolve(__dirname, olSource),
Cesium: path.resolve(__dirname, cesiumSource)
});

if (prod) {
//plugins.push(uglifyPlugin);
//plugins.push(minify);
}

plugins.push(babelPlugin);
plugins.push(aliasPlugin);
plugins.push(sourcemaps());

export default {
input: './dist/index.js',
output: [
{file: prod ? './dist/ol.js' : './dist/ol-debug.js', format: 'iife', sourcemap: true}
],
plugins
//external: ['ol'],
};


and package.json config related to babel and rollup:



"devDependencies": {
"@babel/core": "^7.1.2",
"@babel/preset-env": "^7.1.0",
"rollup": "0.65.2",
"rollup-plugin-babel": "^4.0.3",
"rollup-plugin-babel-minify": "^6.1.1",
"rollup-plugin-commonjs": "9.1.6",
"rollup-plugin-node-resolve": "3.4.0",
"rollup-plugin-sourcemaps": "0.4.2",
"rollup-plugin-uglify": "5.0.2",

"dependencies": {
"rollup-plugin-alias": "^1.4.0"
}


When I use only rollup without babel in output file there is only 1 definition of "Projection".



Original class:



class Projection {

/**
* @param {Options} options Projection options.
*/
constructor(options) {
/**
* @private
* @type {string}
*/
this.code_ = options.code;

/**
* Units of projected coordinates. When set to `TILE_PIXELS`, a
* `this.extent_` and `this.worldExtent_` must be configured properly for each
* tile.
* @private
* @type {import("./Units.js").default}
*/
this.units_ = /** @type {import("./Units.js").default} */ (options.units);


I tried use previous version of babel for rollup and also tried use "external-helpers" plugin but still not work.



Rollup and babel are new for me.



Because of those duplicate definitions I got false when compare types with instanceof operator. Why there are duplicate definitions and how configure babel to get only one definition?










share|improve this question























  • had the same issue, I ended up patching after the build script via sed. I have also noticed that this happens only if the current build includes a module that a submodule includes too. If the project is included from a third module, the duplication disappears (at least in my case). This seems to be a resolution issue, maybe filing a bug to the plugin developer might help more.

    – Andrea Giammarchi
    Dec 17 '18 at 11:39
















1















I'm trying to use rollup with babel but in output file I got duplicate definitions:



 var Projection =
/*#__PURE__*/
function () {
/**
* @param {Options} options Projection options.
*/
function Projection(options) {
_classCallCheck(this, Projection);

/**
* @private
* @type {string}
*/
this.code_ = options.code;


and



var Projection$1 = function Projection(options) {
/**
* @private
* @type {string}
*/
this.code_ = options.code;

/**
* Units of projected coordinates. When set to `TILE_PIXELS`, a
* `this.extent_` and `this.worldExtent_` must be configured properly for each
* tile.
* @private
* @type {module:ol/proj/Units}
*/
this.units_ = /** @type {module:ol/proj/Units} */ (options.units);


My rollup config



// Rollup configuration for the full build

const path = require('path');
import noderesolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import {uglify} from 'rollup-plugin-uglify';
import sourcemaps from 'rollup-plugin-sourcemaps';
import babel from 'rollup-plugin-babel';
import alias from 'rollup-plugin-alias';
import minify from 'rollup-plugin-babel-minify';

const prod = process.env.BUILD === 'production';
const cesiumSource = 'node_modules/cesium/Source';
//const cesiumSource = 'Source/Cesium';
const olSource = 'ol_build/openlayers/src/ol';

const plugins = [
noderesolve(),
commonjs(),
];

// const uglifyPlugin = uglify({
// compress: {
// sequences: false, // workaround uglify bug with sequences
// drop_console: true
// }
// });

const babelPlugin = babel({
babelrc: false,
presets: [["@babel/preset-env", { modules: false }]],
exclude: ['node_modules/**']
// externalHelpers: true,
// plugins: ["@babel/external-helpers"]
// runtimeHelpers: true,
// plugins: ["@babel/plugin-transform-runtime"]
});

const aliasPlugin = alias({
ol: path.resolve(__dirname, olSource),
Cesium: path.resolve(__dirname, cesiumSource)
});

if (prod) {
//plugins.push(uglifyPlugin);
//plugins.push(minify);
}

plugins.push(babelPlugin);
plugins.push(aliasPlugin);
plugins.push(sourcemaps());

export default {
input: './dist/index.js',
output: [
{file: prod ? './dist/ol.js' : './dist/ol-debug.js', format: 'iife', sourcemap: true}
],
plugins
//external: ['ol'],
};


and package.json config related to babel and rollup:



"devDependencies": {
"@babel/core": "^7.1.2",
"@babel/preset-env": "^7.1.0",
"rollup": "0.65.2",
"rollup-plugin-babel": "^4.0.3",
"rollup-plugin-babel-minify": "^6.1.1",
"rollup-plugin-commonjs": "9.1.6",
"rollup-plugin-node-resolve": "3.4.0",
"rollup-plugin-sourcemaps": "0.4.2",
"rollup-plugin-uglify": "5.0.2",

"dependencies": {
"rollup-plugin-alias": "^1.4.0"
}


When I use only rollup without babel in output file there is only 1 definition of "Projection".



Original class:



class Projection {

/**
* @param {Options} options Projection options.
*/
constructor(options) {
/**
* @private
* @type {string}
*/
this.code_ = options.code;

/**
* Units of projected coordinates. When set to `TILE_PIXELS`, a
* `this.extent_` and `this.worldExtent_` must be configured properly for each
* tile.
* @private
* @type {import("./Units.js").default}
*/
this.units_ = /** @type {import("./Units.js").default} */ (options.units);


I tried use previous version of babel for rollup and also tried use "external-helpers" plugin but still not work.



Rollup and babel are new for me.



Because of those duplicate definitions I got false when compare types with instanceof operator. Why there are duplicate definitions and how configure babel to get only one definition?










share|improve this question























  • had the same issue, I ended up patching after the build script via sed. I have also noticed that this happens only if the current build includes a module that a submodule includes too. If the project is included from a third module, the duplication disappears (at least in my case). This seems to be a resolution issue, maybe filing a bug to the plugin developer might help more.

    – Andrea Giammarchi
    Dec 17 '18 at 11:39














1












1








1








I'm trying to use rollup with babel but in output file I got duplicate definitions:



 var Projection =
/*#__PURE__*/
function () {
/**
* @param {Options} options Projection options.
*/
function Projection(options) {
_classCallCheck(this, Projection);

/**
* @private
* @type {string}
*/
this.code_ = options.code;


and



var Projection$1 = function Projection(options) {
/**
* @private
* @type {string}
*/
this.code_ = options.code;

/**
* Units of projected coordinates. When set to `TILE_PIXELS`, a
* `this.extent_` and `this.worldExtent_` must be configured properly for each
* tile.
* @private
* @type {module:ol/proj/Units}
*/
this.units_ = /** @type {module:ol/proj/Units} */ (options.units);


My rollup config



// Rollup configuration for the full build

const path = require('path');
import noderesolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import {uglify} from 'rollup-plugin-uglify';
import sourcemaps from 'rollup-plugin-sourcemaps';
import babel from 'rollup-plugin-babel';
import alias from 'rollup-plugin-alias';
import minify from 'rollup-plugin-babel-minify';

const prod = process.env.BUILD === 'production';
const cesiumSource = 'node_modules/cesium/Source';
//const cesiumSource = 'Source/Cesium';
const olSource = 'ol_build/openlayers/src/ol';

const plugins = [
noderesolve(),
commonjs(),
];

// const uglifyPlugin = uglify({
// compress: {
// sequences: false, // workaround uglify bug with sequences
// drop_console: true
// }
// });

const babelPlugin = babel({
babelrc: false,
presets: [["@babel/preset-env", { modules: false }]],
exclude: ['node_modules/**']
// externalHelpers: true,
// plugins: ["@babel/external-helpers"]
// runtimeHelpers: true,
// plugins: ["@babel/plugin-transform-runtime"]
});

const aliasPlugin = alias({
ol: path.resolve(__dirname, olSource),
Cesium: path.resolve(__dirname, cesiumSource)
});

if (prod) {
//plugins.push(uglifyPlugin);
//plugins.push(minify);
}

plugins.push(babelPlugin);
plugins.push(aliasPlugin);
plugins.push(sourcemaps());

export default {
input: './dist/index.js',
output: [
{file: prod ? './dist/ol.js' : './dist/ol-debug.js', format: 'iife', sourcemap: true}
],
plugins
//external: ['ol'],
};


and package.json config related to babel and rollup:



"devDependencies": {
"@babel/core": "^7.1.2",
"@babel/preset-env": "^7.1.0",
"rollup": "0.65.2",
"rollup-plugin-babel": "^4.0.3",
"rollup-plugin-babel-minify": "^6.1.1",
"rollup-plugin-commonjs": "9.1.6",
"rollup-plugin-node-resolve": "3.4.0",
"rollup-plugin-sourcemaps": "0.4.2",
"rollup-plugin-uglify": "5.0.2",

"dependencies": {
"rollup-plugin-alias": "^1.4.0"
}


When I use only rollup without babel in output file there is only 1 definition of "Projection".



Original class:



class Projection {

/**
* @param {Options} options Projection options.
*/
constructor(options) {
/**
* @private
* @type {string}
*/
this.code_ = options.code;

/**
* Units of projected coordinates. When set to `TILE_PIXELS`, a
* `this.extent_` and `this.worldExtent_` must be configured properly for each
* tile.
* @private
* @type {import("./Units.js").default}
*/
this.units_ = /** @type {import("./Units.js").default} */ (options.units);


I tried use previous version of babel for rollup and also tried use "external-helpers" plugin but still not work.



Rollup and babel are new for me.



Because of those duplicate definitions I got false when compare types with instanceof operator. Why there are duplicate definitions and how configure babel to get only one definition?










share|improve this question














I'm trying to use rollup with babel but in output file I got duplicate definitions:



 var Projection =
/*#__PURE__*/
function () {
/**
* @param {Options} options Projection options.
*/
function Projection(options) {
_classCallCheck(this, Projection);

/**
* @private
* @type {string}
*/
this.code_ = options.code;


and



var Projection$1 = function Projection(options) {
/**
* @private
* @type {string}
*/
this.code_ = options.code;

/**
* Units of projected coordinates. When set to `TILE_PIXELS`, a
* `this.extent_` and `this.worldExtent_` must be configured properly for each
* tile.
* @private
* @type {module:ol/proj/Units}
*/
this.units_ = /** @type {module:ol/proj/Units} */ (options.units);


My rollup config



// Rollup configuration for the full build

const path = require('path');
import noderesolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import {uglify} from 'rollup-plugin-uglify';
import sourcemaps from 'rollup-plugin-sourcemaps';
import babel from 'rollup-plugin-babel';
import alias from 'rollup-plugin-alias';
import minify from 'rollup-plugin-babel-minify';

const prod = process.env.BUILD === 'production';
const cesiumSource = 'node_modules/cesium/Source';
//const cesiumSource = 'Source/Cesium';
const olSource = 'ol_build/openlayers/src/ol';

const plugins = [
noderesolve(),
commonjs(),
];

// const uglifyPlugin = uglify({
// compress: {
// sequences: false, // workaround uglify bug with sequences
// drop_console: true
// }
// });

const babelPlugin = babel({
babelrc: false,
presets: [["@babel/preset-env", { modules: false }]],
exclude: ['node_modules/**']
// externalHelpers: true,
// plugins: ["@babel/external-helpers"]
// runtimeHelpers: true,
// plugins: ["@babel/plugin-transform-runtime"]
});

const aliasPlugin = alias({
ol: path.resolve(__dirname, olSource),
Cesium: path.resolve(__dirname, cesiumSource)
});

if (prod) {
//plugins.push(uglifyPlugin);
//plugins.push(minify);
}

plugins.push(babelPlugin);
plugins.push(aliasPlugin);
plugins.push(sourcemaps());

export default {
input: './dist/index.js',
output: [
{file: prod ? './dist/ol.js' : './dist/ol-debug.js', format: 'iife', sourcemap: true}
],
plugins
//external: ['ol'],
};


and package.json config related to babel and rollup:



"devDependencies": {
"@babel/core": "^7.1.2",
"@babel/preset-env": "^7.1.0",
"rollup": "0.65.2",
"rollup-plugin-babel": "^4.0.3",
"rollup-plugin-babel-minify": "^6.1.1",
"rollup-plugin-commonjs": "9.1.6",
"rollup-plugin-node-resolve": "3.4.0",
"rollup-plugin-sourcemaps": "0.4.2",
"rollup-plugin-uglify": "5.0.2",

"dependencies": {
"rollup-plugin-alias": "^1.4.0"
}


When I use only rollup without babel in output file there is only 1 definition of "Projection".



Original class:



class Projection {

/**
* @param {Options} options Projection options.
*/
constructor(options) {
/**
* @private
* @type {string}
*/
this.code_ = options.code;

/**
* Units of projected coordinates. When set to `TILE_PIXELS`, a
* `this.extent_` and `this.worldExtent_` must be configured properly for each
* tile.
* @private
* @type {import("./Units.js").default}
*/
this.units_ = /** @type {import("./Units.js").default} */ (options.units);


I tried use previous version of babel for rollup and also tried use "external-helpers" plugin but still not work.



Rollup and babel are new for me.



Because of those duplicate definitions I got false when compare types with instanceof operator. Why there are duplicate definitions and how configure babel to get only one definition?







javascript npm babel rollup






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 14 '18 at 14:32









Arkadiusz BednarowskiArkadiusz Bednarowski

314




314













  • had the same issue, I ended up patching after the build script via sed. I have also noticed that this happens only if the current build includes a module that a submodule includes too. If the project is included from a third module, the duplication disappears (at least in my case). This seems to be a resolution issue, maybe filing a bug to the plugin developer might help more.

    – Andrea Giammarchi
    Dec 17 '18 at 11:39



















  • had the same issue, I ended up patching after the build script via sed. I have also noticed that this happens only if the current build includes a module that a submodule includes too. If the project is included from a third module, the duplication disappears (at least in my case). This seems to be a resolution issue, maybe filing a bug to the plugin developer might help more.

    – Andrea Giammarchi
    Dec 17 '18 at 11:39

















had the same issue, I ended up patching after the build script via sed. I have also noticed that this happens only if the current build includes a module that a submodule includes too. If the project is included from a third module, the duplication disappears (at least in my case). This seems to be a resolution issue, maybe filing a bug to the plugin developer might help more.

– Andrea Giammarchi
Dec 17 '18 at 11:39





had the same issue, I ended up patching after the build script via sed. I have also noticed that this happens only if the current build includes a module that a submodule includes too. If the project is included from a third module, the duplication disappears (at least in my case). This seems to be a resolution issue, maybe filing a bug to the plugin developer might help more.

– Andrea Giammarchi
Dec 17 '18 at 11:39












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53302600%2frollup-babel-duplicate-definitions-in-output-file%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53302600%2frollup-babel-duplicate-definitions-in-output-file%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Xamarin.iOS Cant Deploy on Iphone

Glorious Revolution

Dulmage-Mendelsohn matrix decomposition in Python