Coder Social home page Coder Social logo

Comments (5)

oscarni avatar oscarni commented on September 21, 2024 1

Encountered the same problem after upgrading from Ember 3.17 to 3.21. The unprocessed version of the initializer is included in the production build resulting in error Uncaught SyntaxError: Unexpected token 'export'.

Removing https://github.com/minichate/ember-cli-conditional-compile/blob/master/index.js#L114-L118 this first part of this if-statement makes the build load. The initializer in included in the production build, but at least it still works.

(Should mention that I also had this similar issue when upgrading to Ember 3.4. But I do recall that ember-cli-conditional-compile 1.1.1 fixed it.)

from ember-cli-conditional-compile.

kiwi-josh avatar kiwi-josh commented on September 21, 2024

Update: It seems as though the conditional compiling works if I update route/controller/component in question to an ES6 class 🤔

Is this expected behaviour?

from ember-cli-conditional-compile.

lozjackson avatar lozjackson commented on September 21, 2024

I have found this also.. If I use a version of Ember-cli >= 3.4 then the ember-cli-conditional-compile-features initialiser gets included in the production output:

...e.default=a})
import Ember from"ember"
var initializer={name:"ember-cli-conditional-compile-features",initialize:function(e){Ember.Logger.info("Initializing feature flags")}},feature_flags=EMBER_CLI_CONDITIONAL_COMPILE_INJECTIONS
Object.keys(feature_flags).map(function(e){window[e]=feature_flags[e]})
export default initializer
define(...

This causes an error Uncaught SyntaxError: Unexpected identifier.

Also, to add to this, If I use a version of ember-cli-conditional-compile >= 1.1.0, then the enableCompile property in the ember-cli-conditional-compile/index.js file is undefined resulting in the initializer being included in the output with the feature flags baked in. This means the feature flags are also added to the window object in production.

EDIT: after a bit more investigation, it seems to break at ember cli version >= 3.4.0-beta.2. ...and it works as expected (removes the initialiser) with version <= 3.4.0-beta.1

from ember-cli-conditional-compile.

halfbyte avatar halfbyte commented on September 21, 2024

After lots of debugging last night, I think I found the cause of this error. The way the compiling has been reorganized for Ember 3.4 pushed a lot of code from broccoli/ember-app.js to broccoli/default-packager.js and in the process, we ended up with this new processAppAndDependencies method.

What happens there is that applyCustomTransforms takes the original tree, does some transforms (I think it's mainly there to process AMD modules), whereas processJavaScript takes the merged tree and does all the pre- and postprocessing (including the part in ember-cli-conditional-compile that is supposed to remove the module, but also doing the module wrapping), and when the result of those two calls gets merged, as the file is removed, it gets replaced by the unprocessed version of the module - if the module would not be removed, it would (as it's precedence is higher) replace the unprocessed version during the mergeTrees call.

I think this is an ember-cli bug?

from ember-cli-conditional-compile.

tehmaestro avatar tehmaestro commented on September 21, 2024

Hi, I encountered the same problem. I opened an issue on ember-cli.

from ember-cli-conditional-compile.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.