- Notifications
You must be signed in to change notification settings - Fork17
update rollup version support and update test#12
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Open
ssszp wants to merge1 commit intojavascript-obfuscator:masterChoose a base branch fromssszp:fix--rollup-new-version-compatible
base:master
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
Uh oh!
There was an error while loading.Please reload this page.
Open
Changes fromall commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
29 changes: 29 additions & 0 deletionsdist/rollup-plugin-javascript-obfuscator.cjs.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| 'use strict'; | ||
| var JavaScriptObfuscator = require('javascript-obfuscator'); | ||
| function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
| var JavaScriptObfuscator__default = /*#__PURE__*/_interopDefaultLegacy(JavaScriptObfuscator); | ||
| function javascriptObfuscator(options) { | ||
| if ( options === void 0 ) options = {}; | ||
| return { | ||
| name: 'javascript-obfuscator', | ||
| renderChunk: function renderChunk(code) { | ||
| var obfuscationResult = JavaScriptObfuscator__default['default'].obfuscate(code, options); | ||
| var result = { code: obfuscationResult.getObfuscatedCode() }; | ||
| if (options.sourceMap && options.sourceMapMode !== 'inline') { | ||
| result.map = obfuscationResult.getSourceMap(); | ||
| } | ||
| return result; | ||
| } | ||
| }; | ||
| } | ||
| module.exports = javascriptObfuscator; |
23 changes: 23 additions & 0 deletionsdist/rollup-plugin-javascript-obfuscator.es.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import JavaScriptObfuscator from 'javascript-obfuscator'; | ||
| function javascriptObfuscator(options) { | ||
| if ( options === void 0 ) options = {}; | ||
| return { | ||
| name: 'javascript-obfuscator', | ||
| renderChunk: function renderChunk(code) { | ||
| var obfuscationResult = JavaScriptObfuscator.obfuscate(code, options); | ||
| var result = { code: obfuscationResult.getObfuscatedCode() }; | ||
| if (options.sourceMap && options.sourceMapMode !== 'inline') { | ||
| result.map = obfuscationResult.getSourceMap(); | ||
| } | ||
| return result; | ||
| } | ||
| }; | ||
| } | ||
| export default javascriptObfuscator; |
11 changes: 6 additions & 5 deletionspackage.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletionsrollup.config.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
22 changes: 11 additions & 11 deletionssrc/index.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,19 @@ | ||
| import JavaScriptObfuscator from 'javascript-obfuscator'; | ||
| export default function javascriptObfuscator(options = {}) { | ||
| return { | ||
| name: 'javascript-obfuscator', | ||
| renderChunk(code) { | ||
| const obfuscationResult = JavaScriptObfuscator.obfuscate(code, options); | ||
| let result = {code: obfuscationResult.getObfuscatedCode()}; | ||
| if (options.sourceMap && options.sourceMapMode !== 'inline') { | ||
| result.map = obfuscationResult.getSourceMap(); | ||
| } | ||
| return result; | ||
| } | ||
| }; | ||
| } |
52 changes: 26 additions & 26 deletionstest/test.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,39 +1,39 @@ | ||
| const rollup = require('rollup'), | ||
| obfuscatorPlugin = require('..'); | ||
| process.chdir(__dirname); | ||
| const testFunc = function (entry, configValue, expectedValue, expectedSourceMap) { | ||
| return function () { | ||
| expect.assertions(2); | ||
| return rollup.rollup({ | ||
| input: `./fixtures/${entry}.js`, | ||
| plugins: [ | ||
| obfuscatorPlugin(configValue) | ||
| ] | ||
| }).then(function (bundle) { | ||
| return bundle.generate({format: 'esm',sourcemap: !!expectedSourceMap}).then(function (res) { | ||
| expect(res.output[0].code).toContain(expectedValue); | ||
| if (expectedSourceMap) { | ||
| expect(res.output[0].map).toBeInstanceOf(Object); | ||
| } | ||
| else { | ||
| expect(res.output[0].map).toBe(null); | ||
| } | ||
| }); | ||
| }); | ||
| } | ||
| }; | ||
| describe('rollup-plugin-javascript-obfuscator', function () { | ||
| it('obfuscates the code', testFunc('simple', {}, 'console.log("Hello, world!");')); | ||
| it('generates source maps correctly', testFunc('simple', {sourceMap: true}, 'console.log("Hello, world!");', true)); | ||
| it('generates inline source maps correctly', testFunc('simple', { | ||
| sourceMap: true, | ||
| sourceMapMode: 'inline' | ||
| }, 'console.log("Hello, world!");')); | ||
| }); |
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.