gig / rollup-plugin-rename-extensions Goto Github PK
View Code? Open in Web Editor NEWRollup plugin to take modules from RollUp and rename their file extensions.
Home Page: https://www.npmjs.com/package/@betit/rollup-plugin-rename-extensions
Rollup plugin to take modules from RollUp and rename their file extensions.
Home Page: https://www.npmjs.com/package/@betit/rollup-plugin-rename-extensions
This is possibly related to #2, but I am trying to rename coffeescript files for an esm build, and am encountering an error with your plugin. This error appears to occur because this_1
is undefined in line 87 of dist/index.js
, when Acorn parses the code to AST.
var ast = this_1.parse(file.code, {
ecmaVersion: 6,
sourceType: 'module',
});
The rollup config for this change is at https://github.com/UW-Macrostrat/ui-components/blob/feature/tree-shaking/rollup.config.js,
and the issue can be reproduced by npm run build
in the tree-shaking
branch of that repository. I've tried reordering plugins, removing CSS compilation, etc.
Thanks for any insight!
Full traceback:
[!] (plugin rename-rollup) SyntaxError: Unexpected token (35:42)
undefined (35:42)
SyntaxError: Unexpected token (35:42)
at Object.pp$4.raise (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:2827:15)
at Object.pp.unexpected (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:688:10)
at Object.pp$3.parseIdent (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:2778:12)
at Object.pp$3.parsePropertyName (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:2583:107)
at Object.pp$3.parseProperty (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:2510:10)
at Object.pp$3.parseObj (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:2464:23)
at Object.pp$3.parseExprAtom (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:2247:19)
at Object.parseExprAtom (/Users/Daven/Projects/Tools/ui-components/node_modules/rollup/dist/rollup.js:15340:26)
at Object.parseExprAtom (/Users/Daven/Projects/Tools/ui-components/node_modules/rollup/dist/rollup.js:15357:30)
at Object.pp$3.parseExprSubscripts (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:2090:21)
at Object.pp$3.parseMaybeUnary (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:2067:19)
at Object.pp$3.parseExprOps (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:2011:21)
at Object.pp$3.parseMaybeConditional (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:1994:21)
at Object.pp$3.parseMaybeAssign (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:1969:21)
at Object.pp$3.parseParenAndDistinguishExpression (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:2322:30)
at Object.pp$3.parseExprAtom (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:2231:43)
at Object.parseExprAtom (/Users/Daven/Projects/Tools/ui-components/node_modules/rollup/dist/rollup.js:15340:26)
at Object.parseExprAtom (/Users/Daven/Projects/Tools/ui-components/node_modules/rollup/dist/rollup.js:15357:30)
at Object.pp$3.parseExprSubscripts (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:2090:21)
at Object.pp$3.parseMaybeUnary (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:2067:19)
at Object.pp$3.parseExprOps (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:2011:21)
at Object.pp$3.parseMaybeConditional (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:1994:21)
at Object.pp$3.parseMaybeAssign (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:1969:21)
at Object.pp$3.parseExpression (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:1934:21)
at Object.pp$1.parseStatement (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:878:47)
at Object.parseStatement (/Users/Daven/Projects/Tools/ui-components/node_modules/rollup/dist/rollup.js:15334:26)
at Object.parseStatement (/Users/Daven/Projects/Tools/ui-components/node_modules/rollup/dist/rollup.js:15375:30)
at Object.pp$1.parseBlock (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:1162:23)
at Object.pp$3.parseFunctionBody (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:2672:24)
at Object.pp$3.parseMethod (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:2613:10)
at Object.pp$1.parseClassMethod (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:1388:25)
at Object.pp$1.parseClassElement (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:1377:10)
at Object.pp$1.parseClass (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:1316:26)
at Object.pp$1.parseStatement (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:834:19)
at Object.parseStatement (/Users/Daven/Projects/Tools/ui-components/node_modules/rollup/dist/rollup.js:15334:26)
at Object.parseStatement (/Users/Daven/Projects/Tools/ui-components/node_modules/rollup/dist/rollup.js:15375:30)
at Object.pp$1.parseBlock (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:1162:23)
at Object.pp$3.parseFunctionBody (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:2672:24)
at Object.pp$1.parseFunction (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:1284:10)
at Object.pp$3.parseExprAtom (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:2252:19)
at Object.parseExprAtom (/Users/Daven/Projects/Tools/ui-components/node_modules/rollup/dist/rollup.js:15340:26)
at Object.parseExprAtom (/Users/Daven/Projects/Tools/ui-components/node_modules/rollup/dist/rollup.js:15357:30)
at Object.pp$3.parseExprSubscripts (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:2090:21)
at Object.pp$3.parseMaybeUnary (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:2067:19)
at Object.pp$3.parseExprOps (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:2011:21)
at Object.pp$3.parseMaybeConditional (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:1994:21)
at Object.pp$3.parseMaybeAssign (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:1969:21)
at Object.pp$3.parseParenAndDistinguishExpression (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:2322:30)
at Object.pp$3.parseExprAtom (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:2231:43)
at Object.parseExprAtom (/Users/Daven/Projects/Tools/ui-components/node_modules/rollup/dist/rollup.js:15340:26)
at Object.parseExprAtom (/Users/Daven/Projects/Tools/ui-components/node_modules/rollup/dist/rollup.js:15357:30)
at Object.pp$3.parseExprSubscripts (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:2090:21)
at Object.pp$3.parseMaybeUnary (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:2067:19)
at Object.pp$3.parseExprOps (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:2011:21)
at Object.pp$3.parseMaybeConditional (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:1994:21)
at Object.pp$3.parseMaybeAssign (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:1969:21)
at Object.pp$3.parseMaybeAssign (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:1979:25)
at Object.pp$3.parseExpression (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:1934:21)
at Object.pp$1.parseStatement (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:878:47)
at Object.parseStatement (/Users/Daven/Projects/Tools/ui-components/node_modules/rollup/dist/rollup.js:15334:26)
at Object.parseStatement (/Users/Daven/Projects/Tools/ui-components/node_modules/rollup/dist/rollup.js:15375:30)
at Object.pp$1.parseTopLevel (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:745:23)
at Object.parse (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:552:17)
at Function.parse (/Users/Daven/Projects/Tools/ui-components/node_modules/acorn/dist/acorn.js:575:37)
at Object.Graph.contextParse [as parse] (/Users/Daven/Projects/Tools/ui-components/node_modules/rollup/dist/rollup.js:16684:70)
at _loop_1 (/Users/Daven/Projects/Tools/ui-components/node_modules/@betit/rollup-plugin-rename-extensions/dist/index.js:87:38)
at Object.generateBundle (/Users/Daven/Projects/Tools/ui-components/node_modules/@betit/rollup-plugin-rename-extensions/dist/index.js:118:17)
at Promise.resolve.then (/Users/Daven/Projects/Tools/ui-components/node_modules/rollup/dist/rollup.js:15806:25)
at <anonymous>:null:null
Hello,
first of all, thank you for sharing.
I am trying to remake my ui library from git submodule to npm package, I dicided to use rollup and I am trying to implement this setup. BUT I end on this issue:
rollup --config ./rollup.config.js --watch
rollup v1.32.1
bundles ./src/index.js โ dist...
[!] (plugin rename-rollup) SyntaxError: Unexpected token (8:12)
undefined (8:12)
SyntaxError: Unexpected token (8:12)
at Object.pp$4.raise (myProject/node_modules/rollup/node_modules/acorn/dist/acorn.js:2840:15)
at Object.pp.unexpected (myProject/node_modules/rollup/node_modules/acorn/dist/acorn.js:689:10)
at Object.pp$3.parseIdent (myProject/node_modules/rollup/node_modules/acorn/dist/acorn.js:2791:12)
at Object.pp$3.parsePropertyName (myProject/node_modules/rollup/node_modules/acorn/dist/acorn.js:2597:107)
at Object.pp$3.parseProperty (myProject/node_modules/rollup/node_modules/acorn/dist/acorn.js:2524:10)
at Object.pp$3.parseObj (myProject/node_modules/rollup/node_modules/acorn/dist/acorn.js:2478:23)
at Object.pp$3.parseExprAtom (myProject/node_modules/rollup/node_modules/acorn/dist/acorn.js:2239:19)
at Object.parseExprAtom (myProject/node_modules/rollup/dist/shared/node-entry.js:11811:30)
at Object.pp$3.parseExprSubscripts (myProject/node_modules/rollup/node_modules/acorn/dist/acorn.js:2092:21)
at Object.pp$3.parseMaybeUnary (myProject/node_modules/rollup/node_modules/acorn/dist/acorn.js:2069:19)
at Object.pp$3.parseExprOps (myProject/node_modules/rollup/node_modules/acorn/dist/acorn.js:2013:21)
at Object.pp$3.parseMaybeConditional (myProject/node_modules/rollup/node_modules/acorn/dist/acorn.js:1996:21)
at Object.pp$3.parseMaybeAssign (myProject/node_modules/rollup/node_modules/acorn/dist/acorn.js:1969:21)
at Object.pp$3.parseExpression (myProject/node_modules/rollup/node_modules/acorn/dist/acorn.js:1935:21)
at Object.pp$1.parseReturnStatement (myProject/node_modules/rollup/node_modules/acorn/dist/acorn.js:1005:33)
at Object.pp$1.parseStatement (myProject/node_modules/rollup/node_modules/acorn/dist/acorn.js:835:37)
Could anybody give me some hint please? Thanks :)
I am seeing the following stack trace, when trying to apply this plugin to a second, project.
[!] (rename-rollup plugin) TypeError: baseVisitor[type] is not a function
TypeError: baseVisitor[type] is not a function
at c (/Users/jfiel2/dev/spinnaker/deck/app/scripts/modules/core/node_modules/acorn-walk/src/index.js:23:22)
at Object.skipThrough (/Users/jfiel2/dev/spinnaker/deck/app/scripts/modules/core/node_modules/acorn-walk/src/index.js:182:37)
at c (/Users/jfiel2/dev/spinnaker/deck/app/scripts/modules/core/node_modules/acorn-walk/src/index.js:23:22)
at Object.base.NewExpression.base.CallExpression (/Users/jfiel2/dev/spinnaker/deck/app/scripts/modules/core/node_modules/acorn-walk/src/index.js:341:3)
at c (/Users/jfiel2/dev/spinnaker/deck/app/scripts/modules/core/node_modules/acorn-walk/src/index.js:23:22)
at Object.skipThrough (/Users/jfiel2/dev/spinnaker/deck/app/scripts/modules/core/node_modules/acorn-walk/src/index.js:182:37)
at c (/Users/jfiel2/dev/spinnaker/deck/app/scripts/modules/core/node_modules/acorn-walk/src/index.js:23:22)
at Object.base.MemberExpression (/Users/jfiel2/dev/spinnaker/deck/app/scripts/modules/core/node_modules/acorn-walk/src/index.js:347:3)
at c (/Users/jfiel2/dev/spinnaker/deck/app/scripts/modules/core/node_modules/acorn-walk/src/index.js:23:22)
at Object.skipThrough (/Users/jfiel2/dev/spinnaker/deck/app/scripts/modules/core/node_modules/acorn-walk/src/index.js:182:37)
at c (/Users/jfiel2/dev/spinnaker/deck/app/scripts/modules/core/node_modules/acorn-walk/src/index.js:23:22)
at Object.base.NewExpression.base.CallExpression (/Users/jfiel2/dev/spinnaker/deck/app/scripts/modules/core/node_modules/acorn-walk/src/index.js:341:3)
at c (/Users/jfiel2/dev/spinnaker/deck/app/scripts/modules/core/node_modules/acorn-walk/src/index.js:23:22)
at Object.skipThrough (/Users/jfiel2/dev/spinnaker/deck/app/scripts/modules/core/node_modules/acorn-walk/src/index.js:182:37)
at c (/Users/jfiel2/dev/spinnaker/deck/app/scripts/modules/core/node_modules/acorn-walk/src/index.js:23:22)
at Object.base.MemberExpression (/Users/jfiel2/dev/spinnaker/deck/app/scripts/modules/core/node_modules/acorn-walk/src/index.js:347:3)
at c (/Users/jfiel2/dev/spinnaker/deck/app/scripts/modules/core/node_modules/acorn-walk/src/index.js:23:22)
at Object.skipThrough (/Users/jfiel2/dev/spinnaker/deck/app/scripts/modules/core/node_modules/acorn-walk/src/index.js:182:37)
at c (/Users/jfiel2/dev/spinnaker/deck/app/scripts/modules/core/node_modules/acorn-walk/src/index.js:23:22)
at Object.base.NewExpression.base.CallExpression (/Users/jfiel2/dev/spinnaker/deck/app/scripts/modules/core/node_modules/acorn-walk/src/index.js:341:3)
at c (/Users/jfiel2/dev/spinnaker/deck/app/scripts/modules/core/node_modules/acorn-walk/src/index.js:23:22)
at Object.skipThrough (/Users/jfiel2/dev/spinnaker/deck/app/scripts/modules/core/node_modules/acorn-walk/src/index.js:182:37)
error Command failed with exit code 1.
interestingly enough this plugin works just fine in the first project I applied it to.
Here is the relevant section my my rollup config
input: [webpackConfig.entry.lib],
output: { name: 'core', dir: 'lib/', format: 'es', sourcemap: true },
treeshake: true,
preserveModules: true,
plugins: [
renameExtensions({
include: ['**/*.ts', '**/*.tsx'],
mappings: {
'.ts': '.js',
'.tsx': '.js',
}
}),
I doubt this is enough information to be useful, but I will create the issue anyways and attach a remote debugger in the morning.
Cheers,
Justin
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.