Skip to content

Commit

Permalink
Use the new helper package
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Nov 29, 2018
1 parent 7c76ad2 commit 77e56ac
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
Expand Up @@ -53,12 +53,6 @@ export function verifyUsedFeatures(path, file) {
}
}

if (hasFeature(file, FEATURES.decorators)) {
throw new Error(
"@babel/plugin-class-features doesn't support decorators yet.",
);
}

if (path.isClassPrivateMethod()) {
if (!hasFeature(file, FEATURES.privateMethods)) {
throw path.buildCodeFrameError("Class private methods are not enabled.");
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-plugin-proposal-decorators/package.json
Expand Up @@ -16,7 +16,7 @@
],
"dependencies": {
"@babel/helper-plugin-utils": "^7.0.0",
"@babel/plugin-class-features": "^7.1.4",
"@babel/helper-create-class-features-plugin": "^7.1.4",
"@babel/plugin-syntax-decorators": "^7.1.0"
},
"peerDependencies": {
Expand Down
20 changes: 10 additions & 10 deletions packages/babel-plugin-proposal-decorators/src/index.js
@@ -1,9 +1,11 @@
/* eslint-disable local-rules/plugin-name */

import { declare } from "@babel/helper-plugin-utils";
import syntaxDecorators from "@babel/plugin-syntax-decorators";
import pluginClassFeatures, {
enableFeature,
import {
createClassFeaturePlugin,
FEATURES,
} from "@babel/plugin-class-features";
} from "@babel/helper-create-class-features-plugin";
import legacyVisitor from "./transformer-legacy";

export default declare((api, options) => {
Expand Down Expand Up @@ -45,17 +47,15 @@ export default declare((api, options) => {
};
}

return {
return createClassFeaturePlugin({
name: "proposal-decorators",
inherits: pluginClassFeatures,

feature: FEATURES.decorators,
// loose: options.loose, Not supported

manipulateOptions({ generatorOpts, parserOpts }) {
parserOpts.plugins.push(["decorators", { decoratorsBeforeExport }]);
generatorOpts.decoratorsBeforeExport = decoratorsBeforeExport;
},

pre() {
enableFeature(this.file, FEATURES.decorators, false);
},
};
});
});

0 comments on commit 77e56ac

Please sign in to comment.