How can I use rollup to process a JS file in a non-strict mode?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
Today, when I used rollup to process several js files, an error occurred. After checking, the reason was that the js file to be processed contained a syntax that was not allowed in strict mode, which caused the babel to report an error. Later, during the test, I deleted the babel and just used rollup, but it still reported an error. Test file does not indicate 'use strict'.
So, how can I use rollup to process a JS file in a non-strict mode?
The js file to be processed by rollup:
var public = 1;
console.log(public);
The rollup file:
const rollup = require('rollup');
let iOptions =
input: "strict.js",
plugins: [
]
const oOptions =
format: 'cjs',
strict: false,
dir: './',
file: 'out.js',
sourcemap: false
async function build()
const bundle = await rollup.rollup(iOptions);
await bundle.write(oOptions);
build();
With babel, the error is: UnhandledPromiseRejectionWarning: SyntaxError: D:EC-IoTBugsSyntaxErrorstrict.js: public is a reserved word in strict mode (1:4)
Only rollup, the error is : UnhandledPromiseRejectionWarning: Error: The keyword 'public' is reserved
javascript babel rollup rollupjs
|
show 2 more comments
Today, when I used rollup to process several js files, an error occurred. After checking, the reason was that the js file to be processed contained a syntax that was not allowed in strict mode, which caused the babel to report an error. Later, during the test, I deleted the babel and just used rollup, but it still reported an error. Test file does not indicate 'use strict'.
So, how can I use rollup to process a JS file in a non-strict mode?
The js file to be processed by rollup:
var public = 1;
console.log(public);
The rollup file:
const rollup = require('rollup');
let iOptions =
input: "strict.js",
plugins: [
]
const oOptions =
format: 'cjs',
strict: false,
dir: './',
file: 'out.js',
sourcemap: false
async function build()
const bundle = await rollup.rollup(iOptions);
await bundle.write(oOptions);
build();
With babel, the error is: UnhandledPromiseRejectionWarning: SyntaxError: D:EC-IoTBugsSyntaxErrorstrict.js: public is a reserved word in strict mode (1:4)
Only rollup, the error is : UnhandledPromiseRejectionWarning: Error: The keyword 'public' is reserved
javascript babel rollup rollupjs
I think what you mean is to let me try to avoid this, but the current demand is that the rollup can handle such files, including but not limited to usingwith
,delete
,arguments
, etc.
– amapleaf
Nov 15 '18 at 8:03
as it mentionspublic
is reserved keyword with or without strict mode on, hope this is clear
– Nikos M.
Nov 15 '18 at 9:51
Yeah, I know, but when I run this code with nodejs, it works fine. So, what puzzles me is, why does the rollup report an error when processing it? Is it because rollup defaults to strict mode when parsing files like this?
– amapleaf
Nov 15 '18 at 10:56
1
no it has nothing to do with strict mode, it simply refuses to use reserved keywords as variable names
– Nikos M.
Nov 15 '18 at 11:28
So, is this the situation caused by the rollup? Including using arguments as function variables, using the with keyword, and delete a variable using delete.
– amapleaf
Nov 15 '18 at 11:52
|
show 2 more comments
Today, when I used rollup to process several js files, an error occurred. After checking, the reason was that the js file to be processed contained a syntax that was not allowed in strict mode, which caused the babel to report an error. Later, during the test, I deleted the babel and just used rollup, but it still reported an error. Test file does not indicate 'use strict'.
So, how can I use rollup to process a JS file in a non-strict mode?
The js file to be processed by rollup:
var public = 1;
console.log(public);
The rollup file:
const rollup = require('rollup');
let iOptions =
input: "strict.js",
plugins: [
]
const oOptions =
format: 'cjs',
strict: false,
dir: './',
file: 'out.js',
sourcemap: false
async function build()
const bundle = await rollup.rollup(iOptions);
await bundle.write(oOptions);
build();
With babel, the error is: UnhandledPromiseRejectionWarning: SyntaxError: D:EC-IoTBugsSyntaxErrorstrict.js: public is a reserved word in strict mode (1:4)
Only rollup, the error is : UnhandledPromiseRejectionWarning: Error: The keyword 'public' is reserved
javascript babel rollup rollupjs
Today, when I used rollup to process several js files, an error occurred. After checking, the reason was that the js file to be processed contained a syntax that was not allowed in strict mode, which caused the babel to report an error. Later, during the test, I deleted the babel and just used rollup, but it still reported an error. Test file does not indicate 'use strict'.
So, how can I use rollup to process a JS file in a non-strict mode?
The js file to be processed by rollup:
var public = 1;
console.log(public);
The rollup file:
const rollup = require('rollup');
let iOptions =
input: "strict.js",
plugins: [
]
const oOptions =
format: 'cjs',
strict: false,
dir: './',
file: 'out.js',
sourcemap: false
async function build()
const bundle = await rollup.rollup(iOptions);
await bundle.write(oOptions);
build();
With babel, the error is: UnhandledPromiseRejectionWarning: SyntaxError: D:EC-IoTBugsSyntaxErrorstrict.js: public is a reserved word in strict mode (1:4)
Only rollup, the error is : UnhandledPromiseRejectionWarning: Error: The keyword 'public' is reserved
javascript babel rollup rollupjs
javascript babel rollup rollupjs
asked Nov 15 '18 at 7:57
amapleafamapleaf
62
62
I think what you mean is to let me try to avoid this, but the current demand is that the rollup can handle such files, including but not limited to usingwith
,delete
,arguments
, etc.
– amapleaf
Nov 15 '18 at 8:03
as it mentionspublic
is reserved keyword with or without strict mode on, hope this is clear
– Nikos M.
Nov 15 '18 at 9:51
Yeah, I know, but when I run this code with nodejs, it works fine. So, what puzzles me is, why does the rollup report an error when processing it? Is it because rollup defaults to strict mode when parsing files like this?
– amapleaf
Nov 15 '18 at 10:56
1
no it has nothing to do with strict mode, it simply refuses to use reserved keywords as variable names
– Nikos M.
Nov 15 '18 at 11:28
So, is this the situation caused by the rollup? Including using arguments as function variables, using the with keyword, and delete a variable using delete.
– amapleaf
Nov 15 '18 at 11:52
|
show 2 more comments
I think what you mean is to let me try to avoid this, but the current demand is that the rollup can handle such files, including but not limited to usingwith
,delete
,arguments
, etc.
– amapleaf
Nov 15 '18 at 8:03
as it mentionspublic
is reserved keyword with or without strict mode on, hope this is clear
– Nikos M.
Nov 15 '18 at 9:51
Yeah, I know, but when I run this code with nodejs, it works fine. So, what puzzles me is, why does the rollup report an error when processing it? Is it because rollup defaults to strict mode when parsing files like this?
– amapleaf
Nov 15 '18 at 10:56
1
no it has nothing to do with strict mode, it simply refuses to use reserved keywords as variable names
– Nikos M.
Nov 15 '18 at 11:28
So, is this the situation caused by the rollup? Including using arguments as function variables, using the with keyword, and delete a variable using delete.
– amapleaf
Nov 15 '18 at 11:52
I think what you mean is to let me try to avoid this, but the current demand is that the rollup can handle such files, including but not limited to using
with
, delete
, arguments
, etc.– amapleaf
Nov 15 '18 at 8:03
I think what you mean is to let me try to avoid this, but the current demand is that the rollup can handle such files, including but not limited to using
with
, delete
, arguments
, etc.– amapleaf
Nov 15 '18 at 8:03
as it mentions
public
is reserved keyword with or without strict mode on, hope this is clear– Nikos M.
Nov 15 '18 at 9:51
as it mentions
public
is reserved keyword with or without strict mode on, hope this is clear– Nikos M.
Nov 15 '18 at 9:51
Yeah, I know, but when I run this code with nodejs, it works fine. So, what puzzles me is, why does the rollup report an error when processing it? Is it because rollup defaults to strict mode when parsing files like this?
– amapleaf
Nov 15 '18 at 10:56
Yeah, I know, but when I run this code with nodejs, it works fine. So, what puzzles me is, why does the rollup report an error when processing it? Is it because rollup defaults to strict mode when parsing files like this?
– amapleaf
Nov 15 '18 at 10:56
1
1
no it has nothing to do with strict mode, it simply refuses to use reserved keywords as variable names
– Nikos M.
Nov 15 '18 at 11:28
no it has nothing to do with strict mode, it simply refuses to use reserved keywords as variable names
– Nikos M.
Nov 15 '18 at 11:28
So, is this the situation caused by the rollup? Including using arguments as function variables, using the with keyword, and delete a variable using delete.
– amapleaf
Nov 15 '18 at 11:52
So, is this the situation caused by the rollup? Including using arguments as function variables, using the with keyword, and delete a variable using delete.
– amapleaf
Nov 15 '18 at 11:52
|
show 2 more comments
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53314745%2fhow-can-i-use-rollup-to-process-a-js-file-in-a-non-strict-mode%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
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53314745%2fhow-can-i-use-rollup-to-process-a-js-file-in-a-non-strict-mode%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
I think what you mean is to let me try to avoid this, but the current demand is that the rollup can handle such files, including but not limited to using
with
,delete
,arguments
, etc.– amapleaf
Nov 15 '18 at 8:03
as it mentions
public
is reserved keyword with or without strict mode on, hope this is clear– Nikos M.
Nov 15 '18 at 9:51
Yeah, I know, but when I run this code with nodejs, it works fine. So, what puzzles me is, why does the rollup report an error when processing it? Is it because rollup defaults to strict mode when parsing files like this?
– amapleaf
Nov 15 '18 at 10:56
1
no it has nothing to do with strict mode, it simply refuses to use reserved keywords as variable names
– Nikos M.
Nov 15 '18 at 11:28
So, is this the situation caused by the rollup? Including using arguments as function variables, using the with keyword, and delete a variable using delete.
– amapleaf
Nov 15 '18 at 11:52